app/soc/logic/dicts.py
changeset 2177 e2c193e1f631
parent 2073 6eb9b4652c80
equal deleted inserted replaced
2176:3e5187b444db 2177:e2c193e1f631
    51     updates: A dictionary containing new values for the original dict
    51     updates: A dictionary containing new values for the original dict
    52     sub_merge: Merge a dict or list present in both target and update
    52     sub_merge: Merge a dict or list present in both target and update
    53     recursive: Determines whether merge_subdicts is recursive
    53     recursive: Determines whether merge_subdicts is recursive
    54 
    54 
    55   Returns:
    55   Returns:
    56     the target dict, with any missing values from updates merged in, in-place.
    56     a new dict, with any missing values from updates merged into target
    57   """
    57   """
    58 
    58 
    59   if not target:
    59   target = target.copy() if target else {}
    60     target = {}
       
    61 
    60 
    62   for key, value in updates.iteritems():
    61   for key, value in updates.iteritems():
    63     if key not in target:
    62     if key not in target:
    64       target[key] = value
    63       target[key] = value
    65     elif sub_merge:
    64     elif sub_merge: