MCPcopy Index your code
hub / github.com/RustPython/RustPython / _count_path_diff

Function _count_path_diff

scripts/update_lib/deps.py:1103–1122  ·  view source on GitHub ↗

Count changed lines between two paths (file or directory, *.py only).

(path_a: pathlib.Path, path_b: pathlib.Path)

Source from the content-addressed store, hash-verified

1101
1102
1103def _count_path_diff(path_a: pathlib.Path, path_b: pathlib.Path) -> int:
1104 """Count changed lines between two paths (file or directory, *.py only)."""
1105 if path_a.is_file() and path_b.is_file():
1106 return _count_file_diff(path_a, path_b)
1107 if path_a.is_dir() and path_b.is_dir():
1108 total = 0
1109 a_files = {f.relative_to(path_a) for f in path_a.rglob("*.py")}
1110 b_files = {f.relative_to(path_b) for f in path_b.rglob("*.py")}
1111 for rel in a_files & b_files:
1112 total += _count_file_diff(path_a / rel, path_b / rel)
1113 for rel in a_files - b_files:
1114 content = safe_read_text(path_a / rel)
1115 if content:
1116 total += len(content.splitlines())
1117 for rel in b_files - a_files:
1118 content = safe_read_text(path_b / rel)
1119 if content:
1120 total += len(content.splitlines())
1121 return total
1122 return 0
1123
1124
1125@functools.cache

Callers 1

get_module_diff_statFunction · 0.85

Calls 8

safe_read_textFunction · 0.90
_count_file_diffFunction · 0.85
lenFunction · 0.85
is_fileMethod · 0.45
is_dirMethod · 0.45
relative_toMethod · 0.45
rglobMethod · 0.45
splitlinesMethod · 0.45

Tested by

no test coverage detected