def test(self): va_rows = sasi.util.va.read_va_from_csv(conf.conf['va_file']) va = VulnerabilityAssessment(rows = va_rows) f_by_h = va.get_features_by_habitats() features = va.get_features() substrates = va.get_substrates() g_by_h = va.get_gear_categories_by_habitats() gear_categories = va.get_gear_categories() h_by_g = va.get_habitats_by_gear_categories() habitats_for_gear = va.get_habitats_for_gear_category(gear_categories.keys().pop()) features_for_gear = va.get_features_for_gear_category(gear_categories.keys().pop()) f_by_g = va.get_features_by_gear_categories() habitats = va.get_habitats()
def main(): # Read substrates from vulernability assessment. va_rows = sasi.util.va.read_va_from_csv(conf.conf['va_file']) va = VulnerabilityAssessment(rows = va_rows) f_by_h = va.get_features_by_habitats() substrates = va.get_substrates() # Get DB session. session = sa_session.get_session() # Clear substrate table. session.execute(sa_substrate.table.delete()) session.commit() # Create Substrate objects # note: might move this into the VA object itself later. substrate_objs = [] for s in substrates.values(): s_obj = Substrate(name=s['SUBSTRATE'], id=s['SUBSTRATE_CODE']) substrate_objs.append(s_obj) # Add substrate objects to session and save to DB. session.add_all(substrate_objs) session.commit()