本文整理汇总了Python中setuptools.extern.six.binary_type方法的典型用法代码示例。如果您正苦于以下问题:Python six.binary_type方法的具体用法?Python six.binary_type怎么用?Python six.binary_type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类setuptools.extern.six
的用法示例。
在下文中一共展示了six.binary_type方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: glob1
# 需要导入模块: from setuptools.extern import six [as 别名]
# 或者: from setuptools.extern.six import binary_type [as 别名]
def glob1(dirname, pattern):
if not dirname:
if isinstance(pattern, binary_type):
dirname = os.curdir.encode('ASCII')
else:
dirname = os.curdir
try:
names = os.listdir(dirname)
except OSError:
return []
return fnmatch.filter(names, pattern)
示例2: _rlistdir
# 需要导入模块: from setuptools.extern import six [as 别名]
# 或者: from setuptools.extern.six import binary_type [as 别名]
def _rlistdir(dirname):
if not dirname:
if isinstance(dirname, binary_type):
dirname = binary_type(os.curdir, 'ASCII')
else:
dirname = os.curdir
try:
names = os.listdir(dirname)
except os.error:
return
for x in names:
yield x
path = os.path.join(dirname, x) if dirname else x
for y in _rlistdir(path):
yield os.path.join(x, y)
示例3: has_magic
# 需要导入模块: from setuptools.extern import six [as 别名]
# 或者: from setuptools.extern.six import binary_type [as 别名]
def has_magic(s):
if isinstance(s, binary_type):
match = magic_check_bytes.search(s)
else:
match = magic_check.search(s)
return match is not None
示例4: _isrecursive
# 需要导入模块: from setuptools.extern import six [as 别名]
# 或者: from setuptools.extern.six import binary_type [as 别名]
def _isrecursive(pattern):
if isinstance(pattern, binary_type):
return pattern == b'**'
else:
return pattern == '**'
示例5: escape
# 需要导入模块: from setuptools.extern import six [as 别名]
# 或者: from setuptools.extern.six import binary_type [as 别名]
def escape(pathname):
"""Escape all special characters.
"""
# Escaping is done by wrapping any of "*?[" between square brackets.
# Metacharacters do not work in the drive part and shouldn't be escaped.
drive, pathname = os.path.splitdrive(pathname)
if isinstance(pathname, binary_type):
pathname = magic_check_bytes.sub(br'[\1]', pathname)
else:
pathname = magic_check.sub(r'[\1]', pathname)
return drive + pathname