def default_system(self): reader = csv_defaults('system.csv') if not reader: return defs = table_default_values(db.system) for i, row in enumerate(reader): if i == 0: continue defs['name'] = row[0] db.system.update_or_insert( db.system.name==defs['name'], **defs) return
def default_unit_of_measure(self): reader = csv_defaults('unit_of_measure.csv') if not reader: return defs = table_default_values(db.unit_of_measure) cols = Dict(acronym=0,name=1) for i, row in enumerate(reader): if i == 0: continue defs['acronym'] = row[cols.acronym] defs['name'] = row[cols.name] db.unit_of_measure.update_or_insert( db.unit_of_measure.acronym==defs['acronym'], **defs) return
def default_maintenance_service(self): reader = csv_defaults('maintenance_service.csv') if not reader: return defs = table_default_values(db.maintenance_service) cols = Dict(name=0,subsystem=1) for i, row in enumerate(reader): if i == 0: continue subsystem = db(db.subsystem.name == row[cols['subsystem']]).select().first() if not subsystem: continue defs['subsystem_id'] = subsystem.id defs['name'] = row[cols['name']] db.maintenance_service.update_or_insert( db.maintenance_service.name==defs['name'], **defs)
def default_subsystem(self): reader = csv_defaults('subsystem.csv') if not reader: return defs = table_default_values(db.subsystem) cols = Dict(name=1,system=0) for i, row in enumerate(reader): if i == 0: continue system = db(db.system.name == row[cols.system]).select().first() if not system: continue defs['system_id'] = system.id defs['name'] = row[cols.name] db.subsystem.update_or_insert( db.subsystem.system_id==defs['system_id'] and db.subsystem.name==defs['name'], **defs) return
def default_sytem_item(self): reader = csv_defaults('system_item.csv') if not reader: return defs = table_default_values(db.system_item) cols = Dict(name=0,subsystem=1,unit=2,type=3) for i, row in enumerate(reader): if i == 0: continue subsystem = db(db.subsystem.name == row[cols['subsystem']]).select().first() if not subsystem: continue unit = db(db.unit_of_measure.acronym == row[cols['unit']]).select().first() if not unit: continue defs['subsystem_id'] = subsystem.id defs['name'] = row[cols['name']] defs['item_type'] = row[cols['type']] defs['unit_of_measure_id'] = unit.id db.system_item.update_or_insert( db.system_item.item_type==defs['item_type'] and db.system_item.name==defs['name'], **defs)