Mapping Package

Submodules

seed.mappings.mapper module

seed.mappings.mapper.get_attr_source(field_values, value)

Return the first dictionary key that contains a value.

seed.mappings.mapper.get_building_attrs(data_set_buildings)

Returns a dictionary of attributes from each data_set_building.

Parameters:buildings – list, group of BS instances to merge.
Returns:BuildingSnapshot dict: possible attributes keyed on attr name.
seed.mappings.mapper.get_source_id(source_inst, attr)

Get the ID we save for our model source from models module.

seed.mappings.mapper.merge_building(snapshot, b1, b2, can_attrs, conf, default=None, match_type=None)

Set attributes on our Canonical model, saving differences.

Parameters:
  • snapshot – BuildingSnapshot model inst.
  • b1 – BuildingSnapshot model inst. Left parent.
  • b2 – BuildingSnapshot model inst. Right parent.
  • can_attrs – dict of dicts, {‘attr_name’: {‘dataset1’: ‘value’...}}.
  • default – (optional), which dataset’s value to default to.
Rtype default:

BuildingSnapshot

Returns:

inst(snapshot), updated.

seed.mappings.mapper.merge_extra_data(b1, b2, default=None)

Merge extra_data field between two BuildingSnapshots, return result.

Parameters:
  • b1 – BuildingSnapshot inst.
  • b2 – BuildingSnapshot inst.
  • default – BuildingSnapshot inst.
Returns tuple of dict:
 
seed.mappings.mapper.save_variant(snapshot, attr, attribute_values)

Save different options from each dataset for a Canonical field value.

Parameters:
  • snapshot – BuildingSnapshot inst.
  • attr – string, the disputed attribute on the can_building inst.
Attribute_values:
 

dict of obj:str. Keyed on datasource model instance.

seed.mappings.reconcile_mappings module

seed.mappings.seed_mappings module

How to map dataset attributes to CanonicalBuilding.

If the first element in the tuple is a callable, it will be passed a model instance for that type of mapping (AssessedBuilding for AssessedBuilding_to_CanonicalBuilding, etc.)

Module contents