#NEWLINE# def __new__( cls , func , sentinel = '' ) : #NEWLINE# #INDENT# if ( greenlet is None ) : #NEWLINE# #INDENT# raise RuntimeError ( 'IterI requires greenlet support' ) #NEWLINE# #UNINDENT# stream = object . __new__ ( cls ) #NEWLINE# stream . _parent = greenlet . getcurrent ( ) #NEWLINE# stream . _buffer = [ ] #NEWLINE# stream . closed = False #NEWLINE# stream . sentinel = sentinel #NEWLINE# stream . pos = 0 #NEWLINE# def run( ) : #NEWLINE# #INDENT# func ( stream ) #NEWLINE# stream . close ( ) #NEWLINE# #UNINDENT# g = greenlet . greenlet ( g , stream . _parent ) #NEWLINE# while 1 : #NEWLINE# #INDENT# rv = g . switch ( ) #NEWLINE# if ( not rv ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# ( yield rv [ 0 ] )