update create new within update
This commit is contained in:
@@ -11,6 +11,8 @@ class SaveFileObject():
|
||||
def asdict(self):
|
||||
return asdict(self)
|
||||
def update(self, new):
|
||||
if new is None:
|
||||
new=dict()
|
||||
for key, value in new.items():
|
||||
if hasattr(self, key):
|
||||
setattr(self, key, value)
|
||||
@@ -57,7 +59,7 @@ class SaveFileMapping(Mapping):
|
||||
if not isinstance(data,SaveFileObject):
|
||||
raise TypeError("data elements should be derived from SaveFileObject")
|
||||
if not callable(getattr(data,"asdict",None)):
|
||||
raise TypeError("Dataelements need a method to_dict that returns a dict")
|
||||
raise TypeError("Dataelements need a method asdict that returns a dict this should be out of the box if you use dataclasses")
|
||||
#if not callable(getattr(data.__class__,"from_dict",None)):
|
||||
# raise TypeError("Dataelements need a method to_dict that returns a dict")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user