MCPcopy
hub / github.com/pyodide/pyodide / make_zip_archive

Function make_zip_archive

tools/create_zipfile.py:146–171  ·  view source on GitHub ↗

Create a zip archive out of a input folder Parameters ---------- archive_path Path to the zip file that will be created input_dir input dir to compress compression_level compression level of the resulting zip file.

(
    archive_path: Path,
    input_dir: Path,
    compression_level: int = 6,
)

Source from the content-addressed store, hash-verified

144
145
146def make_zip_archive(
147 archive_path: Path,
148 input_dir: Path,
149 compression_level: int = 6,
150) -> None:
151 """Create a zip archive out of a input folder
152
153 Parameters
154 ----------
155 archive_path
156 Path to the zip file that will be created
157 input_dir
158 input dir to compress
159 compression_level
160 compression level of the resulting zip file.
161 """
162 if compression_level > 0:
163 compression = zipfile.ZIP_DEFLATED
164 else:
165 compression = zipfile.ZIP_STORED
166
167 with zipfile.ZipFile(
168 archive_path, "w", compression=compression, compresslevel=compression_level
169 ) as zf:
170 for file in input_dir.rglob("*"):
171 zf.write(file, file.relative_to(input_dir))
172
173
174if __name__ == "__main__":

Callers 1

create_zipfileFunction · 0.85

Calls 1

writeMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…