@@ -124,7 +124,7 @@ def __init__(self):
124124 self ._default_logging_level = self ._logger .level
125125 self ._record_writer = None
126126 self ._records = None
127- self ._allow_empty_list = False
127+ self ._allow_empty_input = True
128128
129129 def __str__ (self ):
130130 text = ' ' .join (chain ((type (self ).name , str (self .options )), [] if self .fieldnames is None else self .fieldnames ))
@@ -414,7 +414,7 @@ def prepare(self):
414414 """
415415 pass
416416
417- def process (self , argv = sys .argv , ifile = sys .stdin , ofile = sys .stdout , allow_empty_list = False ):
417+ def process (self , argv = sys .argv , ifile = sys .stdin , ofile = sys .stdout , allow_empty_input = True ):
418418 """ Process data.
419419
420420 :param argv: Command line arguments.
@@ -426,15 +426,15 @@ def process(self, argv=sys.argv, ifile=sys.stdin, ofile=sys.stdout, allow_empty_
426426 :param ofile: Output data file.
427427 :type ofile: file
428428
429- :param allow_empty_list : Allow empty results
430- :type allow_empty_list : bool
429+ :param allow_empty_input : Allow empty input records for the command, if False an Error will be returned if empty chunk body is encountered when read
430+ :type allow_empty_input : bool
431431
432432 :return: :const:`None`
433433 :rtype: NoneType
434434
435435 """
436436
437- self ._allow_empty_list = allow_empty_list
437+ self ._allow_empty_input = allow_empty_input
438438
439439 if len (argv ) > 1 :
440440 self ._process_protocol_v1 (argv , ifile , ofile )
@@ -972,15 +972,14 @@ def _execute_v2(self, ifile, process):
972972 def _execute_chunk_v2 (self , process , chunk ):
973973 metadata , body = chunk
974974
975- if len (body ) <= 0 and not self ._allow_empty_list :
975+ if len (body ) <= 0 and not self ._allow_empty_input :
976976 raise ValueError (
977- "No records found to process. Set _allow_empty_list =True in dispatch function to move forward "
977+ "No records found to process. Set allow_empty_input =True in dispatch function to move forward "
978978 "with empty records." )
979979
980980 records = self ._read_csv_records (StringIO (body ))
981981 self ._record_writer .write_records (process (records ))
982982
983-
984983 def _report_unexpected_error (self ):
985984
986985 error_type , error , tb = sys .exc_info ()
@@ -1072,7 +1071,7 @@ def iteritems(self):
10721071SearchMetric = namedtuple ('SearchMetric' , ('elapsed_seconds' , 'invocation_count' , 'input_count' , 'output_count' ))
10731072
10741073
1075- def dispatch (command_class , argv = sys .argv , input_file = sys .stdin , output_file = sys .stdout , module_name = None , allow_empty_list = False ):
1074+ def dispatch (command_class , argv = sys .argv , input_file = sys .stdin , output_file = sys .stdout , module_name = None , allow_empty_input = True ):
10761075 """ Instantiates and executes a search command class
10771076
10781077 This function implements a `conditional script stanza <https://docs.python.org/2/library/__main__.html>`_ based on the value of
@@ -1095,6 +1094,8 @@ def dispatch(command_class, argv=sys.argv, input_file=sys.stdin, output_file=sys
10951094 :type output_file: :code:`file`
10961095 :param module_name: Name of the module calling :code:`dispatch` or :const:`None`.
10971096 :type module_name: :code:`basestring`
1097+ :param allow_empty_input: Allow empty input records for the command, if False an Error will be returned if empty chunk body is encountered when read
1098+ :type allow_empty_input: bool
10981099 :returns: :const:`None`
10991100
11001101 **Example**
@@ -1132,4 +1133,4 @@ def stream(records):
11321133 assert issubclass (command_class , SearchCommand )
11331134
11341135 if module_name is None or module_name == '__main__' :
1135- command_class ().process (argv , input_file , output_file , allow_empty_list )
1136+ command_class ().process (argv , input_file , output_file , allow_empty_input )
0 commit comments