Dumps all diffs that have the given field and are of TYPE_MISSING.
350747
def dump_missing_diffs(field)
      missing_diffs = diffs_by_field_type(field, TYPE_MISSING)

      if missing_diffs.length > 0
        header = "Table #{@table_name} is missing #{field}:\n"
        diff_str = missing_diffs.map do |diff|
          dump_single(field, diff[:generator], diff[:elem])
        end.join("\n\t")

        "#{header}\n\t#{diff_str}\n"
      end
    end
134365
def diff_files(left, right, diff_options=None, formatter=None):
    """"""
    return _diff(etree.parse, left, right,
                 diff_options=diff_options, formatter=formatter)
55619
def __diff(self, level, parents_ids=frozenset({})):
        """"""
        if level.t1 is level.t2:
            return

        if self.__skip_this(level):
            return

        if get_type(level.t1) != get_type(level.t2):
            report_type_change = True
            for type_group in self.ignore_type_in_groups:
                if self.type_check_func(level.t1, type_group) and self.type_check_func(level.t2, type_group):
                    report_type_change = False
                    break
            if report_type_change:
                self.__diff_types(level)
                return

        if isinstance(level.t1, strings):
            self.__diff_str(level)

        elif isinstance(level.t1, numbers):
            self.__diff_numbers(level)

        elif isinstance(level.t1, Mapping):
            self.__diff_dict(level, parents_ids)

        elif isinstance(level.t1, tuple):
            self.__diff_tuple(level, parents_ids)

        elif isinstance(level.t1, (set, frozenset, OrderedSet)):
            self.__diff_set(level)

        elif isinstance(level.t1, Iterable):
            if self.ignore_order:
                self.__diff_iterable_with_deephash(level)
            else:
                self.__diff_iterable(level, parents_ids)

        else:
            self.__diff_obj(level, parents_ids)
1102454
function errorDiff(actual, expected) {
  return diff
    .diffWordsWithSpace(actual, expected)
    .map(function(str) {
      if (str.added) {
        return colorLines('diff added', str.value);
      }
      if (str.removed) {
        return colorLines('diff removed', str.value);
      }
      return str.value;
    })
    .join('');
}
1357815
def _diff_and_summarize(from_csv, to_csv, index_columns, stream=sys.stdout,
                        sep=',', ignored_columns=None, significance=None):
    
    from_records = list(records.load(from_csv, sep=sep))
    to_records = records.load(to_csv, sep=sep)

    diff = patch.create(from_records, to_records, index_columns, ignored_columns)
    if significance is not None:
        diff = patch.filter_significance(diff, significance)

    _summarize_diff(diff, len(from_records), stream=stream)
    exit_code = (EXIT_SAME
                 if patch.is_empty(diff)
                 else EXIT_DIFFERENT)
    sys.exit(exit_code)
264319
def collect_custom_fields_diff(name, fields)
      # puts "==> collect_custom_fields_diff for #{name}, #{fields.size}" # DEBUG

      memo = self.initialize_custom_fields_diff(name)

      fields.map do |field|
        field.collect_diff(memo)
      end

      # collect fields with a modified localized field
      fields.each do |field|
        if field.localized_changed? && field.persisted?
          self._custom_field_localize_diff[name] << { field: field.name, localized: field.localized? }
        end
      end
    end
767400
def default_diff(latest_config, current_config):
    """"""
    # Pop off the fields we don't care about:
    pop_no_diff_fields(latest_config, current_config)

    diff = DeepDiff(
        latest_config,
        current_config,
        ignore_order=True
    )
    return diff
532533
def get_columns_diff(changes):
    
    for change in changes:
        change.diff = []
        elt_changes = change.get_changes()
        if elt_changes:
            change.diff = elt_changes.columns

    return changes
1163634
function diff(orig, dest, options) {
        var result, key, obj, objEx, origObj, origObjEx, i, t;
        orig = listToObject(orig, options.key);
        dest = listToObject(dest, options.key);
        result = { added: [], removed: [], modified: [], unchanged: [] };
        for (key in dest.valids) {
            if (dest.valids.hasOwnProperty(key)) {
                obj = dest.valids[key];
                origObj = orig.valids[key];
                if (origObj === undefined) {
                    result.added.push(obj);
                } else {
                    // keep and exclude
                    keep(origObj, obj, options);
                    objEx = exclude(obj, options.exclude);
                    origObjEx = exclude(origObj, options.exclude);
                    // compare
                    if (deepEqual(objEx, origObjEx)) {
                        result.unchanged.push(obj);
                    } else {
                        result.modified.push(obj);
                    }
                    delete orig.valids[key];
                }
            }
        }
        for (key in orig.valids) {
            if (orig.valids.hasOwnProperty(key)) {
                result.removed.push(orig.valids[key]);
            }
        }
        // discarded object (without a key)
        if (orig.discarded.length) {
            result.discardedOrig = orig.discarded;
        }
        if (dest.discarded.length) {
            result.discardedDest = dest.discarded;
        }
        // for (i = 0; i < orig.discarded.length; i =+ 1) {
        //     t = orig.discarded[i];
        // }

        return result;
    }
156920
def diff_files(from_file, to_file, index_columns, sep=',', ignored_columns=None):
    
    with open(from_file) as from_stream:
        with open(to_file) as to_stream:
            from_records = records.load(from_stream, sep=sep)
            to_records = records.load(to_stream, sep=sep)
            return patch.create(from_records, to_records, index_columns,
                                ignore_columns=ignored_columns)
948792
def malloc_diff(func):
    
    def _f(*args, **kwargs):
        print("\n<<<---")
        tracemalloc.start()
        snapshot1 = tracemalloc.take_snapshot()
        res = func(*args, **kwargs)
        snapshot2 = tracemalloc.take_snapshot()
        top_stats = snapshot2.compare_to(snapshot1, 'lineno')
        print("[ Top 10 differences]")
        for stat in top_stats[:10]:
            print(stat)
        print("--->>>\n")
        return res
    return _f
662878
def _get_changes_from_diff_dict(diff_dict):
    '''
    
    '''
    changes_strings = []
    for p in diff_dict.keys():
        if not isinstance(diff_dict[p], dict):
            raise ValueError('Unexpected diff difct \'{0}\''.format(diff_dict))
        if sorted(diff_dict[p].keys()) == ['val1', 'val2']:
            # Some string formatting
            from_str = diff_dict[p]['val1']
            if isinstance(diff_dict[p]['val1'], six.string_types):
                from_str = '\'{0}\''.format(diff_dict[p]['val1'])
            elif isinstance(diff_dict[p]['val1'], list):
                from_str = '\'{0}\''.format(', '.join(diff_dict[p]['val1']))
            to_str = diff_dict[p]['val2']
            if isinstance(diff_dict[p]['val2'], six.string_types):
                to_str = '\'{0}\''.format(diff_dict[p]['val2'])
            elif isinstance(diff_dict[p]['val2'], list):
                to_str = '\'{0}\''.format(', '.join(diff_dict[p]['val2']))
            changes_strings.append('{0} from {1} to {2}'.format(
                p, from_str, to_str))
        else:
            sub_changes = _get_changes_from_diff_dict(diff_dict[p])
            if sub_changes:
                changes_strings.append('{0}:'.format(p))
                changes_strings.extend(['\t{0}'.format(c)
                                       for c in sub_changes])
    return changes_strings
383690
def diff(file_, imports):
    """"""
    modules_not_imported = compare_modules(file_, imports)

    logging.info("The following modules are in {} but do not seem to be imported: "
                 "{}".format(file_, ", ".join(x for x in modules_not_imported)))
820047
def dmp_to_mdiff(diffs):
    
    def yield_buffer(lineno_left, lineno_right):
        while left_buffer or right_buffer:
            if left_buffer:
                left = lineno_left, '\0-{0}\1'.format(left_buffer.pop(0))
                lineno_left += 1
            else:
                left = '', '\n'
            if right_buffer:
                right = lineno_right, '\0+{0}\1'.format(right_buffer.pop(0))
                lineno_right += 1
            else:
                right = '', '\n'
            yield (left, right, True), lineno_left, lineno_right

    lineno_left = lineno_right = 1
    left_buffer = []
    right_buffer = []

    for op, data in diffs:
        for line in data.splitlines(True):
            if op == DMP.DIFF_EQUAL:
                for item, lleft, llright in yield_buffer(lineno_left,
                                                         lineno_right):
                    lineno_left = lleft
                    lineno_right = llright
                    yield item
                yield (lineno_left, line), (lineno_right, line), False
                lineno_left += 1
                lineno_right += 1
            elif op == DMP.DIFF_DELETE:
                left_buffer.append(line)
            elif op == DMP.DIFF_INSERT:
                right_buffer.append(line)

    for item, _, _ in yield_buffer(lineno_left, lineno_right):
        yield item
505069
def diff_cleanupSemantic(self, diffs):
    
    changes = False
    equalities = []  # Stack of indices where equalities are found.
    lastEquality = None  # Always equal to diffs[equalities[-1]][1]
    pointer = 0  # Index of current position.
    # Number of chars that changed prior to the equality.
    length_insertions1, length_deletions1 = 0, 0
    # Number of chars that changed after the equality.
    length_insertions2, length_deletions2 = 0, 0
    while pointer < len(diffs):
      if diffs[pointer][0] == self.DIFF_EQUAL:  # Equality found.
        equalities.append(pointer)
        length_insertions1, length_insertions2 = length_insertions2, 0
        length_deletions1, length_deletions2 = length_deletions2, 0
        lastEquality = diffs[pointer][1]
      else:  # An insertion or deletion.
        if diffs[pointer][0] == self.DIFF_INSERT:
          length_insertions2 += len(diffs[pointer][1])
        else:
          length_deletions2 += len(diffs[pointer][1])
        # Eliminate an equality that is smaller or equal to the edits on both
        # sides of it.
        if (lastEquality and (len(lastEquality) <=
            max(length_insertions1, length_deletions1)) and
            (len(lastEquality) <= max(length_insertions2, length_deletions2))):
          # Duplicate record.
          diffs.insert(equalities[-1], (self.DIFF_DELETE, lastEquality))
          # Change second copy to insert.
          diffs[equalities[-1] + 1] = (self.DIFF_INSERT,
              diffs[equalities[-1] + 1][1])
          # Throw away the equality we just deleted.
          equalities.pop()
          # Throw away the previous equality (it needs to be reevaluated).
          if len(equalities):
            equalities.pop()
          if len(equalities):
            pointer = equalities[-1]
          else:
            pointer = -1
          # Reset the counters.
          length_insertions1, length_deletions1 = 0, 0
          length_insertions2, length_deletions2 = 0, 0
          lastEquality = None
          changes = True
      pointer += 1

    # Normalize the diff.
    if changes:
      self.diff_cleanupMerge(diffs)
    self.diff_cleanupSemanticLossless(diffs)

    # Find any overlaps between deletions and insertions.
    # e.g: <del>abcxxx</del><ins>xxxdef</ins>
    #   -> <del>abc</del>xxx<ins>def</ins>
    # e.g: <del>xxxabc</del><ins>defxxx</ins>
    #   -> <ins>def</ins>xxx<del>abc</del>
    # Only extract an overlap if it is as big as the edit ahead or behind it.
    pointer = 1
    while pointer < len(diffs):
      if (diffs[pointer - 1][0] == self.DIFF_DELETE and
          diffs[pointer][0] == self.DIFF_INSERT):
        deletion = diffs[pointer - 1][1]
        insertion = diffs[pointer][1]
        overlap_length1 = self.diff_commonOverlap(deletion, insertion)
        overlap_length2 = self.diff_commonOverlap(insertion, deletion)
        if overlap_length1 >= overlap_length2:
          if (overlap_length1 >= len(deletion) / 2.0 or
              overlap_length1 >= len(insertion) / 2.0):
            # Overlap found.  Insert an equality and trim the surrounding edits.
            diffs.insert(pointer, (self.DIFF_EQUAL,
                                   insertion[:overlap_length1]))
            diffs[pointer - 1] = (self.DIFF_DELETE,
                                  deletion[:len(deletion) - overlap_length1])
            diffs[pointer + 1] = (self.DIFF_INSERT,
                                  insertion[overlap_length1:])
            pointer += 1
        else:
          if (overlap_length2 >= len(deletion) / 2.0 or
              overlap_length2 >= len(insertion) / 2.0):
            # Reverse overlap found.
            # Insert an equality and swap and trim the surrounding edits.
            diffs.insert(pointer, (self.DIFF_EQUAL, deletion[:overlap_length2]))
            diffs[pointer - 1] = (self.DIFF_INSERT,
                                  insertion[:len(insertion) - overlap_length2])
            diffs[pointer + 1] = (self.DIFF_DELETE, deletion[overlap_length2:])
            pointer += 1
        pointer += 1
      pointer += 1
885376
def _get_diff(self):
        """"""
        diff = []
        self._create_sot_file()
        command = ('show diff rollback-patch file {0} file {1}'.format(
                   'sot_file', self.replace_file.split('/')[-1]))
        diff_out = self.device.send_command(command)
        try:
            diff_out = diff_out.split(
                '#Generating Rollback Patch')[1].replace(
                    'Rollback Patch is Empty', '').strip()
            for line in diff_out.splitlines():
                if line:
                    if line[0].strip() != '!' and line[0].strip() != '.':
                        diff.append(line.rstrip(' '))
        except (AttributeError, KeyError):
            raise ReplaceConfigException(
                'Could not calculate diff. It\'s possible the given file doesn\'t exist.')
        return '\n'.join(diff)
336981
def _load_diff(args, extra_opts):
    
    try:
        diff = API.load(args.inputs, args.itype,
                        ac_ignore_missing=args.ignore_missing,
                        ac_merge=args.merge,
                        ac_template=args.template,
                        ac_schema=args.schema,
                        **extra_opts)
    except API.UnknownProcessorTypeError:
        _exit_with_output("Wrong input type '%s'" % args.itype, 1)
    except API.UnknownFileTypeError:
        _exit_with_output("No appropriate backend was found for given file "
                          "'%s'" % args.itype, 1)
    _exit_if_load_failure(diff,
                          "Failed to load: args=%s" % ", ".join(args.inputs))

    return diff