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

Method __init__

scripts/theme_gate.py:142–158  ·  view source on GitHub ↗
(self, path: Path, root: Path)

Source from the content-addressed store, hash-verified

140 """Read-only view over graph.json, reimplemented here on purpose."""
141
142 def __init__(self, path: Path, root: Path) -> None:
143 data = json.loads(path.read_text(encoding="utf-8"))
144 self.root = root.resolve().as_posix().rstrip("/") + "/"
145 self.nodes: dict[str, dict] = {n["id"]: n for n in data.get("nodes", []) if "id" in n}
146 edges = data.get("links", data.get("edges", []))
147 self.edges_at: dict[tuple[str, int], list[dict]] = {}
148 self.out: dict[str, list[dict]] = {}
149 for e in edges:
150 src_file = self.rel(e.get("source_file"))
151 for ln in self._lines(e, src_file):
152 self.edges_at.setdefault((src_file, ln), []).append(e)
153 self.out.setdefault(e.get("source"), []).append(e)
154 self.nodes_at: dict[tuple[str, int], list[dict]] = {}
155 for n in self.nodes.values():
156 m = re.fullmatch(r"L(\d+)", str(n.get("source_location") or ""))
157 if m:
158 self.nodes_at.setdefault((self.rel(n.get("source_file")), int(m.group(1))), []).append(n)
159
160 def rel(self, f: object) -> str:
161 s = str(f or "").replace("\\", "/")

Callers

nothing calls this directly

Calls 4

relMethod · 0.95
_linesMethod · 0.95
resolveMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected