示例#1
0
 def map_to_resource(self, data_element):
     trv = DataElementTreeTraverser(data_element,
                                    self,
                                    direction=PROCESSING_DIRECTIONS.READ)
     visitor = ResourceBuilderDataElementTreeVisitor()
     trv.run(visitor)
     return visitor.resource
示例#2
0
 def run(self, data_element):
     trv = DataElementTreeTraverser(data_element, self._mapping,
                                    direction=PROCESSING_DIRECTIONS.WRITE)
     vst = JsonDataElementTreeVisitor()
     trv.run(vst)
     rpr_string = dumps(vst.json_data)
     self._stream.write(rpr_string)
示例#3
0
 def run(self, data_element):
     trv = DataElementTreeTraverser(data_element,
                                    self._mapping,
                                    direction=PROCESSING_DIRECTIONS.WRITE)
     vst = JsonDataElementTreeVisitor()
     trv.run(vst)
     rpr_string = dumps(vst.json_data)
     self._stream.write(rpr_string)
示例#4
0
文件: csv.py 项目: helixyte/everest
 def run(self, data_element):
     # We also emit None values to make sure every data row has the same
     # number of fields.
     trv = DataElementTreeTraverser(data_element, self._mapping,
                                    ignore_none_values=False)
     vst = CsvDataElementTreeVisitor(self.get_option('encoding'))
     trv.run(vst)
     csv_data = vst.csv_data
     if len(csv_data) > 0:
         wrt = writer(self._stream, dialect=self.get_option('dialect'))
         wrt.writerow(csv_data.fields)
         for row_data in csv_data.data:
             wrt.writerow(row_data)
示例#5
0
文件: csv.py 项目: papagr/everest
 def run(self, data_element):
     # We also emit None values to make sure every data row has the same
     # number of fields.
     trv = DataElementTreeTraverser(data_element,
                                    self._mapping,
                                    ignore_none_values=False)
     vst = CsvDataElementTreeVisitor(self.get_option('encoding'))
     trv.run(vst)
     csv_data = vst.csv_data
     if len(csv_data) > 0:
         wrt = writer(self._stream, dialect=self.get_option('dialect'))
         wrt.writerow(csv_data.fields)
         for row_data in csv_data.data:
             wrt.writerow(row_data)
示例#6
0
文件: json.py 项目: helixyte/everest
 def run(self, data_element):
     trv = DataElementTreeTraverser(data_element, self._mapping)
     vst = JsonDataElementTreeVisitor()
     trv.run(vst)
     rpr_string = dumps(vst.json_data)
     self._stream.write(rpr_string)
示例#7
0
文件: json.py 项目: papagr/everest
 def run(self, data_element):
     trv = DataElementTreeTraverser(data_element, self._mapping)
     vst = JsonDataElementTreeVisitor()
     trv.run(vst)
     rpr_string = dumps(vst.json_data)
     self._stream.write(rpr_string)
示例#8
0
 def map_to_resource(self, data_element):
     trv = DataElementTreeTraverser(data_element, self,
                                    direction=PROCESSING_DIRECTIONS.READ)
     visitor = ResourceBuilderDataElementTreeVisitor()
     trv.run(visitor)
     return visitor.resource
 def test_mapping_invalid_dataelement_raises_error(self):
     invalid_de = InvalidKindDataElement()
     invalid_de.mapping = self.mapping  # pylint: disable=W0201
     also_provides(invalid_de, IDataElement)
     trv = DataElementTreeTraverser(invalid_de, self.mapping.as_pruning())
     self.assert_raises(ValueError, trv.run, None)