MCPcopy Index your code
hub / github.com/python/cpython / makeZip

Method makeZip

Lib/test/test_zipimport.py:113–131  ·  view source on GitHub ↗
(self, files, zipName=TEMP_ZIP, *,
                comment=None, file_comment=None, stuff=None, prefix='', **kw)

Source from the content-addressed store, hash-verified

111 fp.write(data)
112
113 def makeZip(self, files, zipName=TEMP_ZIP, *,
114 comment=None, file_comment=None, stuff=None, prefix='', **kw):
115 # Create a zip archive based set of modules/packages
116 # defined by files in the zip file zipName.
117 # If stuff is not None, it is prepended to the archive.
118 self.addCleanup(os_helper.unlink, zipName)
119
120 with ZipFile(zipName, "w", compression=self.compression) as z:
121 self.writeZip(z, files, file_comment=file_comment, prefix=prefix)
122 if comment is not None:
123 z.comment = comment
124
125 if stuff is not None:
126 # Prepend 'stuff' to the start of the zipfile
127 with open(zipName, "rb") as f:
128 data = f.read()
129 with open(zipName, "wb") as f:
130 f.write(stuff)
131 f.write(data)
132
133 def writeZip(self, z, files, *, file_comment=None, prefix=''):
134 for name, data in files.items():

Calls 6

writeZipMethod · 0.95
ZipFileClass · 0.90
addCleanupMethod · 0.80
openFunction · 0.50
readMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected