seed.mappings package

Submodules

seed.mappings.mapper module

:copyright (c) 2014 - 2015, The Regents of the University of California, through Lawrence Berkeley National Laboratory (subject to receipt of any required approvals from the U.S. Department of Energy) and contributors. All rights reserved. # NOQA :author

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.
Rtype BuildingSnapshot dict:
 possible attributes keyed on attr name. Ex: {‘property_name’: {building_inst1: ‘value’, building_inst2: ‘value2’}}
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 BuildingSnapshot 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:
 

first dict contains values, second the source pks. ({‘data’: ‘value’}, {‘data’: 23},)

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

:copyright (c) 2014 - 2015, The Regents of the University of California, through Lawrence Berkeley National Laboratory (subject to receipt of any required approvals from the U.S. Department of Energy) and contributors. All rights reserved. # NOQA :author

seed.mappings.reconcile_mappings.break_up_address(address)

Return a list of strings, breaking up address num and st. name.

“1232 Harris Blvd.” -> [1232, [‘Harris’, ‘Blvd.’]] “23 SE Double Phantom St.” -> [23, [‘SE’, ‘Double’ ‘Phantom’, ‘St.’]]

seed.mappings.reconcile_mappings.build_address_q(address, b_attr)

Build a Q(street number) AND (Q(street name) OR Q(quadrant)) Q object.

Parameters:
  • address – str, the full address.
  • b_attr – str, the attribute name you’re going to query against.
Rtype Q:

Returns a Q object that queries for the street number and any other string data from the address field.

seed.mappings.seed_mappings module

:copyright (c) 2014 - 2015, The Regents of the University of California, through Lawrence Berkeley National Laboratory (subject to receipt of any required approvals from the U.S. Department of Energy) and contributors. All rights reserved. # NOQA :author

Module contents

:copyright (c) 2014 - 2015, The Regents of the University of California, through Lawrence Berkeley National Laboratory (subject to receipt of any required approvals from the U.S. Department of Energy) and contributors. All rights reserved. # NOQA :author