#NEWLINE# def elements( self ) : #NEWLINE# #INDENT# if ( not self . parser ) : #NEWLINE# #INDENT# reader = self . stream . reader #NEWLINE# class f ( object ) : #NEWLINE# #INDENT# def read( self , n ) : #NEWLINE# #INDENT# if ( reader . buffer . remaining == 0 ) : #NEWLINE# #INDENT# reader . _read_more ( ) #NEWLINE# #UNINDENT# return reader . buffer . read_bytes ( min ( n , reader . buffer . remaining ) ) #NEWLINE# #UNINDENT# #UNINDENT# self . parser = iter ( iterparse ( f ( ) , events = ( 'start' , 'end' ) ) ) #NEWLINE# ( event , self . root ) = self . parser . next ( ) #NEWLINE# level = 0 #NEWLINE# #UNINDENT# for ( event , element ) in self . parser : #NEWLINE# #INDENT# if ( event == 'start' ) : #NEWLINE# #INDENT# level += 1 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( event == 'end' ) : #NEWLINE# #INDENT# level -= 1 #NEWLINE# if ( reader == 0 ) : #NEWLINE# #INDENT# ( yield element ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# assert False , 'unexpected event'