def FormatFile(filename, style_config=None, lines=None, print_diff=False, verify=False, in_place=False, logger=None):
 _CheckPythonVersion()
 if (in_place and print_diff):
  raise ValueError('Cannot pass both in_place and print_diff.')
 (original_source, newline, encoding) = ReadFile(filename, logger)
 (reformatted_source, changed) = FormatCode(original_source, style_config=style_config, filename=filename, lines=lines, print_diff=print_diff, verify=verify)
 if reformatted_source.rstrip('\n'):
  lines = reformatted_source.rstrip('\n').split('\n')
  reformatted_source = (newline.join((line for line in lines)) + newline)
 if in_place:
  if (original_source and (original_source != reformatted_source)):
   file_resources.WriteReformattedCode(filename, reformatted_source, in_place, encoding)
  return (None, encoding, changed)
 return (reformatted_source, encoding, changed)

def FormatFile ( filename , style_config = None , lines = None , print_diff = False , verify = False , in_place = False , logger = None ) : _CheckPythonVersion ( ) if ( in_place and print_diff ) : raise ValueError ( 'Cannot pass both in_place and print_diff.' ) ( original_source , newline , encoding ) = ReadFile ( filename , logger ) ( reformatted_source , changed ) = FormatCode ( original_source , style_config = style_config , filename = filename , lines = lines , print_diff = print_diff , verify = verify ) if reformatted_source . rstrip ( '\n' ) : lines = reformatted_source . rstrip ( '\n' ) . split ( '\n' ) reformatted_source = ( newline . join ( ( line for line in lines ) ) + newline ) if in_place : if ( original_source and ( original_source != reformatted_source ) ) : file_resources . WriteReformattedCode ( filename , reformatted_source , in_place , encoding ) return ( None , encoding , changed ) return ( reformatted_source , encoding , changed )
format a single python file and return the formatted code .