MCPcopy Index your code
hub / github.com/RustPython/RustPython / makeZip

Method makeZip

Lib/test/test_zipimport.py:115–133  ·  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

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