當前位置: 首頁>>代碼示例>>Python>>正文


Python candidate.InstallationCandidate方法代碼示例

本文整理匯總了Python中pip._internal.models.candidate.InstallationCandidate方法的典型用法代碼示例。如果您正苦於以下問題:Python candidate.InstallationCandidate方法的具體用法?Python candidate.InstallationCandidate怎麽用?Python candidate.InstallationCandidate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pip._internal.models.candidate的用法示例。


在下文中一共展示了candidate.InstallationCandidate方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: from_specifier

# 需要導入模塊: from pip._internal.models import candidate [as 別名]
# 或者: from pip._internal.models.candidate import InstallationCandidate [as 別名]
def from_specifier(
        cls,
        candidates,     # type: List[InstallationCandidate]
        specifier,      # type: specifiers.BaseSpecifier
        prereleases,    # type: Optional[bool]
        evaluator,      # type: CandidateEvaluator
    ):
        # type: (...) -> FoundCandidates
        versions = {
            str(v) for v in specifier.filter(
                # We turn the version object into a str here because otherwise
                # when we're debundled but setuptools isn't, Python will see
                # packaging.version.Version and
                # pkg_resources._vendor.packaging.version.Version as different
                # types. This way we'll use a str as a common data interchange
                # format. If we stop using the pkg_resources provided specifier
                # and start using our own, we can drop the cast to str().
                (str(c.version) for c in candidates),
                prereleases=prereleases,
            )
        }
        return cls(candidates, versions, evaluator) 
開發者ID:PacktPublishing,項目名稱:Mastering-Elasticsearch-7.0,代碼行數:24,代碼來源:index.py

示例2: __init__

# 需要導入模塊: from pip._internal.models import candidate [as 別名]
# 或者: from pip._internal.models.candidate import InstallationCandidate [as 別名]
def __init__(
        self,
        candidates,             # type: List[InstallationCandidate]
        applicable_candidates,  # type: List[InstallationCandidate]
        best_candidate,         # type: Optional[InstallationCandidate]
    ):
        # type: (...) -> None
        """
        :param candidates: A sequence of all available candidates found.
        :param applicable_candidates: The applicable candidates.
        :param best_candidate: The most preferred candidate found, or None
            if no applicable candidates were found.
        """
        assert set(applicable_candidates) <= set(candidates)

        if best_candidate is None:
            assert not applicable_candidates
        else:
            assert best_candidate in applicable_candidates

        self._applicable_candidates = applicable_candidates
        self._candidates = candidates

        self.best_candidate = best_candidate 
開發者ID:pantsbuild,項目名稱:pex,代碼行數:26,代碼來源:package_finder.py

示例3: compute_best_candidate

# 需要導入模塊: from pip._internal.models import candidate [as 別名]
# 或者: from pip._internal.models.candidate import InstallationCandidate [as 別名]
def compute_best_candidate(
        self,
        candidates,      # type: List[InstallationCandidate]
    ):
        # type: (...) -> BestCandidateResult
        """
        Compute and return a `BestCandidateResult` instance.
        """
        applicable_candidates = self.get_applicable_candidates(candidates)

        best_candidate = self.sort_best_candidate(applicable_candidates)

        return BestCandidateResult(
            candidates,
            applicable_candidates=applicable_candidates,
            best_candidate=best_candidate,
        ) 
開發者ID:pantsbuild,項目名稱:pex,代碼行數:19,代碼來源:package_finder.py

示例4: get_install_candidate

# 需要導入模塊: from pip._internal.models import candidate [as 別名]
# 或者: from pip._internal.models.candidate import InstallationCandidate [as 別名]
def get_install_candidate(self, link_evaluator, link):
        # type: (LinkEvaluator, Link) -> Optional[InstallationCandidate]
        """
        If the link is a candidate for install, convert it to an
        InstallationCandidate and return it. Otherwise, return None.
        """
        is_candidate, result = link_evaluator.evaluate_link(link)
        if not is_candidate:
            if result:
                self._log_skipped_link(link, reason=result)
            return None

        return InstallationCandidate(
            name=link_evaluator.project_name,
            link=link,
            # Convert the Text result to str since InstallationCandidate
            # accepts str.
            version=str(result),
        ) 
開發者ID:pantsbuild,項目名稱:pex,代碼行數:21,代碼來源:package_finder.py

示例5: process_project_url

# 需要導入模塊: from pip._internal.models import candidate [as 別名]
# 或者: from pip._internal.models.candidate import InstallationCandidate [as 別名]
def process_project_url(self, project_url, link_evaluator):
        # type: (Link, LinkEvaluator) -> List[InstallationCandidate]
        logger.debug(
            'Fetching project page and analyzing links: %s', project_url,
        )
        html_page = self._link_collector.fetch_page(project_url)
        if html_page is None:
            return []

        page_links = list(parse_links(html_page))

        with indent_log():
            package_links = self.evaluate_links(
                link_evaluator,
                links=page_links,
            )

        return package_links 
開發者ID:pantsbuild,項目名稱:pex,代碼行數:20,代碼來源:package_finder.py

示例6: get_install_candidate

# 需要導入模塊: from pip._internal.models import candidate [as 別名]
# 或者: from pip._internal.models.candidate import InstallationCandidate [as 別名]
def get_install_candidate(self, link_evaluator, link):
        # type: (LinkEvaluator, Link) -> Optional[InstallationCandidate]
        """
        If the link is a candidate for install, convert it to an
        InstallationCandidate and return it. Otherwise, return None.
        """
        is_candidate, result = link_evaluator.evaluate_link(link)
        if not is_candidate:
            if result:
                self._log_skipped_link(link, reason=result)
            return None

        return InstallationCandidate(
            project=link_evaluator.project_name,
            link=link,
            # Convert the Text result to str since InstallationCandidate
            # accepts str.
            version=str(result),
        ) 
開發者ID:boris-kz,項目名稱:CogAlg,代碼行數:21,代碼來源:index.py

示例7: make_found_candidates

# 需要導入模塊: from pip._internal.models import candidate [as 別名]
# 或者: from pip._internal.models.candidate import InstallationCandidate [as 別名]
def make_found_candidates(
        self,
        candidates,      # type: List[InstallationCandidate]
    ):
        # type: (...) -> FoundCandidates
        """
        Create and return a `FoundCandidates` instance.

        :param specifier: An optional object implementing `filter`
            (e.g. `packaging.specifiers.SpecifierSet`) to filter applicable
            versions.
        """
        applicable_candidates = self.get_applicable_candidates(candidates)

        return FoundCandidates(
            candidates,
            applicable_candidates=applicable_candidates,
            evaluator=self,
        ) 
開發者ID:V1EngineeringInc,項目名稱:V1EngineeringInc-Docs,代碼行數:21,代碼來源:index.py

示例8: _sort_key

# 需要導入模塊: from pip._internal.models import candidate [as 別名]
# 或者: from pip._internal.models.candidate import InstallationCandidate [as 別名]
def _sort_key(self, candidate):
        # type: (InstallationCandidate) -> CandidateSortingKey
        """
        Function used to generate link sort key for link tuples.
        The greater the return value, the more preferred it is.
        If not finding wheels, then sorted by version only.
        If finding wheels, then the sort order is by version, then:
          1. existing installs
          2. wheels ordered via Wheel.support_index_min(self._valid_tags)
          3. source archives
        If prefer_binary was set, then all wheels are sorted above sources.
        Note: it was considered to embed this logic into the Link
              comparison operators, but then different sdist links
              with the same version, would have to be considered equal
        """
        support_num = len(self._valid_tags)
        build_tag = tuple()  # type: BuildTag
        binary_preference = 0
        if candidate.location.is_wheel:
            # can raise InvalidWheelFilename
            wheel = Wheel(candidate.location.filename)
            if not wheel.supported(self._valid_tags):
                raise UnsupportedWheel(
                    "%s is not a supported wheel for this platform. It "
                    "can't be sorted." % wheel.filename
                )
            if self._prefer_binary:
                binary_preference = 1
            pri = -(wheel.support_index_min(self._valid_tags))
            if wheel.build_tag is not None:
                match = re.match(r'^(\d+)(.*)$', wheel.build_tag)
                build_tag_groups = match.groups()
                build_tag = (int(build_tag_groups[0]), build_tag_groups[1])
        else:  # sdist
            pri = -(support_num)
        return (binary_preference, candidate.version, build_tag, pri) 
開發者ID:PacktPublishing,項目名稱:Mastering-Elasticsearch-7.0,代碼行數:38,代碼來源:index.py

示例9: get_best_candidate

# 需要導入模塊: from pip._internal.models import candidate [as 別名]
# 或者: from pip._internal.models.candidate import InstallationCandidate [as 別名]
def get_best_candidate(self, candidates):
        # type: (List[InstallationCandidate]) -> InstallationCandidate
        """
        Return the best candidate per the instance's sort order, or None if
        no candidates are given.
        """
        if not candidates:
            return None

        return max(candidates, key=self._sort_key) 
開發者ID:PacktPublishing,項目名稱:Mastering-Elasticsearch-7.0,代碼行數:12,代碼來源:index.py

示例10: __init__

# 需要導入模塊: from pip._internal.models import candidate [as 別名]
# 或者: from pip._internal.models.candidate import InstallationCandidate [as 別名]
def __init__(
        self,
        candidates,     # type: List[InstallationCandidate]
        versions,       # type: Set[str]
        evaluator,      # type: CandidateEvaluator
    ):
        # type: (...) -> None
        self._candidates = candidates
        self._evaluator = evaluator
        self._versions = versions 
開發者ID:PacktPublishing,項目名稱:Mastering-Elasticsearch-7.0,代碼行數:12,代碼來源:index.py

示例11: iter_all

# 需要導入模塊: from pip._internal.models import candidate [as 別名]
# 或者: from pip._internal.models.candidate import InstallationCandidate [as 別名]
def iter_all(self):
        # type: () -> Iterable[InstallationCandidate]
        """Iterate through all candidates.
        """
        return iter(self._candidates) 
開發者ID:PacktPublishing,項目名稱:Mastering-Elasticsearch-7.0,代碼行數:7,代碼來源:index.py

示例12: get_best

# 需要導入模塊: from pip._internal.models import candidate [as 別名]
# 或者: from pip._internal.models.candidate import InstallationCandidate [as 別名]
def get_best(self):
        # type: () -> Optional[InstallationCandidate]
        """Return the best candidate available, or None if no applicable
        candidates are found.
        """
        candidates = list(self.iter_applicable())
        return self._evaluator.get_best_candidate(candidates) 
開發者ID:PacktPublishing,項目名稱:Mastering-Elasticsearch-7.0,代碼行數:9,代碼來源:index.py

示例13: _package_versions

# 需要導入模塊: from pip._internal.models import candidate [as 別名]
# 或者: from pip._internal.models.candidate import InstallationCandidate [as 別名]
def _package_versions(
        self,
        links,  # type: Iterable[Link]
        search  # type: Search
    ):
        # type: (...) -> List[Optional[InstallationCandidate]]
        result = []
        for link in self._sort_links(links):
            v = self._link_package_versions(link, search)
            if v is not None:
                result.append(v)
        return result 
開發者ID:PacktPublishing,項目名稱:Mastering-Elasticsearch-7.0,代碼行數:14,代碼來源:index.py

示例14: iter_applicable

# 需要導入模塊: from pip._internal.models import candidate [as 別名]
# 或者: from pip._internal.models.candidate import InstallationCandidate [as 別名]
def iter_applicable(self):
        # type: () -> Iterable[InstallationCandidate]
        """Iterate through candidates matching the versions associated with
        this instance.
        """
        # Again, converting version to str to deal with debundling.
        return (c for c in self.iter_all() if str(c.version) in self._versions) 
開發者ID:PacktPublishing,項目名稱:Mastering-Elasticsearch-7.0,代碼行數:9,代碼來源:index.py


注:本文中的pip._internal.models.candidate.InstallationCandidate方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。