Returns a dict with the differences between dict1 and dict2

        Notes:
            Keys that only exist in dict2 are not included in the diff if
            ignore_missing_keys is True, otherwise they are
            Simple compares are done on lists
187369
def _get_diffs(cls, dict1, dict2, ignore_missing_keys):
        '''
        
        '''
        ret_dict = {}
        for p in dict1.keys():
            if p not in dict2:
                ret_dict.update({p: {'new': dict1[p], 'old': cls.NONE_VALUE}})
            elif dict1[p] != dict2[p]:
                if isinstance(dict1[p], dict) and isinstance(dict2[p], dict):
                    sub_diff_dict = cls._get_diffs(dict1[p], dict2[p],
                                                   ignore_missing_keys)
                    if sub_diff_dict:
                        ret_dict.update({p: sub_diff_dict})
                else:
                    ret_dict.update({p: {'new': dict1[p], 'old': dict2[p]}})
        if not ignore_missing_keys:
            for p in dict2.keys():
                if p not in dict1.keys():
                    ret_dict.update({p: {'new': cls.NONE_VALUE,
                                         'old': dict2[p]}})
        return ret_dict
979203
def _bsecurate_cli_compare_basis_sets(args):
    ''''''
    ret = curate.compare_basis_sets(args.basis1, args.basis2, args.version1, args.version2, args.uncontract_general,
          args.data_dir, args.data_dir)
    if ret:
        return "No difference found"
    else:
        return "DIFFERENCES FOUND. SEE ABOVE"
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])
343708
def add_dicts(d1, d2):
    
    if d1 is None:
        return d2
    if d2 is None:
        return d1
    keys = set(d1)
    keys.update(set(d2))
    ret = {}
    for key in keys:
        v1 = d1.get(key)
        v2 = d2.get(key)
        if v1 is None:
            ret[key] = v2
        elif v2 is None:
            ret[key] = v1
        else:
            ret[key] = v1 + v2
    return ret
1162397
def _update_intersection(dict1,dict2,**kwargs):
    '''
        
    '''
    if('deepcopy' in kwargs):
        deepcopy = kwargs['deepcopy']
    else:
        deepcopy = 1
    if(deepcopy == 1):
        dict1 = copy.deepcopy(dict1)
    else:
        pass
    for key in dict2:
        if(key in dict1):
            dict1[key] = dict2[key]
    return(dict1)
685141
def merge_dicts(dict1, dict2, append_lists=False):
    
    for key in dict2:
        if isinstance(dict2[key], dict):
            if key in dict1 and key in dict2:
                merge_dicts(dict1[key], dict2[key], append_lists)
            else:
                dict1[key] = dict2[key]
        # If the value is a list and the ``append_lists`` flag is set,
        # append the new values onto the original list
        elif isinstance(dict2[key], list) and append_lists:
            # The value in dict1 must be a list in order to append new
            # values onto it. Don't add duplicates.
            if key in dict1 and isinstance(dict1[key], list):
                dict1[key].extend(
                    [k for k in dict2[key] if k not in dict1[key]])
            else:
                dict1[key] = dict2[key]
        else:
            dict1[key] = dict2[key]
556357
def deep_update(dict1, dict2):
    
    def flatten(v):
        if isinstance(v, ModifyList):
            return v.apply([])
        elif isinstance(v, dict):
            return dict((k, flatten(v_)) for k, v_ in v.iteritems())
        else:
            return v

    def merge(v1, v2):
        if isinstance(v1, dict) and isinstance(v2, dict):
            deep_update(v1, v2)
            return v1
        elif isinstance(v2, ModifyList):
            v1 = flatten(v1)
            return v2.apply(v1)
        else:
            return flatten(v2)

    for k1, v1 in dict1.iteritems():
        if k1 not in dict2:
            dict1[k1] = flatten(v1)

    for k2, v2 in dict2.iteritems():
        v1 = dict1.get(k2)

        if v1 is KeyError:
            dict1[k2] = flatten(v2)
        else:
            dict1[k2] = merge(v1, v2)
307199
def diff_foreign_key(self, key1, key2):
        
        key1_unquoted_local_columns = [
            c.lower() for c in key1.get_unquoted_local_columns()
        ]
        key2_unquoted_local_columns = [
            c.lower() for c in key2.get_unquoted_local_columns()
        ]

        if key1_unquoted_local_columns != key2_unquoted_local_columns:
            return True

        key1_unquoted_foreign_columns = [
            c.lower() for c in key1.get_unquoted_foreign_columns()
        ]
        key2_unquoted_foreign_columns = [
            c.lower() for c in key2.get_unquoted_foreign_columns()
        ]

        if key1_unquoted_foreign_columns != key2_unquoted_foreign_columns:
            return True

        if (
            key1.get_unqualified_foreign_table_name()
            != key2.get_unqualified_foreign_table_name()
        ):
            return True

        if key1.on_update() != key2.on_update():
            return True

        if key1.on_delete() != key2.on_delete():
            return True

        return False
815770
def merge_dicts(i):
    

    a=i['dict1']
    b=i['dict2']

    for k in b:
        v=b[k]
        if type(v) is dict:
           if k not in a:
              a.update({k:b[k]})
           elif type(a[k])==dict:
              merge_dicts({'dict1':a[k], 'dict2':b[k]})
           else:
              a[k]=b[k]
        elif type(v) is list:
           a[k]=[]
           for y in v:
               a[k].append(y)
        else:
           a[k]=b[k]

    return {'return':0, 'dict1':a}
888560
def compare_changes(obj, **kwargs):
    '''
    
    '''
    changes = {}
    for key, value in obj.items():
        if key in kwargs:
            if value != kwargs[key]:
                changes[key] = kwargs[key]
    return changes
638826
def __diff_obj(self, level, parents_ids=frozenset({}),
                   is_namedtuple=False):
        """"""
        try:
            if is_namedtuple:
                t1 = level.t1._asdict()
                t2 = level.t2._asdict()
            else:
                t1 = level.t1.__dict__
                t2 = level.t2.__dict__
        except AttributeError:
            try:
                t1 = self.__dict_from_slots(level.t1)
                t2 = self.__dict_from_slots(level.t2)
            except AttributeError:
                self.__report_result('unprocessed', level)
                return

        self.__diff_dict(
            level,
            parents_ids,
            print_as_attribute=True,
            override=True,
            override_t1=t1,
            override_t2=t2)
402887
def how_similar_dicts(dict1, dict2):
    
    values = []
    for k in dict1:  # iterate keys
        if k in dict2 and dict1[k] and dict2[k]:
            values.append(
                how_similar_are(str(dict1[k]), str(dict2[k]))
            )
    return np.mean(values)
1258807
def calculate_dict_diff(old_params: dict, new_params: dict):
    
    # Ignore all None values as those cannot be saved.
    old_params = remove_None(old_params)
    new_params = remove_None(new_params)
    params_diff = {}
    for key, value in old_params.items():
        if key in new_params:
            if value != new_params[key]:
                params_diff[key] = new_params[key]
        else:
            params_diff[key] = ''
    for key, value in new_params.items():
        if key not in old_params:
            params_diff[key] = value
    return params_diff
1357960
def difference(a: Iterable[Any], b: Container[Any]) -> List[Any]:
    
    d = []
    for item in a:
        if item not in b:
            d.append(item)
    return d
468982
def diff_list(self, list1, list2):
        """"""
        for key in list1:
            if key in list2 and list2[key] != list1[key]:
                print key
            elif key not in list2:
                print key
266543
def cmp_like_py2(dict1, dict2):  # type: (Dict[Text, Any], Dict[Text, Any]) -> int
    
    # extract lists from both dicts
    first, second = dict1["position"], dict2["position"]
    # iterate through both list till max of their size
    for i, j in zip_longest(first, second):
        if i == j:
            continue
        # in case 1st list is smaller
        # should come first in sorting
        if i is None:
            return -1
        # if 1st list is longer,
        # it should come later in sort
        elif j is None:
            return 1

        # if either of the list contains str element
        # at any index, both should be str before comparing
        if isinstance(i, str) or isinstance(j, str):
            return 1 if str(i) > str(j) else -1
        # int comparison otherwise
        return 1 if i > j else -1
    # if both lists are equal
    return 0
591209
def difference(self, other):
        

        obj = self._clone()
        obj.difference_update(other)
        return obj