本文整理汇总了Python中setuptools.unicode_utils.filesys_decode函数的典型用法代码示例。如果您正苦于以下问题:Python filesys_decode函数的具体用法?Python filesys_decode怎么用?Python filesys_decode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了filesys_decode函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_filesys_decode_fs_encoding_is_None
def test_filesys_decode_fs_encoding_is_None(monkeypatch):
"""
Test filesys_decode does not raise TypeError when
getfilesystemencoding returns None.
"""
monkeypatch.setattr('sys.getfilesystemencoding', lambda: None)
unicode_utils.filesys_decode(b'test')
示例2: _safe_path
def _safe_path(self, path):
enc_warn = "'%s' not %s encodable -- skipping"
# To avoid accidental trans-codings errors, first to unicode
u_path = unicode_utils.filesys_decode(path)
if u_path is None:
log.warn("'%s' in unexpected encoding -- skipping" % path)
return False
# Must ensure utf-8 encodability
utf8_path = unicode_utils.try_encode(u_path, "utf-8")
if utf8_path is None:
log.warn(enc_warn, path, 'utf-8')
return False
try:
# accept is either way checks out
if os.path.exists(u_path) or os.path.exists(utf8_path):
return True
# this will catch any encode errors decoding u_path
except UnicodeEncodeError:
log.warn(enc_warn, path, sys.getfilesystemencoding())
示例3: _manifest_normalize
def _manifest_normalize(self, path):
path = unicode_utils.filesys_decode(path)
return path.replace(os.sep, '/')