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

Function _count_file_diff

scripts/update_lib/deps.py:1084–1100  ·  view source on GitHub ↗

Count changed lines between two text files using difflib.

(file_a: pathlib.Path, file_b: pathlib.Path)

Source from the content-addressed store, hash-verified

1082
1083
1084def _count_file_diff(file_a: pathlib.Path, file_b: pathlib.Path) -> int:
1085 """Count changed lines between two text files using difflib."""
1086 a_content = safe_read_text(file_a)
1087 b_content = safe_read_text(file_b)
1088 if a_content is None or b_content is None:
1089 return 0
1090 if a_content == b_content:
1091 return 0
1092 a_lines = a_content.splitlines()
1093 b_lines = b_content.splitlines()
1094 count = 0
1095 for line in difflib.unified_diff(a_lines, b_lines, lineterm=""):
1096 if (line.startswith("+") and not line.startswith("+++")) or (
1097 line.startswith("-") and not line.startswith("---")
1098 ):
1099 count += 1
1100 return count
1101
1102
1103def _count_path_diff(path_a: pathlib.Path, path_b: pathlib.Path) -> int:

Callers 1

_count_path_diffFunction · 0.85

Calls 3

safe_read_textFunction · 0.90
splitlinesMethod · 0.45
startswithMethod · 0.45

Tested by

no test coverage detected