-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsave_titlepage.py
49 lines (44 loc) · 1.44 KB
/
save_titlepage.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
import os
import json
from config_start import path_programm, path_localappdata_lama
def create_file_titlepage(titlepage_save):
if os.path.isfile(titlepage_save):
with open(titlepage_save, encoding="utf8") as f:
titlepage = json.load(f)
else:
titlepage = {
"logo": False,
"logo_path": False,
"titel": True,
"datum": True,
"datum_combobox": 0,
"klasse": True,
"name": True,
"note": False,
"unterschrift": False,
"individual": False,
"hide_all": False,
}
return titlepage
def check_format_titlepage_save(filepath):
# path = os.path.join(path_localappdata_lama, "Teildokument", filename)
try:
titlepage = create_file_titlepage(filepath)
except json.decoder.JSONDecodeError:
print(f'The file "{os.path.basename(filepath)}" has an invalid format. The standard was restored!')
titlepage = {
"logo": False,
"logo_path": False,
"titel": True,
"datum": True,
"datum_combobox": 0,
"klasse": True,
"name": True,
"note": False,
"unterschrift": False,
"individual": False,
"hide_all": False,
}
with open(filepath, "w+", encoding="utf8") as f:
json.dump(titlepage, f, ensure_ascii=False)
return titlepage