53 lines
1.9 KiB
Python
53 lines
1.9 KiB
Python
#!/usr/bin/env python3
|
|
"""Build the wizards roster extract from the live checkins/ directory.
|
|
|
|
Ground truth: every checkin file named checkins/2026-10-2N-<wizard>.md. The CSV
|
|
is the machine-readable table; a peer CHECK script re-derives identical bytes.
|
|
"""
|
|
import hashlib
|
|
import re
|
|
import csv
|
|
from pathlib import Path
|
|
|
|
ROOT = Path("/root/troupe-standup")
|
|
CHECKINS = ROOT / "checkins"
|
|
OUT = ROOT / "wizard-work" / "ledger"
|
|
|
|
|
|
def parse(path):
|
|
name = path.stem # 2026-10-25-volt (11-char stem)
|
|
date = name[:10] # 2026-10-25
|
|
wizard = name[11:] # volt
|
|
text = path.read_text(encoding="utf-8")
|
|
header = text.splitlines()[0] if text else ""
|
|
title = header.lstrip("#").strip() or wizard
|
|
|
|
counts = {f: len(re.findall(r"^\s*\*\*(" + f + r")\s*:\s*$", text, re.M | re.I))
|
|
for f in ("did", "blocked", "next", "ask")}
|
|
counts["total_lines"] = len(text.splitlines())
|
|
return {"wizard": wizard, "date": date, "title": title,
|
|
**counts, "body_sha256": hashlib.sha256(text.encode()).hexdigest()}
|
|
|
|
|
|
def main():
|
|
rows = []
|
|
for p in sorted(CHECKINS.glob("2026-10-2*.md")):
|
|
rows.append(parse(p))
|
|
rows.sort(key=lambda r: (r["date"], r["wizard"]))
|
|
|
|
OUT.mkdir(parents=True, exist_ok=True)
|
|
csv_path = OUT / "wizards-roster-2026-10-25.csv"
|
|
with csv_path.open("w", encoding="utf-8", newline="") as fh:
|
|
w = csv.writer(fh)
|
|
w.writerow(["wizard", "date", "title", "did", "blocked", "next", "ask",
|
|
"total_lines", "body_sha256"])
|
|
for r in rows:
|
|
w.writerow([r["wizard"], r["date"], r["title"], r["did"],
|
|
r["blocked"], r["next"], r["ask"], r["total_lines"],
|
|
r["body_sha256"]])
|
|
print("wrote %s with %d rows" % (csv_path, len(rows)))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|