本文整理汇总了Python中imp.get_tag方法的典型用法代码示例。如果您正苦于以下问题:Python imp.get_tag方法的具体用法?Python imp.get_tag怎么用?Python imp.get_tag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类imp
的用法示例。
在下文中一共展示了imp.get_tag方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _gen_exclusion_paths
# 需要导入模块: import imp [as 别名]
# 或者: from imp import get_tag [as 别名]
def _gen_exclusion_paths():
"""
Generate file paths to be excluded for namespace packages (bytecode
cache files).
"""
# always exclude the package module itself
yield '__init__.py'
yield '__init__.pyc'
yield '__init__.pyo'
if not hasattr(imp, 'get_tag'):
return
base = os.path.join('__pycache__', '__init__.' + imp.get_tag())
yield base + '.pyc'
yield base + '.pyo'
yield base + '.opt-1.pyc'
yield base + '.opt-2.pyc'
示例2: _gen_exclusion_paths
# 需要导入模块: import imp [as 别名]
# 或者: from imp import get_tag [as 别名]
def _gen_exclusion_paths():
"""
Generate file paths to be excluded for namespace packages (bytecode
cache files).
"""
# always exclude the package module itself
yield '__init__.py'
yield '__init__.pyc'
yield '__init__.pyo'
if not hasattr(imp, 'get_tag'):
return
base = os.path.join('__pycache__', '__init__.' + imp.get_tag())
yield base + '.pyc'
yield base + '.pyo'
示例3: cache_zip_file
# 需要导入模块: import imp [as 别名]
# 或者: from imp import get_tag [as 别名]
def cache_zip_file(self, zip_path):
"""Read a zip file and cache the modules and packages found inside it.
"""
zip = zipfile.ZipFile(zip_path)
for archiveName in zip.namelist():
baseName, ext = os.path.splitext(archiveName)
if ext not in ('.pyc', '.pyo'):
continue
if '__pycache__' in baseName:
if sys.version_info[:2] < (3, 2) \
or not baseName.endswith(imp.get_tag()):
continue
baseName = os.path.splitext(source_from_cache(archiveName))[0]
nameparts = baseName.split("/")
if len(nameparts) > 1 and nameparts[-1] == '__init__':
# dir/__init__.pyc -> dir is a package
self.record_loadable_module(nameparts[:-1], None, zip, True)
self.record_loadable_module(nameparts, archiveName, zip, False)