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


Python archive_util.zipfile方法代码示例

本文整理汇总了Python中distutils.archive_util.zipfile方法的典型用法代码示例。如果您正苦于以下问题:Python archive_util.zipfile方法的具体用法?Python archive_util.zipfile怎么用?Python archive_util.zipfile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在distutils.archive_util的用法示例。


在下文中一共展示了archive_util.zipfile方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_make_zipfile_no_zlib

# 需要导入模块: from distutils import archive_util [as 别名]
# 或者: from distutils.archive_util import zipfile [as 别名]
def test_make_zipfile_no_zlib(self):
        patch(self, archive_util.zipfile, 'zlib', None)  # force zlib ImportError

        called = []
        zipfile_class = zipfile.ZipFile
        def fake_zipfile(*a, **kw):
            if kw.get('compression', None) == zipfile.ZIP_STORED:
                called.append((a, kw))
            return zipfile_class(*a, **kw)

        patch(self, archive_util.zipfile, 'ZipFile', fake_zipfile)

        # create something to tar and compress
        tmpdir = self._create_files()
        base_name = os.path.join(self.mkdtemp(), 'archive')
        with change_cwd(tmpdir):
            make_zipfile(base_name, 'dist')

        tarball = base_name + '.zip'
        self.assertEqual(called,
                         [((tarball, "w"), {'compression': zipfile.ZIP_STORED})])
        self.assertTrue(os.path.exists(tarball))
        with zipfile.ZipFile(tarball) as zf:
            self.assertEqual(sorted(zf.namelist()),
                             ['dist/file1', 'dist/file2', 'dist/sub/file3']) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:27,代码来源:test_archive_util.py

示例2: test_make_zipfile_no_zlib

# 需要导入模块: from distutils import archive_util [as 别名]
# 或者: from distutils.archive_util import zipfile [as 别名]
def test_make_zipfile_no_zlib(self):
        patch(self, archive_util.zipfile, 'zlib', None)  # force zlib ImportError

        called = []
        zipfile_class = zipfile.ZipFile
        def fake_zipfile(*a, **kw):
            if kw.get('compression', None) == zipfile.ZIP_STORED:
                called.append((a, kw))
            return zipfile_class(*a, **kw)

        patch(self, archive_util.zipfile, 'ZipFile', fake_zipfile)

        # create something to tar and compress
        tmpdir, tmpdir2, base_name = self._create_files()
        make_zipfile(base_name, tmpdir)

        tarball = base_name + '.zip'
        self.assertEqual(called,
                         [((tarball, "w"), {'compression': zipfile.ZIP_STORED})])
        self.assertTrue(os.path.exists(tarball)) 
开发者ID:IronLanguages,项目名称:ironpython3,代码行数:22,代码来源:test_archive_util.py

示例3: test_make_zipfile_no_zlib

# 需要导入模块: from distutils import archive_util [as 别名]
# 或者: from distutils.archive_util import zipfile [as 别名]
def test_make_zipfile_no_zlib(self):
        patch(self, archive_util.zipfile, 'zlib', None)  # force zlib ImportError

        called = []
        zipfile_class = zipfile.ZipFile
        def fake_zipfile(*a, **kw):
            if kw.get('compression', None) == zipfile.ZIP_STORED:
                called.append((a, kw))
            return zipfile_class(*a, **kw)

        patch(self, archive_util.zipfile, 'ZipFile', fake_zipfile)

        # create something to tar and compress
        tmpdir = self._create_files()
        base_name = os.path.join(self.mkdtemp(), 'archive')
        with change_cwd(tmpdir):
            make_zipfile(base_name, 'dist')

        tarball = base_name + '.zip'
        self.assertEqual(called,
                         [((tarball, "w"), {'compression': zipfile.ZIP_STORED})])
        self.assertTrue(os.path.exists(tarball))
        with zipfile.ZipFile(tarball) as zf:
            self.assertEqual(sorted(zf.namelist()), self._zip_created_files) 
开发者ID:pypa,项目名称:setuptools,代码行数:26,代码来源:test_archive_util.py

示例4: test_make_zipfile

# 需要导入模块: from distutils import archive_util [as 别名]
# 或者: from distutils.archive_util import zipfile [as 别名]
def test_make_zipfile(self):
        # creating something to tar
        tmpdir = self._create_files()
        base_name = os.path.join(self.mkdtemp(), 'archive')
        with change_cwd(tmpdir):
            make_zipfile(base_name, 'dist')

        # check if the compressed tarball was created
        tarball = base_name + '.zip'
        self.assertTrue(os.path.exists(tarball))
        with zipfile.ZipFile(tarball) as zf:
            self.assertEqual(sorted(zf.namelist()),
                             ['dist/file1', 'dist/file2', 'dist/sub/file3']) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:15,代码来源:test_archive_util.py

示例5: test_make_zipfile

# 需要导入模块: from distutils import archive_util [as 别名]
# 或者: from distutils.archive_util import zipfile [as 别名]
def test_make_zipfile(self):
        # creating something to tar
        tmpdir = self._create_files()
        base_name = os.path.join(self.mkdtemp(), 'archive')
        with change_cwd(tmpdir):
            make_zipfile(base_name, 'dist')

        # check if the compressed tarball was created
        tarball = base_name + '.zip'
        self.assertTrue(os.path.exists(tarball))
        with zipfile.ZipFile(tarball) as zf:
            self.assertEqual(sorted(zf.namelist()), self._zip_created_files) 
开发者ID:pypa,项目名称:setuptools,代码行数:14,代码来源:test_archive_util.py


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