def FormatCode(unformatted_source, filename='<unknown>', style_config=None, lines=None, print_diff=False, verify=False):
 _CheckPythonVersion()
 style.SetGlobalStyle(style.CreateStyleFromConfig(style_config))
 if (not unformatted_source.endswith('\n')):
  unformatted_source += '\n'
 tree = pytree_utils.ParseCodeToTree(unformatted_source)
 comment_splicer.SpliceComments(tree)
 continuation_splicer.SpliceContinuations(tree)
 subtype_assigner.AssignSubtypes(tree)
 split_penalty.ComputeSplitPenalties(tree)
 blank_line_calculator.CalculateBlankLines(tree)
 uwlines = pytree_unwrapper.UnwrapPyTree(tree)
 for uwl in uwlines:
  uwl.CalculateFormattingInformation()
 _MarkLinesToFormat(uwlines, lines)
 reformatted_source = reformatter.Reformat(uwlines, verify)
 if (unformatted_source == reformatted_source):
  return (('' if print_diff else reformatted_source), False)
 code_diff = _GetUnifiedDiff(unformatted_source, reformatted_source, filename=filename)
 if print_diff:
  return (code_diff, (code_diff != ''))
 return (reformatted_source, True)

def FormatCode ( unformatted_source , filename = '<unknown>' , style_config = None , lines = None , print_diff = False , verify = False ) : _CheckPythonVersion ( ) style . SetGlobalStyle ( style . CreateStyleFromConfig ( style_config ) ) if ( not unformatted_source . endswith ( '\n' ) ) : unformatted_source += '\n' tree = pytree_utils . ParseCodeToTree ( unformatted_source ) comment_splicer . SpliceComments ( tree ) continuation_splicer . SpliceContinuations ( tree ) subtype_assigner . AssignSubtypes ( tree ) split_penalty . ComputeSplitPenalties ( tree ) blank_line_calculator . CalculateBlankLines ( tree ) uwlines = pytree_unwrapper . UnwrapPyTree ( tree ) for uwl in uwlines : uwl . CalculateFormattingInformation ( ) _MarkLinesToFormat ( uwlines , lines ) reformatted_source = reformatter . Reformat ( uwlines , verify ) if ( unformatted_source == reformatted_source ) : return ( ( '' if print_diff else reformatted_source ) , False ) code_diff = _GetUnifiedDiff ( unformatted_source , reformatted_source , filename = filename ) if print_diff : return ( code_diff , ( code_diff != '' ) ) return ( reformatted_source , True )
format a string of python code .