Files
COGMOD-HWI/Project/tmp/temp.py
T
2025-04-19 16:52:03 -04:00

20 lines
621 B
Python

from pathlib import Path, PurePosixPath
import zipfile, fnmatch
ROOT = Path.cwd()
zip_path = ROOT / "report_overleaf.zip"
exclude = ['*.aux', '*.log', '*.out', '*.pdf', '*.zip', '*.pyc',
'__pycache__', '.git*', '*.DS_Store']
def include(path: Path) -> bool:
rel = path.relative_to(ROOT)
return not any(fnmatch.fnmatch(rel.as_posix(), pat) for pat in exclude)
with zipfile.ZipFile(zip_path, "w", zipfile.ZIP_DEFLATED) as zf:
for p in ROOT.rglob('*'):
if p.is_file() and include(p):
zf.write(p, arcname=PurePosixPath(p.relative_to(ROOT)))
print("archive saved to", zip_path)