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",
)
| 263 | |
| 264 | |
| 265 | def 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 |
no test coverage detected