Merge a list of dictionaries.

    Args:
        dicts (list): a list of dictionary objects
        op (operator): an operator item used to merge the dictionaries. Defaults to :py:func:`operator.add`.

    Returns:
        dict: the merged dictionary
972771
def merge_dicts(dicts, op=operator.add):
    
    a = None
    for b in dicts:

        if a is None:
            a = b.copy()
        else:
            a = dict(a.items() + b.items() + [(k, op(a[k], b[k])) for k in set(b) & set(a)])
    return a
23955
def merge_dicts(dict_a, dict_b):
    """"""
    obj = {}
    for key, value in iteritems(dict_a):
        if key in dict_b:
            if isinstance(dict_b[key], dict):
                obj[key] = merge_dicts(value, dict_b.pop(key))
        else:
            obj[key] = value

    for key, value in iteritems(dict_b):
        obj[key] = value

    return obj
1320579
def combine_dicts(new_dict, old_dict):
    
    old_data_keys = list(old_dict.keys())
    new_data_keys = list(new_dict.keys())
    all_keys = set(old_data_keys).union(new_data_keys)
    combined_data_dict = {}
    for k in all_keys:
        try:
            combined_data_dict[k] = new_dict[k]
        except KeyError:
            combined_data_dict[k] = old_dict[k]
    return combined_data_dict
633757
def merge(dict1, dict2):
    
    for k in dict2:
        if k in dict1 and isinstance(dict1[k], dict) and isinstance(dict2[k], dict):
            merge(dict1[k], dict2[k])
        else:
            dict1[k] = dict2[k]
1107268
def merge_dicts(dict_a, dict_b):
    """"""
    duplicates = [val for val in dict_a if val in dict_b]
    if duplicates:
        _LOGGER.warning(("Duplicates found during merge: %s. "
                         "Renaming is recommended."), duplicates)
    return {**dict_a, **dict_b}
49100
def get_dict(dictionary, *keys,**kwargs):
    

    if 'default' in kwargs:
        default = kwargs['default']
    else:
        default = None

    existing = dictionary
    for i in range(0, len(keys)):

        if keys[i] in existing:

            existing = existing[keys[i]]
        else:

            return default
    return existing
1334555
def merge_dicts(d1, d2):
    """"""
    merged = copy.deepcopy(d1)
    deep_update(merged, d2, True, [])
    return merged
1350336
def merge(*ds):
    
    if not ds:
        raise ValueError("Must provide at least one dict to merge().")
    out = {}
    for d in ds:
        out.update(d)
    return out
971866
def assoc(cls, ops, kwargs):
    
    expanded = [(o,) if not isinstance(o, cls) else o.operands for o in ops]
    return sum(expanded, ()), kwargs
1020945
def to_op(self):
        
        if not self._adds:
            return None
        changes = {}
        if self._adds:
            changes['adds'] = list(self._adds)
        return changes
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
845984
def append(self, obj):
        
        h = self.func(obj)

        self.list.append(obj)
        idx = len(self.list) - 1
        self.dict[h] = idx

        return idx
1328091
def merge_options_to_dict(options):
    
    merged_options = {}
    for obj in options:
        if isinstance(obj,dict):
            new_opts = obj
        else:
            new_opts = {obj.key: obj.kwargs}

        merged_options = merge_option_dicts(merged_options, new_opts)
    return merged_options
919758
def merge(self, dct=None, **kwargs):
        
        if dct is None:
            dct = {}
        if kwargs:
            dct.update(**kwargs)

        for key, value in dct.items():
            if all((
                    isinstance(value, dict),
                    isinstance(self.get(key), Configuration),
                    getattr(self.get(key), "__merge__", True),
            )):
                # recursively merge
                self[key].merge(value)
            elif isinstance(value, list) and isinstance(self.get(key), list):
                # append
                self[key] += value
            else:
                # set the new value
                self[key] = value
673688
def deep_merge(base, extra):
    
    if extra is None:
        return

    for key, value in extra.items():
        if value is None:
            if key in base:
                del base[key]
        # If the key represents a dict on both given dicts, merge the sub-dicts
        elif isinstance(base.get(key), dict) and isinstance(value, dict):
            deep_merge(base[key], value)
        else:
            # Otherwise, set the key on the base to be the value of the extra.
            base[key] = value
270764
def _list_merge(src, dest):
    
    for k in src:
        if type(src[k]) != dict:
            dest[k] = src[k]
        else:
            # ---
            # src could have a key whose value is a list
            # and does not yet exist on dest
            if k not in dest:
                dest[k] = {}
            _list_merge(src[k], dest[k])
640396
def merge(self, dict_=None):
        """"""
        if dict_ is None and hasattr(self, '__dict__'):
            dict_ = self.__dict__  
            # doesn't work anymore as we have _lock attribute
        if dict_ is None:
            return self
        self.update(dict_)
        return self