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

Function run_trash_pattern

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

Source from the content-addressed store, hash-verified

1474 print(t("dupes_none", lang))
1475 return
1476 out = format_dupes(lang, dupes)
1477 print(out)
1478 export_path = prompt_text(lang, "prompt_export", "")
1479 export_text(lang, export_path, out)
1480
1481def run_trash_pattern(lang: str) -> None:
1482 print(t("trash_title", lang))
1483 root = prompt_path(lang, Path("."))
1484 if not root.exists():
1485 print(t("err_path_missing", lang, path=root))
1486 return
1487 pattern = input(t("trash_pattern", lang)).strip()
1488 if not pattern:
1489 return
1490 depth = prompt_int(lang, 12)
1491 hide_dot = yesno(lang, "prompt_hide_dot", False)
1492 include_hidden = not hide_dot
1493 follow = yesno(lang, "prompt_follow", False)
1494 ignore = normalize_patterns(prompt_text(lang, "prompt_ignore", ""))
1495
1496 items = collect_matching_items(root, pattern=pattern, max_depth=depth, include_hidden=include_hidden, follow_symlinks=follow, ignore=ignore)
1497 trash_dir_preview = (root if root.is_dir() else root.parent) / ".TreeExplorerTrash"
1498 print(t("trash_confirm_msg", lang, trash=trash_dir_preview))
1499 print(t("trash_found", lang, n=len(items)))
1500 if not items:
1501 print(t("trash_none", lang))
1502 return
1503
1504 preview = "\n".join(f" - {p}" for p in items[:20])
1505 print(preview + ("\n..." if len(items) > 20 else ""))
1506
1507 confirm = input(t("prompt_confirm", lang)).strip()
1508 if confirm != "YES":
1509 return
1510
1511 moved, skipped, _trash_dir = move_to_trash(root, items)
1512 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
collect_matching_itemsFunction · 0.70
move_to_trashFunction · 0.70

Tested by

no test coverage detected