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

Function compare_file_contents

scripts/update_lib/file_utils.py:245–262  ·  view source on GitHub ↗

Compare two files as text, optionally filtering local content.

(
    cpython_path: pathlib.Path,
    local_path: pathlib.Path,
    *,
    local_filter: Callable[[str], str] | None = None,
    encoding: str = "utf-8",
)

Source from the content-addressed store, hash-verified

243
244
245def compare_file_contents(
246 cpython_path: pathlib.Path,
247 local_path: pathlib.Path,
248 *,
249 local_filter: Callable[[str], str] | None = None,
250 encoding: str = "utf-8",
251) -> bool:
252 """Compare two files as text, optionally filtering local content."""
253 try:
254 cpython_content = cpython_path.read_text(encoding=encoding)
255 local_content = local_path.read_text(encoding=encoding)
256 except (OSError, UnicodeDecodeError):
257 return False
258
259 if local_filter is not None:
260 local_content = local_filter(local_content)
261
262 return cpython_content == local_content
263
264
265def compare_dir_contents(

Callers 2

is_test_up_to_dateFunction · 0.90
compare_dir_contentsFunction · 0.85

Calls 1

read_textMethod · 0.45

Tested by

no test coverage detected