当前位置: 首页>>代码示例>>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;未经允许,请勿转载。