Merge dict b into a
550768
def merge_dict(a, b, path=None):
    
    if not path:
        path = []
    for key in b:
        if key in a:
            if isinstance(a[key], dict) and isinstance(b[key], dict):
                merge_dict(a[key], b[key], path + [str(key)])
            else:
                continue
        else:
            a[key] = b[key]
    return a
1319370
def dictmerge(x, y):
    
    z = x.copy()
    z.update(y)
    return z
16197
def merge_dicts(dict1, dict2, deep_merge=True):
    """"""
    if deep_merge:
        if isinstance(dict1, list) and isinstance(dict2, list):
            return dict1 + dict2

        if not isinstance(dict1, dict) or not isinstance(dict2, dict):
            return dict2

        for key in dict2:
            dict1[key] = merge_dicts(dict1[key], dict2[key]) if key in dict1 else dict2[key]  # noqa pylint: disable=line-too-long
        return dict1
    dict3 = dict1.copy()
    dict3.update(dict2)
    return dict3
334514
def merge_dicts(*dicts, **kwargs):
    """"""
    result = {}
    for d in dicts:
        result.update(d)
    result.update(kwargs)
    return result
1333664
def merge(d, *dicts):
    

    for d_update in dicts:
        if not isinstance(d, dict):
            raise TypeError("{0} is not a dict".format(d))

        dict_merge_pair(d, d_update)

    return d
729207
def _merge_metadata(self_or_cls, obj, fn, *dicts):
        
        merged = dict([(k,v) for d in dicts for (k,v) in d.items()])
        return dict(merged, **fn(obj)) if fn else merged
151016
def _merge_a_into_b(self, a, b):
        
        from easydict import EasyDict as edict
        if type(a) is not edict:
            return

        for k, v in a.items():
            # a must specify keys that are in b
            if k not in b:
                raise KeyError('{} is not a valid config key'.format(k))

            # the types must match, too
            old_type = type(b[k])
            if old_type is not type(v):
                if isinstance(b[k], np.ndarray):
                    v = np.array(v, dtype=b[k].dtype)
                else:
                    raise ValueError(('Type mismatch ({} vs. {}) '
                                      'for config key: {}').format(type(b[k]),
                                                                   type(v), k))

            # recursively merge dicts
            if type(v) is edict:
                try:
                    self._merge_a_into_b(a[k], b[k])
                except:
                    print('Error under config key: {}'.format(k))
                    raise
            else:
                b[k] = v
        return b
364562
def combined_dict(*dicts):
  """"""
  return {k: v for d in dicts for k, v in d.items()}
934137
def merge_dicts(d1, d2):
    
    for k in set(d1.keys()).union(d2.keys()):
        if k in d1 and k in d2:
            if isinstance(d1[k], dict) and isinstance(d2[k], dict):
                yield (k, dict(merge_dicts(d1[k], d2[k])))
            elif isinstance(d1[k], list):
                if isinstance(d2[k], list):
                    d1[k].extend(d2[k])
                else:
                    d1[k].append(d2[k])
                yield(k, d1)
            else:
                # If one of the values is not a dict, you can't continue merging it.
                # Value from second dict overrides one in first and we move on.
                yield (k, d2[k])
                # Alternatively, replace this with exception raiser to alert you of value conflicts
        elif k in d1:
            yield (k, d1[k])
        else:
            yield (k, d2[k])
363991
def merge_hash(a, b):
    '''  '''

    # and iterate over b keys
    for k, v in b.iteritems():
        if k in a and isinstance(a[k], dict):
            # if this key is a hash and exists in a
            # we recursively call ourselves with 
            # the key value of b
            a[k] = merge_hash(a[k], v)
        else:
            # k is not in a, no need to merge b, we just deecopy
            # or k is not a dictionnary, no need to merge b either, we just deecopy it
            a[k] = v
    # finally, return the resulting hash when we're done iterating keys
    return a
1143835
def dict_merge(*dict_list):
    
    result = collections.defaultdict(dict)
    dicts_items = itertools.chain(*[six.iteritems(d or {}) for d in dict_list])

    for key, value in dicts_items:
        src = result[key]
        if isinstance(src, dict) and isinstance(value, dict):
            result[key] = dict_merge(src, value)
        elif isinstance(src, dict) or isinstance(src, six.text_type):
            result[key] = value
        elif hasattr(src, "__iter__") and hasattr(value, "__iter__"):
            result[key] += value
        else:
            result[key] = value

    return dict(result)
980008
def deep_merge(dict_one, dict_two):
    '''
    
    '''
    merged = dict_one.copy()
    for key, value in dict_two.items():
        # value is equivalent to dict_two[key]
        if (key in dict_one and
                isinstance(dict_one[key], dict) and
                isinstance(value, dict)):
            merged[key] = deep_merge(dict_one[key], value)
        elif (key in dict_one and
              isinstance(dict_one[key], list) and
              isinstance(value, list)):
            merged[key] = list(set(dict_one[key] + value))
        else:
            merged[key] = value
    return merged
1334555
def merge_dicts(d1, d2):
    """"""
    merged = copy.deepcopy(d1)
    deep_update(merged, d2, True, [])
    return merged
829293
def merge_dict(lhs, rhs):
    
    assert isinstance(lhs, dict)
    assert isinstance(rhs, dict)
    for k, v in rhs.iteritems():
        if k not in lhs:
            lhs[k] = v
        else:
            lhs[k] = merge_dict(lhs[k], v)
    return lhs
814793
def merge_dicts(base, updates):
    
    if not base:
        base = dict()
    if not updates:
        updates = dict()
    z = base.copy()
    z.update(updates)
    return z
250385
def merge(self, other):
        """"""
        log.debug('Merging: %s and %s' % (self.serialize(), other.serialize()))
        for k in self.keys():
            for new_item in other[k]:
                if new_item not in self[k]:
                    self[k].append(new_item)
        log.debug('Result: %s' % self.serialize())
        return self
609708
def _dict_compose(dict1, dict2):
    
    return {k: dict2.get(v) for k, v in dict1.items() if v in dict2}