-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinitialize.py
More file actions
30 lines (25 loc) · 920 Bytes
/
initialize.py
File metadata and controls
30 lines (25 loc) · 920 Bytes
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
import os
import sys
import json
def create_settings_file():
default_settings = {
"show_info": "no",
"show_info_preset": "online",
"theme": "gnome_light",
"extra_buttons": "yes",
"window_size": "285x450"
}
settings_path = f'{sys.path[0]}/settings.json'
if not os.path.isfile(settings_path):
with open(settings_path, 'w') as settings:
json.dump(default_settings, settings, indent=4)
else:
with open(settings_path, 'r') as settings:
current_settings = json.load(settings)
# Update missing keys with default values
for key, value in default_settings.items():
if key not in current_settings:
current_settings[key] = value
with open(settings_path, 'w') as settings:
json.dump(current_settings, settings, indent=4)
create_settings_file()