-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconstants.py
More file actions
184 lines (174 loc) · 6.51 KB
/
constants.py
File metadata and controls
184 lines (174 loc) · 6.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# constants.py
import sys
from pathlib import Path
APP_NAME = "AutoTidy"
APP_VERSION = "1.5.0"
# Cross-platform home directory and common paths
_HOME = str(Path.home())
if sys.platform == "win32":
import os
_TEMP = os.path.expandvars("%LocalAppData%/Temp")
_WIN_TEMP = "C:/Windows/Temp"
else:
import tempfile
_TEMP = tempfile.gettempdir()
_WIN_TEMP = _TEMP # Fallback on non-Windows
# Action types recorded in history
ACTION_MOVED = "MOVED"
ACTION_COPIED = "COPIED"
ACTION_DELETED_TO_TRASH = "DELETED_TO_TRASH"
ACTION_PERMANENTLY_DELETED = "PERMANENTLY_DELETED"
ACTION_SIMULATED_MOVE = "SIMULATED_MOVE"
ACTION_SIMULATED_COPY = "SIMULATED_COPY"
ACTION_SIMULATED_DELETE_TO_TRASH = "SIMULATED_DELETE_TO_TRASH"
ACTION_SIMULATED_PERMANENT_DELETE = "SIMULATED_PERMANENT_DELETE"
ACTION_ERROR = "ERROR"
ACTION_UNDO_MOVE = "UNDO_MOVE"
ACTION_SKIPPED = "SKIPPED"
# Status types recorded in history
STATUS_SUCCESS = "SUCCESS"
STATUS_FAILURE = "FAILURE"
STATUS_SKIPPED = "SKIPPED" # For actions that were intentionally skipped by logic
# Default configuration values
DEFAULT_CONFIG = {
"rules": [],
"settings": {
"run_on_startup": False,
"show_notifications": True,
"log_level": "INFO"
}
}
# Rule Templates
RULE_TEMPLATES = [
{
"name": "Clean up Downloads",
"description": "Deletes files older than 90 days from your Downloads folder.",
"rules": [
{
"folder_to_watch": str(Path.home() / "Downloads"),
"file_pattern": "*.*",
"action": "delete_to_trash",
"destination_folder": "",
"days_older_than": 90,
"enabled": True,
"use_regex": False
}
]
},
{
"name": "Organize Screenshots",
"description": "Moves screenshots named like 'Screenshot YYYY-MM-DD HHMMSS.png' from your Pictures/Screenshots folder to 'Pictures/Organized Screenshots'.",
"rules": [
{
"folder_to_watch": str(Path.home() / "Pictures" / "Screenshots"),
"file_pattern": "Screenshot ????-??-?? ??????.png",
"action": "move",
"destination_folder": str(Path.home() / "Pictures" / "Organized Screenshots"),
"days_older_than": 0,
"enabled": True,
"use_regex": False
}
]
},
{
"name": "Organize Video Captures",
"description": "Moves video captures (MP4, AVI, MKV) older than 30 days from Videos/Captures to 'Videos/Archived Captures'.",
"rules": [
{
"folder_to_watch": str(Path.home() / "Videos" / "Captures"),
"file_pattern": "*.mp4",
"action": "move",
"destination_folder": str(Path.home() / "Videos" / "Archived Captures"),
"days_older_than": 30,
"enabled": True,
"use_regex": False
},
{
"folder_to_watch": str(Path.home() / "Videos" / "Captures"),
"file_pattern": "*.avi",
"action": "move",
"destination_folder": str(Path.home() / "Videos" / "Archived Captures"),
"days_older_than": 30,
"enabled": True,
"use_regex": False
},
{
"folder_to_watch": str(Path.home() / "Videos" / "Captures"),
"file_pattern": "*.mkv",
"action": "move",
"destination_folder": str(Path.home() / "Videos" / "Archived Captures"),
"days_older_than": 30,
"enabled": True,
"use_regex": False
}
]
},
{
"name": "Clean Temporary Files",
"description": "Deletes all files from system temporary folders. Use with caution.",
"rules": [
{
"folder_to_watch": _WIN_TEMP,
"file_pattern": "*.*",
"action": "delete_permanently",
"destination_folder": "",
"days_older_than": 0,
"enabled": True,
"use_regex": False
},
{
"folder_to_watch": _TEMP,
"file_pattern": "*.*",
"action": "delete_permanently",
"destination_folder": "",
"days_older_than": 0,
"enabled": True,
"use_regex": False
}
]
},
{
"name": "Organize Game Captures (Example)",
"description": "Example: Moves MP4 game captures from a specific game's capture folder to an 'Organized' subfolder. Customize the path for your game.",
"rules": [
{
"folder_to_watch": str(Path.home() / "Videos" / "[Your Game Name]" / "Captures"),
"file_pattern": "*.mp4",
"action": "move",
"destination_folder": str(Path.home() / "Videos" / "[Your Game Name]" / "Captures" / "Organized"),
"days_older_than": 0,
"enabled": True,
"use_regex": False
}
]
}
]
# Help and guidance content reused across dialogs
EXCLUSION_HELP_CONTENT = {
"intro": (
"Exclusion patterns let you ignore files or folders before AutoTidy applies rule actions. "
"Use them to keep critical files safe or skip noisy directories."
),
"glob_examples": [
("*.tmp", "Skip leftover temporary files anywhere inside the watched folder."),
("cache/", "Ignore an entire subfolder named 'cache' (include the trailing slash)."),
("~$*.docx", "Exclude Office autosave files that start with '~$'."),
],
"regex_examples": [
(r"^backup_\\d{4}", "Ignore files whose names begin with 'backup_' followed by four digits."),
(r"\\.(log|bak)$", "Skip log or backup extensions when regex matching is enabled."),
],
"logic_notes": [
"Exclusions are checked before both the age and filename pattern parts of a rule.",
"If a file matches any exclusion, AutoTidy leaves it alone even when other rule conditions match.",
"Use folder-style exclusions (e.g., 'build/') to prevent entire trees from being processed.",
],
"readme_anchor": "#exclusion-patterns",
}
# Logging related constants
# Notification Levels
NOTIFICATION_LEVEL_NONE = "none"
NOTIFICATION_LEVEL_ERROR = "error"
NOTIFICATION_LEVEL_SUMMARY = "summary"
NOTIFICATION_LEVEL_ALL = "all"
DEFAULT_NOTIFICATION_LEVEL = NOTIFICATION_LEVEL_ALL