Compare an object with another and return a :py:class:`DiffInfo`
        object.  Accepts the same arguments as
        :py:meth:`normalize.record.Record.diff_iter`
512525
def diff(self, other, **kwargs):
        
        from normalize.diff import diff
        return diff(self, other, **kwargs)
539529
def diff(self, a_ref, target=None, b_ref=None):
    
    result = {}
    diff_dct = self.scm.get_diff_trees(a_ref, b_ref=b_ref)
    result[DIFF_A_REF] = diff_dct[DIFF_A_REF]
    result[DIFF_B_REF] = diff_dct[DIFF_B_REF]
    if diff_dct[DIFF_EQUAL]:
        result[DIFF_EQUAL] = True
        return result
    result[DIFF_LIST] = []
    diff_outs = _get_diff_outs(self, diff_dct)
    if target is None:
        result[DIFF_LIST] = [
            _diff_royal(self, path, diff_outs[path]) for path in diff_outs
        ]
    elif target in diff_outs:
        result[DIFF_LIST] = [_diff_royal(self, target, diff_outs[target])]
    else:
        msg = "Have not found file/directory '{}' in the commits"
        raise FileNotInCommitError(msg.format(target))
    return result
1216343
def get_diff(self, other_mapping):
        
        result = MultiField(name=self.name)
        new_fields = set(self.fields.keys())
        if not isinstance(other_mapping, MultiField):
            n_mapping = MultiField(name=self.name)
            n_mapping.add_fields([other_mapping])
            other_mapping = n_mapping

        old_fields = set(other_mapping.fields.keys())
        #we propagate new fields
        added = new_fields - old_fields
        if added:
            result.add_fields([(add, self.fields[add]) for add in added])
            #TODO: raise in field changed
        if len(result.fields) > 0:
            return result
        return None
995498
def iterdirty(self):
        ''''''
        return iter(chain(itervalues(self._new), itervalues(self._modified)))
1251107
def record_diff(old, new):
    
    return '\n'.join(difflib.ndiff(
        ['%s: %s' % (k, v) for op in old for k, v in op.items()],
        ['%s: %s' % (k, v) for op in new for k, v in op.items()],
    ))
396602
def diff(self):
        
        latest = self.latest
        current = NetJsonParser(self.json())
        return diff(current, latest)
1071637
def get_diff(self, ignore=[]):
        
        # ignore this and the caller frame
        ignore.append(inspect.currentframe()) #PYCHOK change ignore
        self.o1 = self._get_objects(ignore)
        diff = muppy.get_diff(self.o0, self.o1)
        self.o0 = self.o1
        # manual cleanup, see comment above
        del ignore[:] #PYCHOK change ignore
        return diff
79907
def _diff(d1,d2):
    '''
        
    '''
    d = {}
    ds = _diff_internal(d1,d2)
    for key in ds['vdiff']:
        d[key] = d1[key]
    for key in ds['kdiff']:
        d[key] = d1[key]
    return(d)
583492
def diff_archives(archive1, archive2, verbosity=0, interactive=True):
    """"""
    util.check_existing_filename(archive1)
    util.check_existing_filename(archive2)
    if verbosity >= 0:
        util.log_info("Comparing %s with %s ..." % (archive1, archive2))
    res = _diff_archives(archive1, archive2, verbosity=verbosity, interactive=interactive)
    if res == 0 and verbosity >= 0:
        util.log_info("... no differences found.")
607245
def difference(self, *others):
        
        return self.copy(super(NGram, self).difference(*others))
1112324
def difference_update(self, *iterables):
        
        _set = self._set
        values = set(chain(*iterables))
        if (4 * len(values)) > len(_set):
            _list = self._list
            _set.difference_update(values)
            _list.clear()
            _list.update(_set)
        else:
            _discard = self.discard
            for value in values:
                _discard(value)
        return self
611347
def comparison_callback(sender, instance, **kwargs):
    """"""
    if validate_instance(instance) and settings.AUTOMATED_LOGGING['to_database']:
        try:
            old = sender.objects.get(pk=instance.pk)
        except Exception:
            return None

        try:
            mdl = ContentType.objects.get_for_model(instance)
            cur, ins = old.__dict__, instance.__dict__
            old, new = {}, {}
            for k in cur.keys():
                # _ fields are not real model fields, only state or cache fields
                # getting filtered
                if re.match('(_)(.*?)', k):
                    continue

                changed = False
                if k in ins.keys():
                    if cur[k] != ins[k]:
                        changed = True
                        new[k] = ModelObject()
                        new[k].value = str(ins[k])
                        new[k].save()

                        try:
                            new[k].type = ContentType.objects.get_for_model(ins[k])
                        except Exception:
                            logger = logging.getLogger(__name__)
                            logger.debug('Could not dermin the content type of the field')

                        new[k].field = Field.objects.get_or_create(name=k, model=mdl)[0]
                        new[k].save()
                else:
                    changed = True

                if changed:
                    old[k] = ModelObject()
                    old[k].value = str(cur[k])
                    old[k].save()

                    try:
                        old[k].type = ContentType.objects.get_for_model(cur[k])
                    except Exception:
                        logger = logging.getLogger(__name__)
                        logger.debug('Could not dermin the content type of the field')

                    old[k].field = Field.objects.get_or_create(name=k, model=mdl)[0]
                    old[k].save()

            if old or new:
                changelog = ModelChangelog()
                changelog.save()

                changelog.modification = ModelModification()
                changelog.modification.save()
                changelog.modification.previously.add(*old.values())
                changelog.modification.currently.add(*new.values())

                changelog.information = ModelObject()
                changelog.information.save()
                changelog.information.value = repr(instance)
                changelog.information.type = ContentType.objects.get_for_model(instance)
                changelog.information.save()
                changelog.save()

                instance.al_chl = changelog

                return instance

        except Exception as e:
            print(e)
            logger = logging.getLogger(__name__)
            logger.warning('automated_logging recorded an exception that should not have happended')
514388
def patch_records(diff, from_records, strict=True):
    
    return patch.apply(diff, from_records, strict=strict)
601268
def diff(self, other, **kwargs):
        
        return JsonDiff(
            base_type_name=type(self).__name__,
            other_type_name=type(other).__name__,
            values=self.diff_iter(other, **kwargs),
        )
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
578044
def compare(self, a, b, zone):
        '''
        
        '''
        self.log.info('compare: a=%s, b=%s, zone=%s', a, b, zone)

        try:
            a = [self.providers[source] for source in a]
            b = [self.providers[source] for source in b]
        except KeyError as e:
            raise Exception('Unknown source: {}'.format(e.args[0]))

        sub_zones = self.configured_sub_zones(zone)
        za = Zone(zone, sub_zones)
        for source in a:
            source.populate(za)

        zb = Zone(zone, sub_zones)
        for source in b:
            source.populate(zb)

        return zb.changes(za, _AggregateTarget(a + b))
276965
def comparator(operator):
    
    @wraps(operator)
    def wrapper(self, other):
        if not isinstance(other, (VersionInfo, dict)):
            return NotImplemented
        return operator(self, other)
    return wrapper