当前位置: 首页>>代码示例>>Python>>正文


Python bar.Bar方法代码示例

本文整理汇总了Python中pip._vendor.progress.bar.Bar方法的典型用法代码示例。如果您正苦于以下问题:Python bar.Bar方法的具体用法?Python bar.Bar怎么用?Python bar.Bar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pip._vendor.progress.bar的用法示例。


在下文中一共展示了bar.Bar方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _select_progress_class

# 需要导入模块: from pip._vendor.progress import bar [as 别名]
# 或者: from pip._vendor.progress.bar import Bar [as 别名]
def _select_progress_class(preferred, fallback):
    # type: (Bar, Bar) -> Bar
    encoding = getattr(preferred.file, "encoding", None)

    # If we don't know what encoding this file is in, then we'll just assume
    # that it doesn't support unicode and use the ASCII bar.
    if not encoding:
        return fallback

    # Collect all of the possible characters we want to use with the preferred
    # bar.
    characters = [
        getattr(preferred, "empty_fill", six.text_type()),
        getattr(preferred, "fill", six.text_type()),
    ]
    characters += list(getattr(preferred, "phases", []))

    # Try to decode the characters we're using for the bar using the encoding
    # of the given file, if this works then we'll assume that we can use the
    # fancier bar and if not we'll fall back to the plaintext bar.
    try:
        six.text_type().join(characters).encode(encoding)
    except UnicodeEncodeError:
        return fallback
    else:
        return preferred 
开发者ID:ali5h,项目名称:rules_pip,代码行数:28,代码来源:progress_bars.py


注:本文中的pip._vendor.progress.bar.Bar方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。