Handle empty values

This commit is contained in:
richard-dds
2018-10-23 10:54:53 -04:00
parent e40c6c67a3
commit 3f3b90e3c7
3 changed files with 15 additions and 5 deletions

View File

@@ -33,9 +33,9 @@ def getattr_path(obj, path, default=None):
return _obj
def update_obj(obj, dct):
def update_obj(obj, dct, ignore_vals=lambda v: v is None):
for k, v in dct.items():
if hasattr(obj, k) and v is not None:
if hasattr(obj, k) and not ignore_vals(v):
setattr(obj, k, v)
return obj