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

Function compare_dir_contents

scripts/update_lib/file_utils.py:265–289  ·  view source on GitHub ↗

Compare directory contents for matching files and text.

(
    cpython_dir: pathlib.Path,
    local_dir: pathlib.Path,
    *,
    pattern: str = "*.py",
    local_filter: Callable[[str], str] | None = None,
    encoding: str = "utf-8",
)

Source from the content-addressed store, hash-verified

263
264
265def compare_dir_contents(
266 cpython_dir: pathlib.Path,
267 local_dir: pathlib.Path,
268 *,
269 pattern: str = "*.py",
270 local_filter: Callable[[str], str] | None = None,
271 encoding: str = "utf-8",
272) -> bool:
273 """Compare directory contents for matching files and text."""
274 cpython_files = {f.relative_to(cpython_dir) for f in cpython_dir.rglob(pattern)}
275 local_files = {f.relative_to(local_dir) for f in local_dir.rglob(pattern)}
276
277 if cpython_files != local_files:
278 return False
279
280 for rel_path in cpython_files:
281 if not compare_file_contents(
282 cpython_dir / rel_path,
283 local_dir / rel_path,
284 local_filter=local_filter,
285 encoding=encoding,
286 ):
287 return False
288
289 return True

Callers 1

is_test_up_to_dateFunction · 0.90

Calls 3

compare_file_contentsFunction · 0.85
relative_toMethod · 0.45
rglobMethod · 0.45

Tested by

no test coverage detected