-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig_maker.py
78 lines (67 loc) · 2.37 KB
/
config_maker.py
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
# I might make a gui app that does this.
from main import Config, Operation, FolderTemplate, create_file_rule
import constants as const
#----------------------------------------------------------------------------------------------
DEFAULT_FOLDERS: list[FolderTemplate] = [
FolderTemplate(
"~/Downloads",
[
"Compressed",
"Documents",
"Pictures",
"Music",
"Video",
"Programs",
"Unsorted",
"Folders",
"Misc",
"Misc/No extension",
],
place_for_unwanted = "~/Downloads/Folders"
),
FolderTemplate(
"~/Pictures",
[
"Screenshots",
"Wallpapers"
]
)
]
#----------------------------------------------------------------------------------------------
DEFAULT_OPERATION: Operation = Operation(
["~/Downloads", "~/Downloads/Unsorted"],
[
create_file_rule("~/Downloads/Compressed", const.ARCHIVES),
create_file_rule("~/Downloads/Documents", const.DOCS),
create_file_rule("~/Downloads/Pictures", const.IMAGE),
create_file_rule("~/Downloads/Music", const.AUDIO),
create_file_rule("~/Downloads/Video", const.VIDEO),
create_file_rule("~/Downloads/Programs", const.PROGRAMS),
create_file_rule("~/Downloads/Misc/No extension", extensions=""),
]
)
SORT_PICTURES: Operation = Operation(
["~/Pictures","~/Downloads/Pictures"],
[
create_file_rule("~/Pictures/Screenshots", keywords=["screenshot"]),
create_file_rule("~/Pictures/Wallpapers", keywords=["wallpaper","unsplash"])
]
)
# We may have some files after a cleanup, move them to the unsorted folder.
# NOTE: Do not merge with the operation above, this can create a cylce.
SORT_RESIDUAL_FILES: Operation = Operation(
["~/Downloads"],
[create_file_rule("~/Downloads/Unsorted/", keywords="")]
)
#----------------------------------------------------------------------------------------------
DEFAULT_CONFIG: Config = Config(
DEFAULT_FOLDERS,
[
DEFAULT_OPERATION,
SORT_PICTURES,
SORT_RESIDUAL_FILES # Must be placed last or can create a cycle
]
)
#----------------------------------------------------------------------------------------------
if __name__ == "__main__":
DEFAULT_CONFIG.export("./configs/default.json")