MCPcopy
hub / github.com/tirth8205/code-review-graph / _parse_single_file

Function _parse_single_file

code_review_graph/incremental.py:799–817  ·  view source on GitHub ↗

Parse one file in a worker process. Returns ``(rel_path, nodes, edges, error_or_none, file_hash)``. Must be a module-level function so ``ProcessPoolExecutor`` can serialise it across processes.

(
    args: tuple[str, str],
)

Source from the content-addressed store, hash-verified

797
798
799def _parse_single_file(
800 args: tuple[str, str],
801) -> tuple[str, list, list, str | None, str]:
802 """Parse one file in a worker process.
803
804 Returns ``(rel_path, nodes, edges, error_or_none, file_hash)``.
805 Must be a module-level function so ``ProcessPoolExecutor`` can
806 serialise it across processes.
807 """
808 rel_path, repo_root_str = args
809 abs_path = Path(repo_root_str) / rel_path
810 try:
811 raw = abs_path.read_bytes()
812 fhash = hashlib.sha256(raw).hexdigest()
813 parser = CodeParser(Path(repo_root_str))
814 nodes, edges = parser.parse_bytes(abs_path, raw)
815 return (rel_path, nodes, edges, None, fhash)
816 except Exception as e:
817 return (rel_path, [], [], str(e), "")
818
819
820def full_build(

Callers 2

Calls 2

parse_bytesMethod · 0.95
CodeParserClass · 0.85

Tested by 2