#NEWLINE# def _apply_handlebars( self , q , data , union = True ) : #NEWLINE# #INDENT# if ( sys . version_info < ( 3 , 0 ) ) : #NEWLINE# #INDENT# q = unicode ( q ) #NEWLINE# #UNINDENT# template = self . handlebars . compile ( q ) #NEWLINE# if isinstance ( data , list ) : #NEWLINE# #INDENT# query = [ template ( item ) for item in data ] #NEWLINE# query = [ str ( item ) for item in query ] #NEWLINE# if ( union == True ) : #NEWLINE# #INDENT# query = '\nUNION ALL' . join ( query ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# query = '\n' . join ( query ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( data , dict ) : #NEWLINE# #INDENT# query = template ( data ) #NEWLINE# query = str ( query ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return q #NEWLINE# #UNINDENT# #UNINDENT# return query