#!/usr/bin/env python3 """Refresh the root README's pass status from the tier's own audit. The root README's inventory and summary tables say how far each project got. `_tools/audit_promoted.py` knows whether a project meets every item of `PROMPTS.md`'s promotion checklist, so the status column is derived from it rather than kept by hand. Only the pass wording changes: the coverage figure, the vectors and the promotion dates are left as they are. Usage: python3 _tools/refresh_readme_status.py [--write] """ import argparse import importlib.util import re import sys from pathlib import Path ROOT = Path(__file__).resolve().parent.parent def load_audit(): spec = importlib.util.spec_from_file_location( "audit_promoted", ROOT / "_tools" / "audit_promoted.py") m = importlib.util.module_from_spec(spec) spec.loader.exec_module(m) return m def main(): ap = argparse.ArgumentParser(description=__doc__.splitlines()[0]) ap.add_argument("--write", action="store_true") args = ap.parse_args() audit = load_audit() projects = [] for base in ("NROM", "CNROM", "UNROM", "MAPPER8"): for d in sorted((ROOT / base).iterdir()): if d.is_dir() and (d / "prg.s").is_file(): projects.append(f"{base}/{d.name}") ok = set() for p in projects: res = audit.audit(p, build=False) res.pop("5b", None) # the informational entry-point count if not res: ok.add(p.split("/", 1)[1]) readme = ROOT / "README.md" lines = readme.read_text().split("\n") out, changed = [], 0 for line in lines: m = re.match(r"^\| (\d+) \| (.+?) \| (.*)$", line) if m and m.group(2).strip() in ok and "partial" in line: new = line.replace("Pass 3 partial", "Pass 3 complete") new = new.replace("Pass 2/3 partial", "Pass 2/3 complete") if new != line: changed += 1 line = new out.append(line) print(f"{changed} row(s) updated; {len(ok)} project(s) pass the checklist") if args.write: readme.write_text("\n".join(out)) print("written") if __name__ == "__main__": sys.exit(main())