master
Colby Knox 1.0.62: standard aliases for 16 of the 1.0.61 verbs, the standard-decision test, battery coverage for all 78 new verbs,… fabfdcd 14d ago
#!/usr/bin/env python3
"""Snapshot the EDA Bridge Standard's verb names into rust/crates/kicad-bridge/src/standard_names.txt.

The catalog test `every_verb_has_a_standard_decision` (catalog.rs) reads it: every kicad_* verb must be a
standard name, an alias in catalog::ALIASES, or listed in kicad_only.txt beside it (a job the standard does
not have, reviewed). Refresh it when the standard changes:

  python3 tools/sync_standard_names.py              # clones adom/eda-bridge-standard into a temp dir
  python3 tools/sync_standard_names.py <clone-dir>  # or reads an existing clone
"""
import json, os, subprocess, sys, tempfile
from pathlib import Path

ROOT = Path(__file__).resolve().parent.parent
OUT = ROOT / "rust/crates/kicad-bridge/src/standard_names.txt"

def main():
    src = Path(sys.argv[1]) if len(sys.argv) > 1 else None
    if src is None:
        src = Path(tempfile.mkdtemp(prefix="eda-std-")) / "std"
        subprocess.run(["adom-wiki", "repo", "clone", "adom/eda-bridge-standard", "--dir", str(src)], check=True, capture_output=True)
    d = json.loads((src / "verbs/standard.json").read_text())
    names = sorted(v["name"] for v in d["verbs"])
    head = (f"# The EDA Bridge Standard's verb names (adom/eda-bridge-standard verbs/standard.json, reference "
            f"{d['reference']['bridge']} {d['reference']['version']}). Generated by tools/sync_standard_names.py; do not edit.\n")
    OUT.write_text(head + "\n".join(names) + "\n")
    print(f"{len(names)} standard names -> {OUT.relative_to(ROOT)}")

if __name__ == "__main__":
    main()