tools/clang/scripts/apply_edits.py
def _ParseEditsFromStdin(build_directory):
  """Extracts generated list of edits from the tool's stdout.

  The expected format is documented at the top of this file.

  Args:
    build_directory: Directory that contains the compile database. Used to
      normalize the filenames.
    stdout: The stdout from running the clang tool.

  Returns:
    A dictionary mapping filenames to the associated edits.
  """
  path_to_resolved_path = {}
  def _ResolvePath(path):
    if path in path_to_resolved_path:
      return path_to_resolved_path[path]

    if not os.path.isfile(path):
      resolved_path = os.path.realpath(os.path.join(build_directory, path))
    else:
      resolved_path = os.path.realpath(path)

    if not os.path.isfile(resolved_path):
      sys.stderr.write('Edit applies to a non-existent file: %s\n' % path)
      resolved_path = None

    path_to_resolved_path[path] = resolved_path
    return resolved_path

  edits = collections.defaultdict(list)
  for line in sys.stdin:
    line = line.rstrip("\n\r")
    try:
      edit_type, path, offset, length, replacement = line.split(':::', 4)
      replacement = replacement.replace('\0', '\n')
      path = _ResolvePath(path)
      if not path: continue
      edits[path].append(Edit(edit_type, int(offset), int(length), replacement))
    except ValueError:
      sys.stderr.write('Unable to parse edit: %s\n' % line)
  return edits
Extracts generated list of edits from the tool's stdout.

  The expected format is documented at the top of this file.

  Args:
    build_directory: Directory that contains the compile database. Used to
      normalize the filenames.
    stdout: The stdout from running the clang tool.

  Returns:
    A dictionary mapping filenames to the associated edits.
  
Extracts generated list of edits from the tool's stdout.
The expected format is documented at the top of this file.
Extracts generated list of edits from the tool ' s stdout . The expected format is documented at the top of this file .
def _ParseEditsFromStdin(build_directory):
  path_to_resolved_path = {}
  def _ResolvePath(path):
    if path in path_to_resolved_path:
      return path_to_resolved_path[path]
    if not os.path.isfile(path):
      resolved_path = os.path.realpath(os.path.join(build_directory, path))
    else:
      resolved_path = os.path.realpath(path)
    if not os.path.isfile(resolved_path):
      sys.stderr.write('Edit applies to a non-existent file: %s\n' % path)
      resolved_path = None
    path_to_resolved_path[path] = resolved_path
    return resolved_path
  edits = collections.defaultdict(list)
  for line in sys.stdin:
    line = line.rstrip("\n\r")
    try:
      edit_type, path, offset, length, replacement = line.split(':::', 4)
      replacement = replacement.replace('\0', '\n')
      path = _ResolvePath(path)
      if not path: continue
      edits[path].append(Edit(edit_type, int(offset), int(length), replacement))
    except ValueError:
      sys.stderr.write('Unable to parse edit: %s\n' % line)
  return edits
def _ParseEditsFromStdin ( build_directory ) : path_to_resolved_path = { } def _ResolvePath ( path ) : if path in path_to_resolved_path : return path_to_resolved_path [ path ] if not os . path . isfile ( path ) : resolved_path = os . path . realpath ( os . path . join ( build_directory , path ) ) else : resolved_path = os . path . realpath ( path ) if not os . path . isfile ( resolved_path ) : sys . stderr . write ( 'Edit applies to a non-existent file: %s\n' % path ) resolved_path = None path_to_resolved_path [ path ] = resolved_path return resolved_path edits = collections . defaultdict ( list ) for line in sys . stdin : line = line . rstrip ( "\n\r" ) try : edit_type , path , offset , length , replacement = line . split ( ':::' , 4 ) replacement = replacement . replace ( '\0' , '\n' ) path = _ResolvePath ( path ) if not path : continue edits [ path ] . append ( Edit ( edit_type , int ( offset ) , int ( length ) , replacement ) ) except ValueError : sys . stderr . write ( 'Unable to parse edit: %s\n' % line ) return edits
Extracts generated list of edits from the tool's stdout.
Extracts generated list of edits from the tool ' s stdout .
"""Extracts generated list of edits from the tool's stdout.

  The expected format is documented at the top of this file.

  Args:
    build_directory: Directory that contains the compile database. Used to
      normalize the filenames.
    stdout: The stdout from running the clang tool.

  Returns:
    A dictionary mapping filenames to the associated edits.
  """
A dictionary mapping filenames to the associated edits.
A dictionary mapping filenames to the associated edits .
build_directory
Directory that contains the compile database. Used to
normalize the filenames.
Directory that contains the compile database . Used to normalize the filenames .
stdout
The stdout from running the clang tool.
The stdout from running the clang tool .