Returns the diff of two text blobs.
179024
def _get_diff_text(old, new):
    '''
    
    '''
    diff = difflib.unified_diff(old.splitlines(1),
                                new.splitlines(1))
    return ''.join([x.replace('\r', '') for x in diff])
1368169
def get_dict_diff_str(d1, d2, title):
    
    added, removed, changed = get_dict_diff(d1, d2)
    lines = [title]

    if added:
        lines.append("Added attributes: %s"
                     % ['.'.join(x) for x in added])
    if removed:
        lines.append("Removed attributes: %s"
                     % ['.'.join(x) for x in removed])
    if changed:
        lines.append("Changed attributes: %s"
                     % ['.'.join(x) for x in changed])

    return '\n'.join(lines)
590291
def compare_dicts(d1, d2):
    
    a = json.dumps(d1, indent=4, sort_keys=True)
    b = json.dumps(d2, indent=4, sort_keys=True)
    # stolen from cpython
    # https://github.com/python/cpython/blob/01fd68752e2d2d0a5f90ae8944ca35df0a5ddeaa/Lib/unittest/case.py#L1091
    diff = ('\n' + '\n'.join(difflib.ndiff(
                   a.splitlines(),
                   b.splitlines())))
    return diff
17943
def dicom_diff(file1, file2):
    

    datasets = compressed_dicom.read_file(file1), compressed_dicom.read_file(file2)

    rep = []

    for dataset in datasets:
        lines = (str(dataset.file_meta)+"\n"+str(dataset)).split('\n')
        lines = [line + '\n' for line in lines]  # add the newline to the end
        rep.append(lines)

    diff = difflib.Differ()
    for line in diff.compare(rep[0], rep[1]):
        if (line[0] == '+') or (line[0] == '-'):
            sys.stdout.write(line)
1087588
def diff_table(rawinfo, newinfo):
    '''
    
    '''
    return HtmlDiff.make_table(HtmlDiff(), rawinfo.split('\n'), newinfo.split('\n'),
                               context=True,
                               numlines=1)
890950
def _full_diff(merge_result, key, context_lines=3):
    """"""
    header_printed = False
    for group in _split_diff(merge_result, context_lines=context_lines):
        if not header_printed:
            header_printed = True
            yield color.Header('diff a/%s b/%s' % (key, key))
            yield color.DeletedHeader('--- %s' % key)
            yield color.AddedHeader('+++ %s' % key)

        for l in _diff_group(group):
            yield l
646001
def word_diff(a,b):
  ''
  return translate_diff(a,rediff(splitpreserve(a),splitpreserve(b)))
587021
def diff(a, b):
    
    a, b = list(a), list(b)
    opcodes = SM(None, a, b).get_opcodes()
    return parse_opcodes(opcodes)
707779
def check_text_similarity(a_dom, b_dom, cutoff):
    """"""
    a_words = list(tree_words(a_dom))
    b_words = list(tree_words(b_dom))

    sm = WordMatcher(a=a_words, b=b_words)
    if sm.text_ratio() >= cutoff:
        return True
    return False
748943
function diff () {
  const files = getConfigFiles()

  debug('diff files: %o', files)

  const output = []

  files.forEach(f => {
    const result = jsDiff.structuredPatch(f[0].name, f[1].name, f[0].content, f[1].content)

    debug('diff result: %o', result)

    output.push('-------------------------------------------------\n')
    // eslint-disable-next-line max-len
    output.push(`diff ${chalk.blue(result.newFileName)} ${chalk.blue(result.oldFileName)}\n`)
    output.push('-------------------------------------------------\n')

    result.hunks.forEach(hunk => {
      fillLineNumber(hunk)

      const lines = hunk.lines.map(line => {
        if (line.startsWith('+')) {
          return chalk.green(line)
        }
        if (line.startsWith('-')) {
          return chalk.red(line)
        }
        return line
      })

      output.push(lines.join('\n'))
      output.push('\n')
    })

    output.push('\n')
  })

  console.log(output.join(''))
}
1363111
def _compute_diff(map1, map2):
        
        data = map1.data - map2.data
        return HpxMap(data, map1.hpx)
377837
def _diff_internal(d1,d2):
    '''
        
    '''
    same =[]
    kdiff =[]
    vdiff = []
    for key in d1:
        value = d1[key]
        if(key in d2):
            if(value == d2[key]):
                same.append(key)
            else:
                vdiff.append(key)
        else:
            kdiff.append(key)
    return({'same':same,'kdiff':kdiff,'vdiff':vdiff})
396602
def diff(self):
        
        latest = self.latest
        current = NetJsonParser(self.json())
        return diff(current, latest)
606459
function diff( a, b ) {
  let i, j, found = false, result = [];

  for ( i = 0; i < a.length; i++ ) {
    found = false;
    for ( j = 0; j < b.length; j++ ) {
      if ( a[ i ] === b[ j ] ) {
        found = true;
        break;
      }
    }
    if ( !found ) {
      result.push( a[ i ] );
    }
  }

  return result;
}
307620
def diff(self, diff):
        
        if diff is None:
            return None
        return dict(
            toVol=diff.toUUID,
            fromVol=diff.fromUUID,
            size=diff.size,
            sizeIsEstimated=diff.sizeIsEstimated,
        )
599663
def format_diff_pyxb(a_pyxb, b_pyxb):
    
    return '\n'.join(
        difflib.ndiff(
            serialize_to_xml_str(a_pyxb).splitlines(),
            serialize_to_xml_str(b_pyxb).splitlines(),
        )
    )
453406
def _get_diff(environ, label, pop=False):
    
    if pop:
        blob = environ.pop(_variable_name(label), None)
    else:
        blob = environ.get(_variable_name(label))

    return _loads(blob) if blob else {}