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"] red_ids = jsonobj["red_ids"]
self.set_red_ids(red_ids) self.set_red_ids(red_ids)
def to_json(self): def to_dict(self):
jsonobj = dict() jsonobj = dict()
# die Oberflächendaten # die Oberflächendaten
gui_data = self.get_gui_dict() gui_data = self.get_all_gui_data()
jsonobj["gui_data"] = gui_data jsonobj["gui_data"] = gui_data
# die Impfdaten # die Impfdaten
@@ -171,19 +171,21 @@ class CadItem():
# die ids der nicht migrierten Dateien # die ids der nicht migrierten Dateien
red_ids = self.get_red_ids() red_ids = self.get_red_ids()
jsonobj["red_ids"] = 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): def load(self, path):
#try: try:
# with open('data.json', 'r') as f: with open(path, 'r') as f:
# self.model.todos = json.load(f) self.from_json(json.load(f))
#except Exception: except Exception:
# pass raise Exception("guid_data, data, parent_children_mapping or red_ids not found")
pass
def save(self, path): def save(self, path):
#with open('data.json', 'w') as f: with open(path, 'w') as f:
# data = json.dump(self.model.data, f) json.dump(self.to_dict(), f)
pass
class CadItemRepository: class CadItemRepository:
""" """