def generate_output_items(self):
     # type: () -> Iterator[NameValuePair]
     for (output_name, converted_value_cell
          ) in self._output_name_to_converted_value_cell.items():
         possible_input_names = self.iter_input_names_for_output_name(
             output_name)
         with DataConversionError.sublocation(possible_input_names):
             yield output_name, converted_value_cell.output
示例#2
0
 def __call__(self, data):
     # type: (Value) -> Iterator
     with self.state_bookkeeper_context() as bookkeeper:
         input_name_value_pairs = self.generate_input_name_value_pairs(data)
         input_name_value_pairs = self.validate_input_names(
             input_name_value_pairs)
         input_name_value_pairs = bookkeeper.preprocess_input_items(
             input_name_value_pairs)
         for input_name, input_value in input_name_value_pairs:
             with DataConversionError.sublocation(input_name):
                 item_conv = self._input_name_to_converter.get(
                     input_name, self._free_item_converter)
                 for output_name, converted_value_cell in item_conv(
                     (input_name, input_value)):
                     bookkeeper.collect_converted_item(
                         input_name, output_name, converted_value_cell)
         bookkeeper.verify_required_input_items_collected(
             self._required_input_names)
         output_name_value_pairs = bookkeeper.generate_output_items()
         for assembled_data in self._assembling_converter(
                 output_name_value_pairs):
             yield assembled_data
示例#3
0
 def generate_output_elements(self, input_elements):
     # type: (Iterator[Value]) -> Iterator[Value]
     for index, value in enumerate(input_elements):
         with DataConversionError.sublocation(index):
             for converted_value in self._element_converter(value):
                 yield converted_value