mirror of
https://github.com/ION606/COGMOD-HWI.git
synced 2026-05-14 22:16:57 +00:00
20 lines
621 B
Python
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)
|