Commit dee43579 authored by Jelte Jansen's avatar Jelte Jansen
Browse files

modified merge()

git-svn-id: svn:// e5f2f494-b856-4b98-b285-d166d9295462
parent 3fe5cad0
......@@ -41,17 +41,20 @@ def merge(orig, new):
new it will be removed in orig."""
if type(orig) != dict or type(new) != dict:
raise DataTypeError("Not a dict in merge()")
for kn in new.keys():
if kn in orig:
if new[kn]:
if type(new[kn]) == dict:
merge(orig[kn], new[kn])
orig[kn] = new[kn]
del orig[kn]
orig[kn] = new[kn]
def remove_null_items(d):
"""Recursively removes all (key,value) pairs from d where the
value is None"""
null_keys = []
for key in d.keys():
if type(d[key]) == dict:
elif d[key] is None:
for k in null_keys:
del d[k]
def find(element, identifier):
"""Returns the subelement in the given data element, raises DataNotFoundError if not found"""
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment