当前位置: 首页>>代码示例>>Python>>正文


Python imp.get_tag方法代码示例

本文整理汇总了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' 
开发者ID:jpush,项目名称:jbox,代码行数:21,代码来源:install_lib.py

示例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' 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:19,代码来源:install_lib.py

示例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) 
开发者ID:tensorlang,项目名称:tensorlang,代码行数:22,代码来源:finder.py


注:本文中的imp.get_tag方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。