Files
Kill_LIFE/ai-agentic-embedded-base/tools/hw/blocks/generate_registry.py
T
Clément SAILLANT dda793c0ef feat(hw): add schops tool for schematic operations and kicad-cli integration
- Introduced `kicad_cli.sh` for local and Docker-based kicad-cli execution.
- Created `schops.py` for schematic operations including ERC, BOM, netlist exports, and bulk edits.
- Added README.md for schops with installation and usage instructions.
- Included requirements.txt for necessary Python packages.
- Implemented rules engine for applying field defaults and renaming nets.
- Added tests for rules engine functionality.
- Introduced scope guard script to enforce file modification policies based on PR labels.
- Created watch script to monitor KiCad files and trigger hardware gate on changes.
2026-02-19 00:00:33 +01:00

53 lines
1.5 KiB
Python

#!/usr/bin/env python3
import argparse, json
from pathlib import Path
def main():
ap = argparse.ArgumentParser()
ap.add_argument("--blocks-dir", default="hardware/blocks")
ap.add_argument("--out", default="hardware/blocks/REGISTRY.md")
args = ap.parse_args()
root = Path(args.blocks_dir)
out = Path(args.out)
out.parent.mkdir(parents=True, exist_ok=True)
blocks = []
for b in sorted(root.rglob("*.kicad_block")):
sch = next(b.glob("*.kicad_sch"), None)
meta = next(b.glob("*.json"), None)
meta_obj = {}
if meta and meta.exists():
try:
meta_obj = json.loads(meta.read_text(encoding="utf-8"))
except Exception:
meta_obj = {}
blocks.append({
"path": str(b),
"name": b.stem,
"schematic": str(sch) if sch else "",
"meta": meta_obj
})
lines = ["# Design Blocks registry", ""]
lines.append(f"- Total: **{len(blocks)}**")
lines.append("")
for blk in blocks:
lines.append(f"## {blk['name']}")
lines.append(f"- Path: `{blk['path']}`")
if blk["schematic"]:
lines.append(f"- Schematic: `{blk['schematic']}`")
desc = blk["meta"].get("description","")
if desc:
lines.append(f"- Description: {desc}")
kws = blk["meta"].get("keywords", [])
if kws:
lines.append(f"- Keywords: {', '.join(kws)}")
lines.append("")
out.write_text("\n".join(lines), encoding="utf-8")
print(str(out))
return 0
if __name__ == "__main__":
raise SystemExit(main())