Walk *paths* and return all .py files, filtering out *excludes*.
(
paths: list[str],
excludes: list[str],
)
| 247 | |
| 248 | |
| 249 | def collect_python_files( |
| 250 | paths: list[str], |
| 251 | excludes: list[str], |
| 252 | ) -> list[Path]: |
| 253 | """Walk *paths* and return all .py files, filtering out *excludes*.""" |
| 254 | result: list[Path] = [] |
| 255 | exclude_parts = [e.replace("\\", "/").strip("/") for e in excludes] |
| 256 | |
| 257 | for p_str in paths: |
| 258 | p = Path(p_str) |
| 259 | if p.is_file() and p.suffix == ".py": |
| 260 | if not _is_excluded(p, exclude_parts): |
| 261 | result.append(p) |
| 262 | elif p.is_dir(): |
| 263 | for py_file in p.rglob("*.py"): |
| 264 | if not _is_excluded(py_file, exclude_parts): |
| 265 | result.append(py_file) |
| 266 | return result |
| 267 | |
| 268 | |
| 269 | def _is_excluded(path: Path, exclude_parts: list[str]) -> bool: |
no test coverage detected