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


Python hashes.FAVORITE_HASH屬性代碼示例

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


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

示例1: __init__

# 需要導入模塊: from pip._internal.utils import hashes [as 別名]
# 或者: from pip._internal.utils.hashes import FAVORITE_HASH [as 別名]
def __init__(self, *args, **kw):
        super(HashCommand, self).__init__(*args, **kw)
        self.cmd_opts.add_option(
            '-a', '--algorithm',
            dest='algorithm',
            choices=STRONG_HASHES,
            action='store',
            default=FAVORITE_HASH,
            help='The hash algorithm to use: one of %s' %
                 ', '.join(STRONG_HASHES))
        self.parser.insert_option_group(0, self.cmd_opts) 
開發者ID:HaoZhang95,項目名稱:Python24,代碼行數:13,代碼來源:hash.py

示例2: __init__

# 需要導入模塊: from pip._internal.utils import hashes [as 別名]
# 或者: from pip._internal.utils.hashes import FAVORITE_HASH [as 別名]
def __init__(self, *args, **kw):
        super(HashCommand, self).__init__(*args, **kw)
        self.cmd_opts.add_option(
            '-a', '--algorithm',
            dest='algorithm',
            choices=STRONG_HASHES,
            action='store',
            default=FAVORITE_HASH,
            help='The hash algorithm to use: one of {}'.format(
                 ', '.join(STRONG_HASHES)))
        self.parser.insert_option_group(0, self.cmd_opts) 
開發者ID:ali5h,項目名稱:rules_pip,代碼行數:13,代碼來源:hash.py

示例3: _get_hashes_from_pypi

# 需要導入模塊: from pip._internal.utils import hashes [as 別名]
# 或者: from pip._internal.utils.hashes import FAVORITE_HASH [as 別名]
def _get_hashes_from_pypi(self, ireq):
        """
        Return a set of hashes from PyPI JSON API for a given InstallRequirement.
        Return None if fetching data is failed or missing digests.
        """
        project = self._get_project(ireq)
        if project is None:
            return None

        _, version, _ = as_tuple(ireq)

        try:
            release_files = project["releases"][version]
        except KeyError:
            log.debug("Missing release files on PyPI")
            return None

        try:
            hashes = {
                "{algo}:{digest}".format(
                    algo=FAVORITE_HASH, digest=file_["digests"][FAVORITE_HASH]
                )
                for file_ in release_files
                if file_["packagetype"] in self.HASHABLE_PACKAGE_TYPES
            }
        except KeyError:
            log.debug("Missing digests of release files on PyPI")
            return None

        return hashes 
開發者ID:ali5h,項目名稱:rules_pip,代碼行數:32,代碼來源:pypi.py

示例4: _get_file_hash

# 需要導入模塊: from pip._internal.utils import hashes [as 別名]
# 或者: from pip._internal.utils.hashes import FAVORITE_HASH [as 別名]
def _get_file_hash(self, link):
        log.debug("Hashing {}".format(link.show_url))
        h = hashlib.new(FAVORITE_HASH)
        with open_local_or_remote_file(link, self.session) as f:
            # Chunks to iterate
            chunks = iter(lambda: f.stream.read(FILE_CHUNK_SIZE), b"")

            # Choose a context manager depending on verbosity
            if log.verbosity >= 1:
                iter_length = f.size / FILE_CHUNK_SIZE if f.size else None
                bar_template = "{prefix}  |%(bar)s| %(info)s".format(
                    prefix=" " * log.current_indent
                )
                context_manager = progressbar(
                    chunks,
                    length=iter_length,
                    # Make it look like default pip progress bar
                    fill_char="█",
                    empty_char=" ",
                    bar_template=bar_template,
                    width=32,
                )
            else:
                context_manager = contextlib.nullcontext(chunks)

            # Iterate over the chosen context manager
            with context_manager as bar:
                for chunk in bar:
                    h.update(chunk)
        return ":".join([FAVORITE_HASH, h.hexdigest()]) 
開發者ID:ali5h,項目名稱:rules_pip,代碼行數:32,代碼來源:pypi.py

示例5: get_hashes

# 需要導入模塊: from pip._internal.utils import hashes [as 別名]
# 或者: from pip._internal.utils.hashes import FAVORITE_HASH [as 別名]
def get_hashes(self, ireq):
        key = key_from_ireq(ireq)
        existing_pin = self.existing_pins.get(key)
        if existing_pin and ireq_satisfied_by_existing_pin(ireq, existing_pin):
            if PIP_VERSION[:2] <= (20, 0):
                hashes = existing_pin.options.get("hashes", {})
            else:
                hashes = existing_pin.hash_options
            hexdigests = hashes.get(FAVORITE_HASH)
            if hexdigests:
                return {
                    ":".join([FAVORITE_HASH, hexdigest]) for hexdigest in hexdigests
                }
        return self.repository.get_hashes(ireq) 
開發者ID:ali5h,項目名稱:rules_pip,代碼行數:16,代碼來源:local.py


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