You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Nexus/core/util.py

12 lines
405 B
Python

def dict_combine_recursive(a, b):
# Based on http://stackoverflow.com/a/8725321
if a is None: return b
if b is None: return a
if isinstance(a, list) and isinstance(b, list):
return list(set(a + b))
elif isinstance(a, dict) and isinstance(b, dict):
keys = set(a.iterkeys()) | set(b.iterkeys())
return dict((key, dict_combine_recursive(a.get(key), b.get(key))) for key in keys)
else:
return b