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


Python six.text_type方法代码示例

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


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

示例1: filesys_decode

# 需要导入模块: from setuptools.extern import six [as 别名]
# 或者: from setuptools.extern.six import text_type [as 别名]
def filesys_decode(path):
    """
    Ensure that the given path is decoded,
    NONE when no expected encoding works
    """

    if isinstance(path, six.text_type):
        return path

    fs_enc = sys.getfilesystemencoding() or 'utf-8'
    candidates = fs_enc, 'utf-8'

    for enc in candidates:
        try:
            return path.decode(enc)
        except UnicodeDecodeError:
            continue 
开发者ID:jpush,项目名称:jbox,代码行数:19,代码来源:unicode_utils.py

示例2: test_bad_url_double_scheme

# 需要导入模块: from setuptools.extern import six [as 别名]
# 或者: from setuptools.extern.six import text_type [as 别名]
def test_bad_url_double_scheme(self):
        """
        A bad URL with a double scheme should raise a DistutilsError.
        """
        index = setuptools.package_index.PackageIndex(
            hosts=('www.example.com',)
        )

        # issue 20
        url = 'http://http://svn.pythonpaste.org/Paste/wphp/trunk'
        try:
            index.open_url(url)
        except distutils.errors.DistutilsError as error:
            msg = six.text_type(error)
            assert (
                'nonnumeric port' in msg
                or 'getaddrinfo failed' in msg
                or 'Name or service not known' in msg
            )
            return
        raise RuntimeError("Did not raise") 
开发者ID:pypa,项目名称:setuptools,代码行数:23,代码来源:test_packageindex.py

示例3: decompose

# 需要导入模块: from setuptools.extern import six [as 别名]
# 或者: from setuptools.extern.six import text_type [as 别名]
def decompose(path):
    if isinstance(path, six.text_type):
        return unicodedata.normalize('NFD', path)
    try:
        path = path.decode('utf-8')
        path = unicodedata.normalize('NFD', path)
        path = path.encode('utf-8')
    except UnicodeError:
        pass  # Not UTF-8
    return path 
开发者ID:jpush,项目名称:jbox,代码行数:12,代码来源:unicode_utils.py

示例4: b

# 需要导入模块: from setuptools.extern import six [as 别名]
# 或者: from setuptools.extern.six import text_type [as 别名]
def b(s, encoding='utf-8'):
    if isinstance(s, six.text_type):
        return s.encode(encoding, errors)
    return s 
开发者ID:jpush,项目名称:jbox,代码行数:6,代码来源:upload_docs.py

示例5: isascii

# 需要导入模块: from setuptools.extern import six [as 别名]
# 或者: from setuptools.extern.six import text_type [as 别名]
def isascii(s):
        try:
            six.text_type(s, 'ascii')
            return True
        except UnicodeError:
            return False 
开发者ID:jpush,项目名称:jbox,代码行数:8,代码来源:easy_install.py


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