From 922c4c29feed402b7e43c8c2b5350a5e8638cc1a Mon Sep 17 00:00:00 2001 From: stonebig Date: Sat, 5 Jul 2025 10:36:12 +0200 Subject: [PATCH] we can .zip with Python only, but 4x slower --- wppm/utils.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/wppm/utils.py b/wppm/utils.py index dcec0207..df8e759b 100644 --- a/wppm/utils.py +++ b/wppm/utils.py @@ -303,6 +303,16 @@ def normalize(this): """Apply PEP 503 normalization to the string.""" return re.sub(r"[-_.]+", "-", this).lower() +def zip_directory(folder_path, output_zip_path): + folder_path = Path(folder_path) + output_zip_path = Path(output_zip_path) + + with zipfile.ZipFile(output_zip_path, 'w', compression=zipfile.ZIP_DEFLATED) as zipf: + for file in folder_path.rglob('*'): + if file.is_file(): + arcname = file.relative_to(folder_path) + zipf.write(file, arcname) + if __name__ == '__main__': print_box("Test") dname = sys.prefix