weitere Atomisierung von json load and save. caditem.to_dict impl.
This commit is contained in:
+14
-12
@@ -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:
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user