29 lines
1.0 KiB
Python
29 lines
1.0 KiB
Python
#!/usr/bin/env python3
|
|
"""Clean, self-contained manifest generator (tab-delimited; no CSV quoting issues)."""
|
|
import os
|
|
from collections import defaultdict
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(os.environ.get("WIZARDWORK_ROOT", "/root/troupe-standup/wizard-work"))
|
|
OUT = Path(os.environ.get("WIZARDWORK_OUT", "/root/troupe-standup/wizard-work/ledger"))
|
|
MANIFEST = OUT / "wizardwork-file-manifest.tsv" # tab-delimited manifest
|
|
|
|
def build():
|
|
rows = []
|
|
for top in sorted(ROOT.iterdir()):
|
|
if not top.is_dir():
|
|
continue
|
|
for dirpath, _dirnames, filenames in os.walk(top):
|
|
for fn in filenames:
|
|
p = Path(dirpath) / fn
|
|
rel = p.relative_to(ROOT)
|
|
rows.append((rel.as_posix(), p.stat().st_size, fn, top.name))
|
|
rows.sort()
|
|
with open(MANIFEST, "w") as f:
|
|
for rel, size, fn, top in rows:
|
|
f.write(f"{rel}\t{size}\t{fn}\t{top}\n")
|
|
print("manifest written:", MANIFEST, "rows:", len(rows))
|
|
|
|
if __name__ == "__main__":
|
|
build()
|