#NEWLINE# def append_node( self , nodecls , * args , **kwargs ) : #NEWLINE# #INDENT# kwargs . setdefault ( 'source' , self . text ) #NEWLINE# kwargs . setdefault ( 'lineno' , self . matched_lineno ) #NEWLINE# kwargs . setdefault ( 'pos' , self . matched_charpos ) #NEWLINE# kwargs [ 'filename' ] = self . filename #NEWLINE# node = nodecls ( * args , ** kwargs ) #NEWLINE# if len ( self . tag ) : #NEWLINE# #INDENT# self . tag [ ( - 1 ) ] . nodes . append ( node ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . template . nodes . append ( node ) #NEWLINE# #UNINDENT# if self . control_line : #NEWLINE# #INDENT# control_frame = self . control_line [ ( - 1 ) ] #NEWLINE# control_frame . nodes . append ( node ) #NEWLINE# if ( not ( isinstance ( node , parsetree . ControlLine ) and control_frame . is_ternary ( node . keyword ) ) ) : #NEWLINE# #INDENT# if ( self . ternary_stack and self . ternary_stack [ ( - 1 ) ] ) : #NEWLINE# #INDENT# self . ternary_stack [ ( - 1 ) ] [ ( - 1 ) ] . nodes . append ( node ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if isinstance ( node , parsetree . Tag ) : #NEWLINE# #INDENT# if len ( self . tag ) : #NEWLINE# #INDENT# node . parent = self . tag [ ( - 1 ) ] #NEWLINE# #UNINDENT# self . tag . append ( node ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( node , parsetree . ControlLine ) : #NEWLINE# #INDENT# if node . isend : #NEWLINE# #INDENT# self . control_line . pop ( ) #NEWLINE# self . ternary_stack . pop ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if node . is_primary : #NEWLINE# #INDENT# self . control_line . append ( node ) #NEWLINE# self . ternary_stack . append ( [ ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( self . control_line and self . control_line [ ( - 1 ) ] . is_ternary ( node . keyword ) ) : #NEWLINE# #INDENT# self . ternary_stack [ ( - 1 ) ] . append ( node ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( self . control_line and ( not self . control_line [ ( - 1 ) ] . is_ternary ( kwargs . keyword ) ) ) : #NEWLINE# #INDENT# raise exceptions . SyntaxException ( ( "Keyword '%s' not a legal ternary for keyword '%s'" % ( node . keyword , self . control_line [ ( - 1 ) ] . keyword ) ) , ** self . exception_kwargs )