#NEWLINE# def _generate_parts( self ) : #NEWLINE# #INDENT# 'Return a list of callables that can be composed to build a query generator' #NEWLINE# tokens = self . tokens #NEWLINE# parts = [ ] #NEWLINE# self . column_classes = ( [ self . _column_builder ( c ) for c in tokens . columns ] if ( tokens . columns != '*' ) else None ) #NEWLINE# if ( not isinstance ( tokens . tables [ 0 ] [ 0 ] , basestring ) ) : #NEWLINE# #INDENT# self . _table_subquery = Query ( tokens . tables [ 0 ] [ 0 ] ) #NEWLINE# #UNINDENT# if tokens . where : #NEWLINE# #INDENT# func = eval ( ( 'lambda row:' + self . _filter_builder ( tokens . where ) ) ) #NEWLINE# parts . append ( partial ( Filter , function = func ) ) #NEWLINE# #UNINDENT# if tokens . groupby : #NEWLINE# #INDENT# parts . append ( partial ( GroupBy , group_by = [ c [ 0 ] for c in tokens . groupby ] , columns = self . column_classes ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( self . column_classes and any ( ( ( len ( c . name ) > 1 ) for c in tokens . columns ) ) ) : #NEWLINE# #INDENT# parts . append ( partial ( Aggregator , columns = self . column_classes ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# parts . append ( partial ( Selector , columns = ( [ ( c . name [ 0 ] , c . alias ) for c in tokens . columns ] if ( tokens . columns != '*' ) else None ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# if tokens . orderby : #NEWLINE# #INDENT# order = tokens . orderby #NEWLINE# parts . append ( partial ( OrderBy , order_by = order [ 0 ] [ 0 ] , descending = ( ( order [ 1 ] == 'DESC' ) if ( len ( order ) > 1 ) else False ) ) ) #NEWLINE# #UNINDENT# if ( tokens . limit or tokens . offset ) : #NEWLINE# #INDENT# parts . append ( partial ( LimitOffset , limit = ( int ( tokens . limit ) if tokens . limit else None ) , offset = ( int ( tokens . offset ) if tokens . offset else 0 ) ) ) #NEWLINE# #UNINDENT# return parts