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

Function _declared_external_modules

graphify/extract.py:5437–5457  ·  view source on GitHub ↗
(source_path: Path)

Source from the content-addressed store, hash-verified

5435 declared_modules_by_file: dict[Path, set[str]] = {}
5436
5437 def _declared_external_modules(source_path: Path) -> set[str]:
5438 source_path = source_path.resolve()
5439 if source_path in declared_modules_by_file:
5440 return declared_modules_by_file[source_path]
5441 try:
5442 import tree_sitter_rust as tsrust
5443 from tree_sitter import Language, Parser
5444
5445 source = source_path.read_bytes()
5446 tree = Parser(Language(tsrust.language())).parse(source)
5447 except Exception:
5448 declared_modules_by_file[source_path] = set()
5449 return declared_modules_by_file[source_path]
5450 declared_modules_by_file[source_path] = {
5451 _read_text(name, source)
5452 for child in tree.root_node.named_children
5453 if child.type == "mod_item"
5454 and child.child_by_field_name("body") is None
5455 and (name := child.child_by_field_name("name")) is not None
5456 }
5457 return declared_modules_by_file[source_path]
5458
5459 def _module_nodes_from(
5460 base: Path, modules: list[str], parent_file: Path | None,

Callers 3

_module_nodes_fromFunction · 0.85

Calls 2

_read_textFunction · 0.90
resolveMethod · 0.45

Tested by

no test coverage detected