clutterxp 1.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. clutterxp/__init__.py +4 -0
  2. clutterxp/cli/__init__.py +7 -0
  3. clutterxp/cli/app.py +251 -0
  4. clutterxp/cli/cmd_config.py +250 -0
  5. clutterxp/cli/cmd_doctor.py +449 -0
  6. clutterxp/cli/cmd_duplicates.py +253 -0
  7. clutterxp/cli/cmd_gui.py +22 -0
  8. clutterxp/cli/cmd_history.py +233 -0
  9. clutterxp/cli/cmd_init.py +76 -0
  10. clutterxp/cli/cmd_organize.py +226 -0
  11. clutterxp/cli/cmd_rules.py +540 -0
  12. clutterxp/cli/cmd_scan.py +109 -0
  13. clutterxp/cli/cmd_service.py +130 -0
  14. clutterxp/cli/cmd_undo.py +180 -0
  15. clutterxp/cli/cmd_watch.py +147 -0
  16. clutterxp/cli/errors.py +166 -0
  17. clutterxp/cli/render.py +390 -0
  18. clutterxp/config/__init__.py +40 -0
  19. clutterxp/config/jsonschema.py +12 -0
  20. clutterxp/config/loader.py +212 -0
  21. clutterxp/config/placeholders.py +79 -0
  22. clutterxp/config/runtime.py +30 -0
  23. clutterxp/config/schema.py +166 -0
  24. clutterxp/config/validate.py +226 -0
  25. clutterxp/config/writer.py +248 -0
  26. clutterxp/config.example.yaml +76 -0
  27. clutterxp/duplicates/__init__.py +22 -0
  28. clutterxp/duplicates/detector.py +438 -0
  29. clutterxp/duplicates/hashcache.py +149 -0
  30. clutterxp/duplicates/namenorm.py +45 -0
  31. clutterxp/duplicates/quarantine.py +196 -0
  32. clutterxp/duplicates/report.py +110 -0
  33. clutterxp/gui/__init__.py +1 -0
  34. clutterxp/gui/api.py +494 -0
  35. clutterxp/gui/app.py +205 -0
  36. clutterxp/gui/models_qt.py +544 -0
  37. clutterxp/gui/views/__init__.py +21 -0
  38. clutterxp/gui/views/dashboard.py +253 -0
  39. clutterxp/gui/views/duplicates.py +404 -0
  40. clutterxp/gui/views/folders.py +354 -0
  41. clutterxp/gui/views/history.py +281 -0
  42. clutterxp/gui/views/preview.py +277 -0
  43. clutterxp/gui/views/rules.py +527 -0
  44. clutterxp/gui/views/settings.py +172 -0
  45. clutterxp/gui/workers.py +147 -0
  46. clutterxp/history/__init__.py +23 -0
  47. clutterxp/history/db.py +174 -0
  48. clutterxp/history/pathcodec.py +42 -0
  49. clutterxp/history/recovery.py +318 -0
  50. clutterxp/history/schema.sql +43 -0
  51. clutterxp/history/service.py +493 -0
  52. clutterxp/history/undo.py +373 -0
  53. clutterxp/interfaces.py +164 -0
  54. clutterxp/locking.py +113 -0
  55. clutterxp/logging_setup.py +73 -0
  56. clutterxp/models.py +266 -0
  57. clutterxp/mover/__init__.py +26 -0
  58. clutterxp/mover/collision.py +46 -0
  59. clutterxp/mover/fsops.py +191 -0
  60. clutterxp/mover/safe_move.py +741 -0
  61. clutterxp/organizer.py +388 -0
  62. clutterxp/packaging/clutterxp.service +15 -0
  63. clutterxp/paths.py +112 -0
  64. clutterxp/planner.py +339 -0
  65. clutterxp/py.typed +0 -0
  66. clutterxp/rules/__init__.py +16 -0
  67. clutterxp/rules/engine.py +374 -0
  68. clutterxp/rules/matcher.py +222 -0
  69. clutterxp/rules/template.py +171 -0
  70. clutterxp/rules/tokenizer.py +118 -0
  71. clutterxp/safety.py +111 -0
  72. clutterxp/scanner.py +196 -0
  73. clutterxp/service_install.py +208 -0
  74. clutterxp/units.py +59 -0
  75. clutterxp/watch/__init__.py +37 -0
  76. clutterxp/watch/debounce.py +84 -0
  77. clutterxp/watch/events.py +259 -0
  78. clutterxp/watch/ignore.py +77 -0
  79. clutterxp/watch/service.py +662 -0
  80. clutterxp/watch/settle.py +170 -0
  81. clutterxp-1.1.0.dist-info/METADATA +149 -0
  82. clutterxp-1.1.0.dist-info/RECORD +84 -0
  83. clutterxp-1.1.0.dist-info/WHEEL +4 -0
  84. clutterxp-1.1.0.dist-info/entry_points.txt +6 -0
@@ -0,0 +1,77 @@
1
+ """Ignore pattern matching for watch service (built-ins, hidden files, user globs)."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import fnmatch
6
+ from collections.abc import Sequence
7
+ from pathlib import Path
8
+
9
+ BUILTIN_IGNORE: tuple[str, ...] = (
10
+ "*.crdownload",
11
+ "*.part",
12
+ "*.partial",
13
+ "*.tmp",
14
+ "*.temp",
15
+ "*.download",
16
+ "*.opdownload",
17
+ "*.!qB",
18
+ "*.aria2",
19
+ "*.swp",
20
+ "*.swx",
21
+ "*~",
22
+ "~$*",
23
+ ".~lock.*#",
24
+ "*.clutterxp-partial",
25
+ )
26
+
27
+
28
+ class IgnoreMatcher:
29
+ """Matches files against built-in and configured ignore patterns."""
30
+
31
+ def __init__(
32
+ self,
33
+ builtin: Sequence[str] = BUILTIN_IGNORE,
34
+ global_extra: Sequence[str] = (),
35
+ folder_extra: Sequence[str] = (),
36
+ skip_hidden: bool = True,
37
+ ) -> None:
38
+ self.builtin = tuple(builtin)
39
+ self.global_extra = tuple(global_extra)
40
+ self.folder_extra = tuple(folder_extra)
41
+ self.skip_hidden = skip_hidden
42
+ self._patterns = tuple(
43
+ p.casefold() for p in (*self.builtin, *self.global_extra, *self.folder_extra)
44
+ )
45
+
46
+ def matches(self, path: Path) -> bool:
47
+ """Return True if path should be ignored."""
48
+ name = path.name
49
+ if not name:
50
+ return True
51
+
52
+ # ClutterXP's internal partial transfer files are always ignored
53
+ name_cf = name.casefold()
54
+ if name_cf.endswith(".clutterxp-partial"):
55
+ return True
56
+
57
+ # Skip hidden files or files within hidden directories
58
+ if self.skip_hidden:
59
+ for part in path.parts:
60
+ if part.startswith(".") and part not in (".", ".."):
61
+ return True
62
+
63
+ # Casefolded fnmatch matching on path.name
64
+ for pattern in self._patterns:
65
+ if fnmatch.fnmatchcase(name_cf, pattern):
66
+ return True
67
+ if "/" in pattern:
68
+ posix_path = path.as_posix().casefold()
69
+ if fnmatch.fnmatchcase(posix_path, pattern) or fnmatch.fnmatchcase(
70
+ posix_path, f"*/{pattern.lstrip('/')}"
71
+ ):
72
+ return True
73
+
74
+ return False
75
+
76
+
77
+ __all__ = ["BUILTIN_IGNORE", "IgnoreMatcher"]