Revision a971d6fe

b/snf-common/synnefo/lib/utils.py
32 32
# or implied, of GRNET S.A.
33 33

  
34 34
import datetime
35
import copy
35 36

  
36 37

  
37 38
def split_time(value):
......
86 87
        return list(set(iterable) - set(icase))
87 88

  
88 89
    return []
90

  
91

  
92
def dict_merge(a, b):
93
    """
94
    http://www.xormedia.com/recursively-merge-dictionaries-in-python/
95
    """
96
    if not isinstance(b, dict):
97
        return b
98
    result = copy.deepcopy(a)
99
    for k, v in b.iteritems():
100
        if k in result and isinstance(result[k], dict):
101
                result[k] = dict_merge(result[k], v)
102
        else:
103
            result[k] = copy.deepcopy(v)
104
    return result
105

  
106

  

Also available in: Unified diff