Library Packages


Exporter Module

class seed.lib.exporter.Exporter(export_id, export_name, export_type)

Class to handle the exporting of buildings

export(buildings, fields, row_cb)

The main method of export. Uses the export type defined by the initializer

  • buildings – Array of building ids to export
  • fields – Array of fields to export
  • row_cb – ID for row cache

export_csv(qs, fields=[], cb=None)
export_xls(qs, fields=[], cb=None)
static fields_from_queryset(qs)

Creates a list of all accessible fields on a model based off of a queryset.

This method should not be here. It seems that is should be on the building snapshot model. Not moved yet because I am unsure if the qs argument is more than one data type (i.e. BuildingSnapshot and/or ?)


The expected file name based on the export_id, export_name, and export_type

Returns:String of the expected filename

Create and return the subdirectory

Returns:String of the subdirectory
static subdirectory_from_export_id(export_id)

Return the subdirectory as constructed by the instance method.

Parameters:export_id – The export ID
Returns:String of the path to the exported file
tempfile = None
seed.lib.exporter.batch_qs(qs, batch_size=1000)


Returns a (start, end, total, queryset) tuple for each batch in the given queryset.


seed.lib.exporter.construct_obj_row(obj, fields)

Creates an exportable row of data from an object and a list of fields. Ignores nones and instances of the Django Manager object, replacing them with blank unicode strings.

seed.lib.exporter.get_field_name_from_model(field, model)

Takes a field name like “building_snapshot__state” and returns the verbose field name as set in django, to be used as the header in exported files.

  • field
  • qs

seed.lib.exporter.get_field_value_from_instance(field, obj)

Does some deep diving to find the right value given a string like “building_snapshot__state”

seed.lib.exporter.qs_to_rows(qs, fields)

Module contents