parameters: (self, new_text, filename, old_text, encoding=None)
docstring: Writes a string to a file.
  
          It first shows a unified diff between the old text and the new text, and
          then rewrites the file; the latter is only done if the write option is
          set.
docstring_summary: Writes a string to a file.
docstring_tokens: Writes a string to a file .
function: def write_file(self, new_text, filename, old_text, encoding=None):
          """Writes a string to a file.
  
          It first shows a unified diff between the old text and the new text, and
          then rewrites the file; the latter is only done if the write option is
          set.
          """
          try:
              fp = io.open(filename, "w", encoding=encoding, newline='')
          except OSError as err:
              self.log_error("Can't create %s: %s", filename, err)
              return
  
          with fp:
              try:
                  fp.write(new_text)
              except OSError as err:
                  self.log_error("Can't write %s: %s", filename, err)
          self.log_debug("Wrote changes to %s", filename)
          self.wrote = True
function_tokens: def write_file ( self , new_text , filename , old_text , encoding = None ) : try : fp = io . open ( filename , "w" , encoding = encoding , newline = '' ) except OSError as err : self . log_error ( "Can't create %s: %s" , filename , err ) return with fp : try : fp . write ( new_text ) except OSError as err : self . log_error ( "Can't write %s: %s" , filename , err ) self . log_debug ( "Wrote changes to %s" , filename ) self . wrote = True