コード例 #1
0
ファイル: index.py プロジェクト: vault-the/poetry
    def specs_from_fixtures(cls, fixture_name):
        if fixture_name in cls._specs_from_fixtures:
            return cls._specs_from_fixtures[fixture_name]

        packages_by_name = {}
        with open(os.path.join(FIXTURE_INDEX_DIR,
                               fixture_name + '.json')) as fd:
            content = json.load(fd)

            for name, releases in content.items():
                packages_by_name[name] = []

                for release in releases:
                    package = Package(name, release['version'],
                                      release['version'])

                    for dependency_name, requirements in release[
                            'dependencies'].items():
                        package.requires.append(
                            Dependency(dependency_name, requirements))

                    packages_by_name[name].append(package)

                packages_by_name[name].sort(
                    key=cmp_to_key(lambda x, y: 0 if x.version[1] == y.version[
                        1] else -1 * int(less_than(x[1], y[1]) or -1)))

        return packages_by_name
コード例 #2
0
ファイル: provider.py プロジェクト: oca159/poetry
    def search_for(self, dependency):  # type: (Dependency) -> List[Package]
        """
        Search for the specifications that match the given dependency.

        The specifications in the returned list will be considered in reverse
        order, so the latest version ought to be last.
        """
        if dependency in self._search_for:
            return self._search_for[dependency]

        if dependency.is_vcs():
            packages = self.search_for_vcs(dependency)
        else:
            packages = self._pool.find_packages(
                dependency.name,
                dependency.constraint,
                extras=dependency.extras,
            )

            packages.sort(
                key=cmp_to_key(lambda x, y: 0 if x.version == y.version else -1
                               * int(less_than(x.version, y.version) or -1)))

        self._search_for[dependency] = packages

        return self._search_for[dependency]
コード例 #3
0
ファイル: provider.py プロジェクト: undu/poetry
    def search_for(self, dependency):  # type: (Dependency) -> List[Package]
        """
        Search for the specifications that match the given dependency.

        The specifications in the returned list will be considered in reverse
        order, so the latest version ought to be last.
        """
        if dependency in self._search_for:
            return self._search_for[dependency]

        if dependency.is_vcs():
            packages = self.search_for_vcs(dependency)
        elif dependency.is_file():
            packages = self.search_for_file(dependency)
        elif dependency.is_directory():
            packages = self.search_for_directory(dependency)
        else:
            constraint = dependency.constraint

            # If we have already seen this dependency
            # we take the most restrictive constraint
            if dependency.name in self._constraints:
                current_constraint = self._constraints[dependency.name]
                if str(dependency.constraint) == '*':
                    # The new constraint accepts anything
                    # so we take the previous one
                    constraint = current_constraint

            self._constraints[dependency.name] = constraint

            packages = self._pool.find_packages(
                dependency.name,
                constraint,
                extras=dependency.extras,
                allow_prereleases=dependency.allows_prereleases())

            packages.sort(
                key=cmp_to_key(lambda x, y: 0 if x.version == y.version else -1
                               * int(less_than(x.version, y.version) or -1)))

        self._search_for[dependency] = packages

        return self._search_for[dependency]