-
Notifications
You must be signed in to change notification settings - Fork 0
/
tools.py
60 lines (56 loc) · 809 Bytes
/
tools.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
def check_config_existence(location):
from pathlib import Path
from json import load, dump
default_config: dict = {
'Documents': [
'txt',
'pdf',
'html',
'css',
'yaml',
'json',
'docx',
'xml',
'xlsx',
'csv'
],
'Images': [
'png',
'jpg',
'gif',
'svg',
'ico'
],
'Video': [
'mp4',
'webm',
'mkv',
'mov',
'flv',
'avi',
'wmv',
'm4v'
],
'Compressed': [
'zip',
'7z',
'rar'
],
'Audio': [
'mp3',
'ogg',
'wav',
'wma'
],
'Software': [
'exe',
'msi'
]
}
config_file: Path = Path(location).joinpath('config.json')
if not config_file.exists():
with config_file.open('w') as f:
dump(default_config, f, indent = 2)
return default_config
with config_file.open('rb') as f:
return load(f)