MCPcopy Create free account
hub / github.com/dedsec1121fk/DedSec / find_empty_folders

Function find_empty_folders

Scripts/Developer Base/Tree Explorer.py:678–706  ·  view source on GitHub ↗
(
    root: Path,
    *,
    max_depth: int,
    include_hidden: bool,
    follow_symlinks: bool,
    ignore: List[str],
)

Source from the content-addressed store, hash-verified

676
677# ------------------ Empty folders ------------------
678def 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) ------------------

Callers 3

run_empty_dirsFunction · 0.70
run_remove_emptyFunction · 0.70
mainFunction · 0.70

Calls 2

iter_pathsFunction · 0.70
match_anyFunction · 0.70

Tested by

no test coverage detected