#NEWLINE# def iterrename( source , spec , strict ) : #NEWLINE# #INDENT# it = iter ( source ) #NEWLINE# hdr = next ( it ) #NEWLINE# flds = list ( map ( text_type , hdr ) ) #NEWLINE# if strict : #NEWLINE# #INDENT# for x in spec : #NEWLINE# #INDENT# if isinstance ( x , int ) : #NEWLINE# #INDENT# if ( ( x < 0 ) or ( it >= len ( hdr ) ) ) : #NEWLINE# #INDENT# raise FieldSelectionError ( x ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( x not in flds ) : #NEWLINE# #INDENT# raise FieldSelectionError ( x ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# outhdr = [ ( spec [ i ] if ( i in spec ) else ( spec [ f ] if ( f in spec ) else f ) ) for ( i , f ) in enumerate ( flds ) ] #NEWLINE# ( yield tuple ( outhdr ) ) #NEWLINE# for row in it : #NEWLINE# #INDENT# ( yield tuple ( row ) )