weitere Atomisierung von json load and save. caditem.to_dict impl.

This commit is contained in:
2024-01-16 17:02:48 +01:00
parent b2a4a62aa7
commit b9e69acca9
+14 -12
View File
@@ -153,11 +153,11 @@ class CadItem():
red_ids = jsonobj["red_ids"]
self.set_red_ids(red_ids)
def to_json(self):
def to_dict(self):
jsonobj = dict()
# die Oberflächendaten
gui_data = self.get_gui_dict()
gui_data = self.get_all_gui_data()
jsonobj["gui_data"] = gui_data
# die Impfdaten
@@ -171,19 +171,21 @@ class CadItem():
# die ids der nicht migrierten Dateien
red_ids = self.get_red_ids()
jsonobj["red_ids"] = red_ids
return json.dumps(jsonobj)
return jsonobj
def to_json(self):
obj = self.to_dict()
return json.dumps(obj)
def load(self, path):
#try:
# with open('data.json', 'r') as f:
# self.model.todos = json.load(f)
#except Exception:
# pass
pass
try:
with open(path, 'r') as f:
self.from_json(json.load(f))
except Exception:
raise Exception("guid_data, data, parent_children_mapping or red_ids not found")
def save(self, path):
#with open('data.json', 'w') as f:
# data = json.dump(self.model.data, f)
pass
with open(path, 'w') as f:
json.dump(self.to_dict(), f)
class CadItemRepository:
"""