Esempio n. 1
0
 def _parse_any(self,
                anything,
                on_demand=False,
                file_type=None,
                **keywords):
     if on_demand:
         sheets, reader = iget_data(anything,
                                    file_type=file_type,
                                    **keywords)
         self._free_me_up_later(reader)
     else:
         sheets = get_data(anything, file_type=file_type, **keywords)
     return sheets
Esempio n. 2
0
 def parse_db(self, argument,
              export_columns_list=None, on_demand=False,
              **keywords):
     session, tables = argument
     exporter = sql.SQLTableExporter(session)
     if export_columns_list is None:
         export_columns_list = [None] * len(tables)
     for table, export_columns in zip(tables, export_columns_list):
         adapter = sql.SQLTableExportAdapter(table, export_columns)
         exporter.append(adapter)
     if on_demand:
         sheets, _ = iget_data(
             exporter, file_type=self._file_type, **keywords)
     else:
         sheets = get_data(exporter, file_type=self._file_type, **keywords)
     return sheets
Esempio n. 3
0
 def parse_db(self, argument,
              export_columns_list=None, on_demand=True,
              **keywords):
     models = argument
     exporter = django.DjangoModelExporter()
     if export_columns_list is None:
         export_columns_list = [None] * len(models)
     for model, export_columns in zip(models, export_columns_list):
         adapter = django.DjangoModelExportAdapter(model, export_columns)
         exporter.append(adapter)
     if on_demand:
         sheets, _ = iget_data(
             exporter, file_type=self._file_type, **keywords)
     else:
         sheets = get_data(exporter, file_type=self._file_type, **keywords)
     return sheets
Esempio n. 4
0
 def parse_db(self,
              argument,
              export_columns_list=None,
              on_demand=False,
              **keywords):
     session, tables = argument
     exporter = sql.SQLTableExporter(session)
     if export_columns_list is None:
         export_columns_list = [None] * len(tables)
     for table, export_columns in zip(tables, export_columns_list):
         adapter = sql.SQLTableExportAdapter(table, export_columns)
         exporter.append(adapter)
     if on_demand:
         sheets, _ = iget_data(exporter,
                               file_type=self._file_type,
                               **keywords)
     else:
         sheets = get_data(exporter, file_type=self._file_type, **keywords)
     return sheets
Esempio n. 5
0
def test_generator_is_obtained():
    data, reader = iget_data(os.path.join("tests", "fixtures", "test.csv"))
    assert isinstance(data["test.csv"], types.GeneratorType)
    reader.close()