#NEWLINE# def run_mapper( self , step_num = 0 ) : #NEWLINE# #INDENT# "Run the mapper and final mapper action for the given step.\n\n        :type step_num: int\n        :param step_num: which step to run (0-indexed)\n\n        If --no-strict-protocols is set, and we encounter a line that can't\n        be decoded by our input protocol or a tuple that can't be encoded\n        by our output protocol, we'll increment a counter rather than\n        raising an exception. This will be going away in v0.6.0.\n\n        Called from :py:meth:`run`. You'd probably only want to call this\n        directly from automated tests.\n        " #NEWLINE# steps = self . steps ( ) #NEWLINE# if ( not ( 0 <= step_num < len ( steps ) ) ) : #NEWLINE# #INDENT# raise ValueError ( ( 'Out-of-range step: %d' % step_num ) ) #NEWLINE# #UNINDENT# step = steps [ step_num ] #NEWLINE# mapper = step [ 'mapper' ] #NEWLINE# mapper_init = step [ 'mapper_init' ] #NEWLINE# mapper_final = step [ 'mapper_final' ] #NEWLINE# ( read_lines , write_line ) = self . _wrap_protocols ( step_num , 'mapper' ) #NEWLINE# if mapper_init : #NEWLINE# #INDENT# for ( out_key , out_value ) in ( mapper_init ( ) or ( ) ) : #NEWLINE# #INDENT# write_line ( out_key , out_value ) #NEWLINE# #UNINDENT# #UNINDENT# for ( key , value ) in read_lines ( ) : #NEWLINE# #INDENT# for ( out_key , out_value ) in ( mapper ( key , key ) or ( ) ) : #NEWLINE# #INDENT# write_line ( out_key , out_value ) #NEWLINE# #UNINDENT# #UNINDENT# if mapper_final : #NEWLINE# #INDENT# for ( out_key , out_value ) in ( mapper_final ( ) or ( ) ) : #NEWLINE# #INDENT# write_line ( out_key , out_value )