本文整理汇总了Python中pants.fs.archive.ZIP.create方法的典型用法代码示例。如果您正苦于以下问题:Python ZIP.create方法的具体用法?Python ZIP.create怎么用?Python ZIP.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pants.fs.archive.ZIP
的用法示例。
在下文中一共展示了ZIP.create方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_aarfile
# 需要导入模块: from pants.fs.archive import ZIP [as 别名]
# 或者: from pants.fs.archive.ZIP import create [as 别名]
def create_aarfile(self, location, name, filenames=None):
"""Create an aar file, using the contents created by self.unpacked_aar_library."""
with temporary_dir() as temp:
aar_contents = self.unpacked_aar_library(temp, filenames=filenames)
archive = ZIP.create(aar_contents, location, name)
aar = os.path.join(location, '{}.aar'.format(name))
os.rename(archive, aar)
return aar
示例2: test_zip_filter
# 需要导入模块: from pants.fs.archive import ZIP [as 别名]
# 或者: from pants.fs.archive.ZIP import create [as 别名]
def test_zip_filter(self):
def do_filter(path):
return path == 'allowed.txt'
with temporary_dir() as fromdir:
touch(os.path.join(fromdir, 'allowed.txt'))
touch(os.path.join(fromdir, 'disallowed.txt'))
with temporary_dir() as archivedir:
archive = ZIP.create(fromdir, archivedir, 'archive')
with temporary_dir() as todir:
ZIP.extract(archive, todir, filter_func=do_filter)
self.assertEquals(set(['allowed.txt']), self._listtree(todir, empty_dirs=False))