#NEWLINE# def tokens( self , event , next ) : #NEWLINE# #INDENT# ( kind , data , pos ) = event #NEWLINE# if ( kind == START ) : #NEWLINE# #INDENT# ( tag , attribs ) = data #NEWLINE# name = tag . localname #NEWLINE# namespace = tag . namespace #NEWLINE# converted_attribs = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for ( k , v ) in attribs : #NEWLINE# #INDENT# if isinstance ( k , QName ) : #NEWLINE# #INDENT# converted_attribs [ ( k . namespace , k . localname ) ] = v #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# converted_attribs [ ( None , k ) ] = v #NEWLINE# #UNINDENT# #UNINDENT# if ( ( namespace == namespaces [ 'html' ] ) and ( name in voidElements ) ) : #NEWLINE# #INDENT# for token in self . emptyTag ( namespace , name , converted_attribs , ( ( not next ) or ( next [ 0 ] != END ) or ( next [ 1 ] != event ) ) ) : #NEWLINE# #INDENT# ( yield token ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# ( yield self . startTag ( namespace , name , converted_attribs ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( kind == END ) : #NEWLINE# #INDENT# name = data . localname #NEWLINE# namespace = data . namespace #NEWLINE# if ( name not in voidElements ) : #NEWLINE# #INDENT# ( yield self . endTag ( namespace , name ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( kind == COMMENT ) : #NEWLINE# #INDENT# ( yield self . comment ( data ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( kind == TEXT ) : #NEWLINE# #INDENT# for token in self . text ( data ) : #NEWLINE# #INDENT# ( yield token ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( kind == DOCTYPE ) : #NEWLINE# #INDENT# ( yield self . doctype ( * data ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( kind in ( XML_NAMESPACE , DOCTYPE , START_NS , END_NS , START_CDATA , END_CDATA , PI ) ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ( yield self . unknown ( kind ) )