Shami96 commited on
Commit
d39e22c
·
verified ·
1 Parent(s): a84ea93

Create packager.py

Browse files
Files changed (1) hide show
  1. packager.py +16 -0
packager.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import shutil
3
+ from pathlib import Path
4
+
5
+ def write_text(text: str, path: Path):
6
+ with open(path, "w", encoding="utf-8") as f:
7
+ f.write(text)
8
+
9
+ def write_manifest(run_dir: Path, meta: dict):
10
+ with open(run_dir / "manifest.json", "w", encoding="utf-8") as f:
11
+ json.dump(meta, f, indent=2)
12
+
13
+ def make_zip(run_dir: Path) -> Path:
14
+ zip_path = run_dir.with_suffix("") # base name
15
+ shutil.make_archive(str(zip_path), "zip", str(run_dir))
16
+ return Path(str(zip_path) + ".zip")