Parse the diff an return data for the template.
766935
def _parse_udiff(self):
        
        lineiter = self.lines
        files = []
        try:
            line = lineiter.next()
            # skip first context
            skipfirst = True
            while 1:
                # continue until we found the old file
                if not line.startswith('--- '):
                    line = lineiter.next()
                    continue

                chunks = []
                filename, old_rev, new_rev = \
                    self._extract_rev(line, lineiter.next())
                files.append({
                    'filename':         filename,
                    'old_revision':     old_rev,
                    'new_revision':     new_rev,
                    'chunks':           chunks
                })

                line = lineiter.next()
                while line:
                    match = self._chunk_re.match(line)
                    if not match:
                        break

                    lines = []
                    chunks.append(lines)

                    old_line, old_end, new_line, new_end = \
                        [int(x or 1) for x in match.groups()[:-1]]
                    old_line -= 1
                    new_line -= 1
                    context = len(match.groups()) == 5
                    old_end += old_line
                    new_end += new_line

                    if context:
                        if not skipfirst:
                            lines.append({
                                'old_lineno': '...',
                                'new_lineno': '...',
                                'action': 'context',
                                'line': line,
                            })
                        else:
                            skipfirst = False

                    line = lineiter.next()
                    while old_line < old_end or new_line < new_end:
                        if line:
                            command, line = line[0], line[1:]
                        else:
                            command = ' '
                        affects_old = affects_new = False

                        # ignore those if we don't expect them
                        if command in '#@':
                            continue
                        elif command == '+':
                            affects_new = True
                            action = 'add'
                        elif command == '-':
                            affects_old = True
                            action = 'del'
                        else:
                            affects_old = affects_new = True
                            action = 'unmod'

                        old_line += affects_old
                        new_line += affects_new
                        lines.append({
                            'old_lineno':   affects_old and old_line or '',
                            'new_lineno':   affects_new and new_line or '',
                            'action':       action,
                            'line':         line
                        })
                        line = lineiter.next()

        except StopIteration:
            pass

        # highlight inline changes
        for file in files:
            for chunk in chunks:
                lineiter = iter(chunk)
                #first = True
                try:
                    while 1:
                        line = lineiter.next()
                        if line['action'] != 'unmod':
                            nextline = lineiter.next()
                            if nextline['action'] == 'unmod' or \
                               nextline['action'] == line['action']:
                                continue
                            self.differ(line, nextline)
                except StopIteration:
                    pass

        return files
567567
function diffDataProps(props, oldProps) {
  if (oldProps === null) {
    return 'oldProps is null, initial diff';
  }

  // Support optional app defined comparison of data
  const {dataComparator} = props;
  if (dataComparator) {
    if (!dataComparator(props.data, oldProps.data)) {
      return 'Data comparator detected a change';
    }
    // Otherwise, do a shallow equal on props
  } else if (props.data !== oldProps.data) {
    return 'A new data container was supplied';
  }

  return null;
}
1173033
function(current, next, exclude){
   var di = diff(current, next);
   var diffs = di ? di.map(function(i){
      var str = JSON.stringify(i).replace("\"__data\",", "");
      return JSON.parse(str);
   }).filter(function(i){
      return i.path.join(",").indexOf("_") === -1;
   }).filter(function(i){
      return exclude.every(function(x){return i.path.indexOf(x) === -1; });
   }) : [];
   if(diffs.length > 0){
      return diffs;
   }
   else{
      return null;
   }
}
939076
def diff_sevice_by_text(service_name, service, environment, cf_client, repo_root):
    
    global ret_code

    logger.info('Investigating textual diff for `%s`:`%s` in environment `%s`',
                service['type'], service_name, environment)

    try:
        local_template = render_local_template(service_name, environment,
                                               repo_root, service['template_file'])

        current_template = fetch_current_cloudformation_template(
            service_name, environment, cf_client)

    except Exception as e:
        ret_code = 2
        logger.error(e)
        return

    ret = diff_string_templates(local_template, current_template)
    if not ret:
        logger.info('Deployed service `%s` in environment `%s` matches '
                    'the local template.', service_name, environment)
    else:
        ret_code = 1
        logger.error('Service `%s` in environment `%s` differs from '
                     'the local template.',
                     service_name, environment)
        logger.info('Change details:\n        %s', indentify(ret))
845165
function diff (code, lang) {
  var sections = []

  code.split(/\r?\n/g).forEach(function (line) {
    var type

    if (CHUNK_REGEXP.test(line)) {
      type = 'chunk'
    } else if (HEADER_REGEXP.test(line)) {
      type = 'header'
    } else {
      type = PATCH_TYPES[line[0]] || 'null'
      line = line.replace(/^[+\-! ]/, '')
    }

    // Merge data with the previous section where possible.
    var previous = sections[sections.length - 1]

    if (!previous || previous.type !== type) {
      sections.push({
        type: type,
        lines: [line]
      })

      return
    }

    previous.lines.push(line)
  })

  return highlightSections(sections, lang)
    .map(function (section) {
      var type = section.type
      var value = section.lines.join(SEPARATOR)

      return '<span class="diff-' + type + '">' + value + '</span>'
    })
    .join(SEPARATOR)
}
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
1125454
def parse_template(template, target):
 """"""
 c = ConfManager('')
 for section in template:
  c.add_section(section)
  for option, o in template[section].items():
   try:
    value = type(template[section][option]['value'])(target[section][option])
   except KeyError:
    value = o['value']
   finally:
    if 'value' in o:
     del o['value']
   c.set(section, option, value, **o)
 return c
387454
def parse_template(input_filename, output_filename=''):
    
    data = load_input()
    with open(input_filename, 'rb') as file:
        template = file.read().decode("utf-8")
    
    # Check if 'input' in data
    if not 'input' in data:
        raise ValueError("Could not find 'input' in data")
    
    # Parse template
    for field in data['input']:
        subs = ["filename", "value"] if isinstance(data['input'][field], dict) and "filename" in data['input'][field] and "value" in data['input'][field] else [""]
        for sub in subs:
            displayed_field = field + (":" if sub else "") + sub
            regex = re.compile("@([^@]*)@" + displayed_field + '@([^@]*)@')
            for prefix, postfix in set(regex.findall(template)):
                if sub == "value":
                    text = open(data['input'][field][sub], 'rb').read().decode('utf-8')
                elif sub:
                    text = data['input'][field][sub]
                else:
                    text = data['input'][field]
                rep = "\n".join([prefix + v + postfix for v in text.splitlines()])
                template = template.replace("@{0}@{1}@{2}@".format(prefix, displayed_field, postfix), rep)
    
    if output_filename == '':
        output_filename=input_filename
    
    # Ensure directory of resulting file exists
    try:
        os.makedirs(os.path.dirname(output_filename))
    except OSError as e:
        pass

    # Write file
    with open(output_filename, 'wb') as file:
        file.write(template.encode("utf-8"))
232435
def _get_val2_dict_from_diff_dict(diff_dict):
    '''
    
    '''
    ret_dict = {}
    for p in diff_dict.keys():
        if not isinstance(diff_dict[p], dict):
            raise ValueError('Unexpected diff difct \'{0}\''.format(diff_dict))
        if 'val2' in diff_dict[p].keys():
            ret_dict.update({p: diff_dict[p]['val2']})
        else:
            ret_dict.update(
                {p: _get_val2_dict_from_diff_dict(diff_dict[p])})
    return ret_dict
82890
def diff(self, obj=None):
        """"""
        if self.no_resource:
            return NOOP

        if not self.present:
            if self.existing:
                return DEL

            return NOOP

        if not obj:
            obj = self.obj()

        is_diff = NOOP
        if self.present and self.existing:
            if isinstance(self.existing, dict):
                current = dict(self.existing)
                if 'refresh_interval' in current:
                    del current['refresh_interval']

                if diff_dict(current, obj):
                    is_diff = CHANGED
            elif is_unicode(self.existing):
                if self.existing != obj:
                    is_diff = CHANGED

        elif self.present and not self.existing:
            is_diff = ADD

        return is_diff
734225
function expectedDiff(expected, computedStyles) {
  const received = Array.from(computedStyles)
    .filter(prop => expected[prop])
    .reduce(
      (obj, prop) =>
        Object.assign(obj, {[prop]: computedStyles.getPropertyValue(prop)}),
      {},
    )
  const diffOutput = jestDiff(
    printoutStyles(expected),
    printoutStyles(received),
  )
  // Remove the "+ Received" annotation because this is a one-way diff
  return diffOutput.replace(`${chalk.red('+ Received')}\n`, '')
}
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(''))
}
1202313
def diff(actual, expected):
    
    return '\n'.join(list(
        difflib.unified_diff(actual.splitlines(), expected.splitlines())
    ))
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)
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 {}
238357
def _extract_return(self, data):
        '''
        
        '''
        if isinstance(data, dict):
            data = data.get('return', data)

        return data
446170
def _parse_return(cls, result):
        

        return_value = None
        success = result['result']
        context = result['context']

        if 'return_value' in result:
            return_value = result['return_value']

        return success, return_value, context