finder.py 文件源码

python
阅读 35 收藏 0 点赞 0 评论 0

项目:cx_Freeze 作者: anthony-tuininga 项目源码 文件源码
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 not baseName.endswith(imp.get_tag()):
                    continue
                baseName = \
                        os.path.splitext(imp.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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号