(
root: Path,
*,
max_depth: int,
include_hidden: bool,
follow_symlinks: bool,
ignore: List[str],
)
| 676 | |
| 677 | # ------------------ Empty folders ------------------ |
| 678 | def find_empty_folders( |
| 679 | root: Path, |
| 680 | *, |
| 681 | max_depth: int, |
| 682 | include_hidden: bool, |
| 683 | follow_symlinks: bool, |
| 684 | ignore: List[str], |
| 685 | ) -> List[Path]: |
| 686 | empties: List[Path] = [] |
| 687 | for p in iter_paths(root, max_depth=max_depth, include_hidden=include_hidden, follow_symlinks=follow_symlinks, ignore=ignore): |
| 688 | if not p.is_dir(): |
| 689 | continue |
| 690 | try: |
| 691 | has_any = False |
| 692 | with os.scandir(p) as it: |
| 693 | for de in it: |
| 694 | if de.name in (".", ".."): |
| 695 | continue |
| 696 | if not include_hidden and de.name.startswith("."): |
| 697 | continue |
| 698 | if match_any(p / de.name, de.name, ignore): |
| 699 | continue |
| 700 | has_any = True |
| 701 | break |
| 702 | if not has_any: |
| 703 | empties.append(p) |
| 704 | except OSError: |
| 705 | continue |
| 706 | return empties |
| 707 | |
| 708 | |
| 709 | # ------------------ Duplicate files (hash) ------------------ |
no test coverage detected