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

Function _file_stem

graphify/extractors/base.py:39–62  ·  view source on GitHub ↗

Stem used as the node-ID prefix for a file and its symbols. The full path (extension dropped) is preserved as path segments; ``make_id`` later collapses the separators to underscores. Using every segment — not just the immediate parent dir (#1504) — means same-named files in different

(path: Path)

Source from the content-addressed store, hash-verified

37
38
39def _file_stem(path: Path) -> str:
40 """Stem used as the node-ID prefix for a file and its symbols.
41
42 The full path (extension dropped) is preserved as path segments; ``make_id``
43 later collapses the separators to underscores. Using every segment — not just
44 the immediate parent dir (#1504) — means same-named files in different
45 directories get distinct IDs instead of colliding into one
46 last-writer-wins node:
47
48 docs/v1/api/README.md -> docs/v1/api/README -> docs_v1_api_readme
49 docs/v2/api/README.md -> docs/v2/api/README -> docs_v2_api_readme
50
51 Top-level files keep a bare stem (``setup.py`` -> ``setup``). When passed an
52 absolute path the whole path is encoded; the extract() id-remap post-pass
53 re-derives the canonical repo-relative form from ``source_file`` so the on-disk
54 location can't leak into the persisted IDs (#502).
55
56 Returns "" for a path with no name (``Path('.')`` — a source_file that equals
57 the scan root, so it has no per-file stem). Guarding here keeps
58 ``path.with_suffix("")`` from raising ``ValueError: '.' has an empty name`` and
59 protects every caller, not just ``_semantic_id_remap`` (#1618)."""
60 if not path.name:
61 return ""
62 return path.with_suffix("").as_posix()
63
64
65def _read_text(node, source: bytes) -> str:

Callers 15

_semantic_id_remapFunction · 0.90
graph_has_legacy_idsFunction · 0.90
extract_mcp_configFunction · 0.90
_file_node_idFunction · 0.90
_import_jsFunction · 0.90
_require_imports_jsFunction · 0.90
_extract_genericFunction · 0.90
_extract_js_rationaleFunction · 0.90
_extract_spock_fallbackFunction · 0.90
extract_apexFunction · 0.90
extract_dartFunction · 0.90

Calls

no outgoing calls