MCPcopy Create free account
hub / github.com/VectifyAI/OpenKB / get_by_path

Method get_by_path

openkb/state.py:38–53  ·  view source on GitHub ↗

Return metadata whose path/raw_path/source_path equals ``path``. ``path`` is a registry path string (posix, relative to the KB dir when inside it) as produced by ``converter._registry_path``. Entries written before the path index existed carry none of these fields and

(self, path: str)

Source from the content-addressed store, hash-verified

36 return dict(self._data)
37
38 def get_by_path(self, path: str) -> dict | None:
39 """Return metadata whose path/raw_path/source_path equals ``path``.
40
41 ``path`` is a registry path string (posix, relative to the KB dir
42 when inside it) as produced by ``converter._registry_path``. Entries
43 written before the path index existed carry none of these fields and
44 never match.
45 """
46 for metadata in self._data.values():
47 if path in (
48 metadata.get("path"),
49 metadata.get("raw_path"),
50 metadata.get("source_path"),
51 ):
52 return metadata
53 return None
54
55 def find_legacy_by_stem(self, stem: str) -> tuple[str, dict] | None:
56 """Find a pre-path-index entry matching ``stem``.

Calls 1

getMethod · 0.45