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