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

Function _registry_path

openkb/converter.py:36–47  ·  view source on GitHub ↗

Portable path string used as the registry's identity key. Relative-to-KB posix when the file lives inside the KB (stable across machines/checkouts), absolute posix otherwise. Both paths are fully resolved (symlinks followed) before comparison.

(path: Path, kb_dir: Path)

Source from the content-addressed store, hash-verified

34
35
36def _registry_path(path: Path, kb_dir: Path) -> str:
37 """Portable path string used as the registry's identity key.
38
39 Relative-to-KB posix when the file lives inside the KB (stable across
40 machines/checkouts), absolute posix otherwise. Both paths are fully
41 resolved (symlinks followed) before comparison.
42 """
43 resolved_path = path.resolve()
44 resolved_kb = kb_dir.resolve()
45 if resolved_path.is_relative_to(resolved_kb):
46 return resolved_path.relative_to(resolved_kb).as_posix()
47 return resolved_path.as_posix()
48
49
50_SAFE_STEM_RE = re.compile(r"[^\w\-]+")

Calls

no outgoing calls