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

Function _normalized

graphify/cache.py:2172–2188  ·  view source on GitHub ↗

Copy of ``item`` with a portable ``source_file`` (#2197). Normalizing BEFORE grouping means both the group key and the persisted item carry the relative forward-slash form, so a fragment whose source_file arrived absolute (Windows detect() output) can never be cached

(item: dict)

Source from the content-addressed store, hash-verified

2170 source_path, _normalize_value = _semantic_source_matcher(root)
2171
2172 def _normalized(item: dict) -> dict:
2173 """Copy of ``item`` with a portable ``source_file`` (#2197).
2174
2175 Normalizing BEFORE grouping means both the group key and the persisted
2176 item carry the relative forward-slash form, so a fragment whose
2177 source_file arrived absolute (Windows detect() output) can never be
2178 cached verbatim. A shallow copy keeps the caller's dicts untouched —
2179 downstream steps may still rely on the original absolute shape (same
2180 reasoning as :func:`save_cached`'s on-disk copy-on-write transform).
2181 """
2182 src = item.get("source_file")
2183 if not src:
2184 return item
2185 norm = _normalize_value(src)
2186 if norm != src:
2187 item = {**item, "source_file": norm}
2188 return item
2189
2190 by_file: dict[str, dict] = defaultdict(lambda: {"nodes": [], "edges": [], "hyperedges": []})
2191 owner_by_id: dict[str, str | None] = {}

Callers 1

save_semantic_cacheFunction · 0.85

Calls 1

getMethod · 0.45

Tested by

no test coverage detected