本文整理匯總了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