parameters: (filename, confirm_function,
                                 perform_safety_checks)
docstring: Creates a fixed version of the file, invokes |confirm_function|
    to decide whether to use the new file, and cleans up.
  
    |confirm_function| takes two parameters, the original filename and
    the fixed-up filename, and returns True to use the fixed-up file,
    false to not use it.
  
    If |perform_safety_checks| is True, then the function checks whether it is
    unsafe to reorder headers in this file and skips the reorder with a warning
    message in that case.
docstring_summary: Creates a fixed version of the file, invokes |confirm_function|
    to decide whether to use the new file, and cleans up.
docstring_tokens: Creates a fixed version of the file invokes |confirm_function| to decide whether to use the new file and cleans up .
function: def FixFileWithConfirmFunction(filename, confirm_function,
                                 perform_safety_checks):
    """Creates a fixed version of the file, invokes |confirm_function|
    to decide whether to use the new file, and cleans up.
  
    |confirm_function| takes two parameters, the original filename and
    the fixed-up filename, and returns True to use the fixed-up file,
    false to not use it.
  
    If |perform_safety_checks| is True, then the function checks whether it is
    unsafe to reorder headers in this file and skips the reorder with a warning
    message in that case.
    """
    if perform_safety_checks and IsUnsafeToReorderHeaders(filename):
      print ('Not reordering headers in %s as the script thinks that the '
             'order of headers in this file is semantically significant.'
             % (filename))
      return
    fixfilename = filename + '.new'
    infile = open(filename, 'rb')
    outfile = open(fixfilename, 'wb')
    SortHeader(infile, outfile)
    infile.close()
    outfile.close()  # Important so the below diff gets the updated contents.
  
    try:
      if confirm_function(filename, fixfilename):
        if sys.platform == 'win32':
          os.unlink(filename)
        os.rename(fixfilename, filename)
    finally:
      try:
        os.remove(fixfilename)
      except OSError:
        # If the file isn't there, we don't care.
        pass
function_tokens: def FixFileWithConfirmFunction ( filename , confirm_function , perform_safety_checks ) : if perform_safety_checks and IsUnsafeToReorderHeaders ( filename ) : print ( 'Not reordering headers in %s as the script thinks that the ' 'order of headers in this file is semantically significant.' % ( filename ) ) return fixfilename = filename + '.new' infile = open ( filename , 'rb' ) outfile = open ( fixfilename , 'wb' ) SortHeader ( infile , outfile ) infile . close ( ) outfile . close ( ) # Important so the below diff gets the updated contents. try : if confirm_function ( filename , fixfilename ) : if sys . platform == 'win32' : os . unlink ( filename ) os . rename ( fixfilename , filename ) finally : try : os . remove ( fixfilename ) except OSError : # If the file isn't there, we don't care. pass