8000 Merge pull request #1662 from stonebig/master · winpython/winpython@b6d6ae0 · GitHub
[go: up one dir, main page]

Skip to content

Commit b6d6ae0

Browse files
authored
Merge pull request #1662 from stonebig/master
we can .zip with Python only, but 4x slower
2 parents 4a1cd78 + 922c4c2 commit b6d6ae0

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

wppm/utils.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,16 @@ def normalize(this):
303303
"""Apply PEP 503 normalization to the string."""
304304
return re.sub(r"[-_.]+", "-", this).lower()
305305

306+
def zip_directory(folder_path, output_zip_path):
307+
folder_path = Path(folder_path)
308+
output_zip_path = Path(output_zip_path)
309+
310+
with zipfile.ZipFile(output_zip_path, 'w', compression=zipfile.ZIP_DEFLATED) as zipf:
311+
for file in folder_path.rglob('*'):
312+
if file.is_file():
313+
arcname = file.relative_to(folder_path)
314+
zipf.write(file, arcname)
315+
306316
if __name__ == '__main__':
307317
print_box("Test")
308318
dname = sys.prefix

0 commit comments

Comments
 (0)
0