MCPcopy Create free account
hub / github.com/Graphify-Labs/graphify / main

Function main

scripts/theme_gate.py:618–658  ·  view source on GitHub ↗

CLI entry point; returns the process exit code (0 ok, 1 miss, 2 bad input).

(argv: list[str] | None = None)

Source from the content-addressed store, hash-verified

616
617
618def main(argv: list[str] | None = None) -> int:
619 """CLI entry point; returns the process exit code (0 ok, 1 miss, 2 bad input)."""
620 ap = argparse.ArgumentParser(description="Check graph.json covers every active grep case of a theme.")
621 ap.add_argument("themes", nargs="+", help="theme root(s) containing graphify-out/graph.json")
622 ap.add_argument("--categories", default=",".join(CATEGORIES), help="comma list drawn from a,b,c,d,e,f")
623 ap.add_argument("--max-failures", type=int, default=5, help="failures listed per category")
624 ap.add_argument("--json", action="store_true", help="emit JSON {theme: {category: {covered,total,failures,warnings}}}")
625 try:
626 args = ap.parse_args(argv)
627 except SystemExit:
628 return 2
629 cats = [c.strip() for c in args.categories.split(",") if c.strip()]
630 if not cats or any(c not in tuple(CATEGORIES) for c in cats) or args.max_failures < 0:
631 print("invalid --categories / --max-failures", file=sys.stderr)
632 return 2
633 report: dict[str, dict] = {}
634 worst = 0
635 for t in args.themes:
636 root = Path(t)
637 gpath = root / "graphify-out" / "graph.json"
638 try:
639 graph = Graph(gpath, root)
640 except (OSError, ValueError, KeyError) as exc:
641 print(f"cannot read {gpath}: {exc}", file=sys.stderr)
642 return 2
643 res = measure(root, graph, "".join(cats))
644 report[root.name] = res
645 if any(r["covered"] < r["total"] for r in res.values()):
646 worst = 1
647 if args.json:
648 json.dump(report, sys.stdout, indent=1)
649 print()
650 else:
651 for theme, res in report.items():
652 print(f"== {theme}")
653 for cat, r in res.items():
654 w = f" (+{len(r['warnings'])} warnings)" if r["warnings"] else ""
655 print(f" ({cat}) {_pct(r)}{w}")
656 for f, ln, key in r["failures"][: args.max_failures]:
657 print(f" {f}:{ln} {key}")
658 return worst
659
660
661if __name__ == "__main__":

Callers 1

theme_gate.pyFile · 0.70

Calls 5

measureFunction · 0.85
_pctFunction · 0.85
GraphClass · 0.70
joinMethod · 0.45
itemsMethod · 0.45

Tested by

no test coverage detected