本文整理汇总了Python中os.supports_effective_ids方法的典型用法代码示例。如果您正苦于以下问题:Python os.supports_effective_ids方法的具体用法?Python os.supports_effective_ids怎么用?Python os.supports_effective_ids使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类os
的用法示例。
在下文中一共展示了os.supports_effective_ids方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: list_files
# 需要导入模块: import os [as 别名]
# 或者: from os import supports_effective_ids [as 别名]
def list_files(path):
"""
Return list of sorted file paths in `path`
Raise ReadError if `path` or any file or directory underneath it is not
readable.
"""
def assert_readable(path):
os_supports_effective_ids = os.access in os.supports_effective_ids
if not os.access(path, os.R_OK, effective_ids=os_supports_effective_ids):
raise error.ReadError(errno.EACCES, path)
if os.path.isfile(path):
assert_readable(path)
return [path]
else:
def onerror(exc):
raise error.ReadError(getattr(exc, 'errno', None),
getattr(exc, 'filename', None))
filepaths = []
for dirpath, dirnames, filenames in os.walk(path, onerror=onerror):
for filename in filenames:
filepath = os.path.join(dirpath, filename)
assert_readable(filepath)
filepaths.append(filepath)
return list(sorted(filepaths, key=lambda fp: str(fp).casefold()))
示例2: requiresWriteAccess
# 需要导入模块: import os [as 别名]
# 或者: from os import supports_effective_ids [as 别名]
def requiresWriteAccess(self, path):
# effective_ids unavailable on windows
if not os.access(path, os.W_OK,
effective_ids=os.access in os.supports_effective_ids):
self.skipTest('requires write access to the installed location')
filename = os.path.join(path, 'test_zipfile.try')
try:
fd = os.open(filename, os.O_WRONLY | os.O_CREAT)
os.close(fd)
except Exception:
self.skipTest('requires write access to the installed location')
unlink(filename)
示例3: effective_access
# 需要导入模块: import os [as 别名]
# 或者: from os import supports_effective_ids [as 别名]
def effective_access(*args, **kwargs):
if 'effective_ids' not in kwargs:
try:
kwargs['effective_ids'] = os.access in os.supports_effective_ids
except AttributeError:
pass
return os.access(*args, **kwargs)