#NEWLINE# def format( sql , **options ) : #NEWLINE# #INDENT# 'Format *sql* according to *options*.\n\n    Available options are documented in :ref:`formatting`.\n\n    In addition to the formatting options this function accepts the\n    keyword "encoding" which determines the encoding of the statement.\n\n    :returns: The formatted SQL statement as string.\n    ' #NEWLINE# encoding = options . pop ( 'encoding' , None ) #NEWLINE# stack = engine . FilterStack ( ) #NEWLINE# options = formatter . validate_options ( stack ) #NEWLINE# stack = formatter . build_filter_stack ( stack , options ) #NEWLINE# stack . postprocess . append ( filters . SerializerUnicode ( ) ) #NEWLINE# return '' . join ( stack . run ( sql , encoding ) )