ppapi/generate_ppapi_size_checks.py
def Apply(self):
    """Apply the patch by writing it to self.filename."""
    # Read the lines of the existing file in to a list.
    sourcefile = open(self.filename, "r")
    file_lines = sourcefile.readlines()
    sourcefile.close()
    # Now apply the patch.  Our strategy is to keep the array at the same size,
    # and just edit strings in the file_lines list as necessary.  When we delete
    # lines, we just blank the line and keep it in the list.  When we add lines,
    # we just prepend the added source code to the start of the existing line at
    # that line number.  This way, all the line numbers we cached from calls to
    # Add and Delete remain valid list indices, and we don't have to worry about
    # maintaining any offsets.  Each element of file_lines at the end may
    # contain any number of lines (0 or more) delimited by carriage returns.
    for linenum_to_delete in self.linenums_to_delete:
      file_lines[linenum_to_delete] = "";
    for linenum, sourcelines in self.lines_to_add.items():
      # Sort the lines we're adding so we get relatively consistent results.
      sourcelines.sort()
      # Prepend the new lines.  When we output
      file_lines[linenum] = "".join(sourcelines) + file_lines[linenum]
    newsource = open(self.filename, "w")
    for line in file_lines:
      newsource.write(line)
    newsource.close()
Apply the patch by writing it to self.filename.
Apply the patch by writing it to self.filename.
Apply the patch by writing it to self . filename .
def Apply(self):
    sourcefile = open(self.filename, "r")
    file_lines = sourcefile.readlines()
    sourcefile.close()
    for linenum_to_delete in self.linenums_to_delete:
      file_lines[linenum_to_delete] = "";
    for linenum, sourcelines in self.lines_to_add.items():
      sourcelines.sort()
      file_lines[linenum] = "".join(sourcelines) + file_lines[linenum]
    newsource = open(self.filename, "w")
    for line in file_lines:
      newsource.write(line)
    newsource.close()
def Apply ( self ) : sourcefile = open ( self . filename , "r" ) file_lines = sourcefile . readlines ( ) sourcefile . close ( ) for linenum_to_delete in self . linenums_to_delete : file_lines [ linenum_to_delete ] = "" ; for linenum , sourcelines in self . lines_to_add . items ( ) : sourcelines . sort ( ) file_lines [ linenum ] = "" . join ( sourcelines ) + file_lines [ linenum ] newsource = open ( self . filename , "w" ) for line in file_lines : newsource . write ( line ) newsource . close ( )
Apply the patch by writing it to self.filename.
Apply the patch by writing it to self . filename .
"""Apply the patch by writing it to self.filename.""" # Read the lines of the existing file in to a list. # Now apply the patch.  Our strategy is to keep the array at the same size, # and just edit strings in the file_lines list as necessary.  When we delete # lines, we just blank the line and keep it in the list.  When we add lines, # we just prepend the added source code to the start of the existing line at # that line number.  This way, all the line numbers we cached from calls to # Add and Delete remain valid list indices, and we don't have to worry about # maintaining any offsets.  Each element of file_lines at the end may # contain any number of lines (0 or more) delimited by carriage returns. # Sort the lines we're adding so we get relatively consistent results. # Prepend the new lines.  When we output
self