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

Function run_remove_empty

Scripts/Developer Base/Tree Explorer.py:1596–1627  ·  view source on GitHub ↗
(lang: str)

Source from the content-addressed store, hash-verified

1594 return
1595
1596 moved, skipped, _trash_dir = move_to_trash(root, to_trash)
1597 print(t("trash_done", lang, n=moved))
1598 if skipped:
1599 print(t("trash_skip", lang, n=skipped))
1600
1601def run_remove_empty(lang: str) -> None:
1602 print(t("remove_empty_title", lang))
1603 root = prompt_path(lang, Path("."))
1604 if not root.exists():
1605 print(t("err_path_missing", lang, path=root))
1606 return
1607 depth = prompt_int(lang, 12)
1608 hide_dot = yesno(lang, "prompt_hide_dot", False)
1609 include_hidden = not hide_dot
1610 follow = yesno(lang, "prompt_follow", False)
1611 ignore = normalize_patterns(prompt_text(lang, "prompt_ignore", ""))
1612
1613 empties = find_empty_folders(root, max_depth=depth, include_hidden=include_hidden, follow_symlinks=follow, ignore=ignore)
1614 # never move root itself
1615 empties = [p for p in empties if p != root]
1616 print(t("empty_found", lang, n=len(empties)))
1617 if not empties:
1618 return
1619
1620 preview = "\n".join(f" - {p}" for p in empties[:20])
1621 print(preview + ("\n..." if len(empties) > 20 else ""))
1622
1623 trash_dir_preview = (root if root.is_dir() else root.parent) / ".TreeExplorerTrash"
1624 print(t("trash_confirm_msg", lang, trash=trash_dir_preview))
1625 confirm = input(t("prompt_confirm", lang)).strip()
1626 if confirm != "YES":
1627 return
1628
1629 moved, skipped, _trash_dir = move_to_trash(root, empties)
1630 print(t("trash_done", lang, n=moved))

Callers 1

menu_loopFunction · 0.70

Calls 10

printFunction · 0.85
inputFunction · 0.85
tFunction · 0.70
prompt_pathFunction · 0.70
prompt_intFunction · 0.70
yesnoFunction · 0.70
normalize_patternsFunction · 0.70
prompt_textFunction · 0.70
find_empty_foldersFunction · 0.70
move_to_trashFunction · 0.70

Tested by

no test coverage detected