← Commit history

Delete design/gen/sch_compare.py

John Lauer ·58f7852d93 ·7d ago ·parent 203d5ab
1 file changed −21
design/gen/sch_compare.pydeleted−21
@@ -1,21 +0,0 @@-#!/usr/bin/env python3-"""Compare a KiCad-exported schematic netlist (kicadsexpr) with design/netlist.json, pin by pin."""-import re, json, sys, os-ROOT = os.path.join(os.path.dirname(__file__), "..")-t = open(sys.argv[1] if len(sys.argv) > 1 else os.path.join(ROOT, "kicad", "sch.net")).read()-t = re.sub(r"\s+", " ", t)-sch = {}-for b in t.split("(net (code")[1:]:-    name = re.search(r'\(name "([^"]*)"\)', b).group(1).lstrip("/")-    nodes = re.findall(r'\(node \(ref "([^"]+)"\) \(pin "([^"]+)"\)', b)-    if name.startswith(("unconnected", "Net-(")):-        continue-    sch[name] = sorted(f"{r}.{p}" for r, p in nodes)-want = {k: sorted(v) for k, v in json.load(open(os.path.join(ROOT, "design", "netlist.json")))["nets"].items()}-ps = {p: n for n, l in sch.items() for p in l}-pw = {p: n for n, l in want.items() for p in l}-diff = sorted((p, pw.get(p), ps.get(p)) for p in set(ps) | set(pw) if pw.get(p) != ps.get(p))-print(f"schematic nets {len(sch)}, netlist.json nets {len(want)}, connected pins {len(pw)}, mismatches {len(diff)}")-for d in diff[:30]:-    print("  ", d)-sys.exit(1 if diff else 0)