-
Notifications
You must be signed in to change notification settings - Fork 0
/
fireNFX_Persist.py
39 lines (32 loc) · 1.16 KB
/
fireNFX_Persist.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
import general
if(general.getVersion() >= 37):
import json
import os
cwd = os.getcwd() + '\\'
def save_object(obj, file_path):
file_path = cwd + file_path
try:
with open(file_path, 'w') as file:
json.dump(vars(obj), file, indent=4)
return True
except Exception as e:
print(f"Error saving object {obj}: {e}")
return False
def load_object(obj, file_path):
file_path = cwd + file_path
try:
with open(file_path, 'r') as file:
settings_dict = json.load(file)
for key, value in settings_dict.items():
setattr(obj, key, value)
return True
except Exception as e:
print(f"Error loading object {obj}: {e}")
return False
else:
def save_object(obj, file_path):
print('save_object() insufficient version ', general.getVersion(), 'requires version >= 37')
return False
def load_object(obj, file_path):
print('load_object() insufficient version ', general.getVersion(), 'requires version >= 37')
return False