def handle_spell(conn, section): curs = conn.cursor() try: fetch_spell_detail(curs, section['section_id']) detail = curs.fetchone() if detail: del detail['spell_detail_id'] del detail['section_id'] section.update(detail) fetch_spell_lists(curs, section['section_id']) levels = [] for level in curs.fetchall(): levels.append({ "type": level["type"], "name": level['name'], "notes": level['notes'], "level": level['level'] }) if len(levels) > 0: section['levels'] = levels fetch_spell_subschools(curs, section['section_id']) subschools = [] for subschool in curs.fetchall(): subschools.append(subschool['subschool']) if len(subschools) > 0: section['subschool'] = subschools fetch_spell_descriptors(curs, section['section_id']) descriptors = [] for descriptor in curs.fetchall(): descriptors.append(descriptor['descriptor']) if len(descriptors) > 0: section['descriptor'] = descriptors fetch_spell_effects(curs, section['section_id']) effects = [] for effect in curs.fetchall(): effects.append({ 'name': effect['name'], 'text': effect['description'] }) if len(effects) > 0: section['effects'] = effects fetch_spell_components(curs, section['section_id']) components = [] for component in curs.fetchall(): c = {"type": component['component_type']} if component['description']: c['text'] = component['description'] components.append(c) if len(components) > 0: section['components'] = components finally: curs.close()
def handle_spell(curs, source_curs, index_id, section_id): fetch_spell_lists(source_curs, section_id) for spell_list in source_curs.fetchall(): insert_spell_list_index(curs, index_id, spell_list['level'], spell_list['class'], spell_list['magic_type']) fetch_spell_descriptors(source_curs, section_id) for spell_descriptor in source_curs.fetchall(): insert_spell_descriptor_index(curs, index_id, spell_descriptor['descriptor']) fetch_spell_components(source_curs, section_id) for spell_component in source_curs.fetchall(): insert_spell_component_index(curs, index_id, spell_component['component_type']) fetch_spell_subschools(source_curs, section_id) for spell_subschool in source_curs.fetchall(): insert_spell_subschool_index(curs, index_id, spell_subschool['subschool'])
def handle_spell(conn, section): curs = conn.cursor() try: fetch_spell_detail(curs, section['section_id']) detail = curs.fetchone() if detail: del detail['spell_detail_id'] del detail['section_id'] section.update(detail) fetch_spell_lists(curs, section['section_id']) levels = [] for level in curs.fetchall(): levels.append({"type": level["type"], "name": level['name'], "notes": level['notes'], "level": level['level']}) if len(levels) > 0: section['levels'] = levels fetch_spell_subschools(curs, section['section_id']) subschools = [] for subschool in curs.fetchall(): subschools.append(subschool['subschool']) if len(subschools) > 0: section['subschool'] = subschools fetch_spell_descriptors(curs, section['section_id']) descriptors = [] for descriptor in curs.fetchall(): descriptors.append(descriptor['descriptor']) if len(descriptors) > 0: section['descriptor'] = descriptors fetch_spell_effects(curs, section['section_id']) effects = [] for effect in curs.fetchall(): effects.append({'name': effect['name'], 'text': effect['description']}) if len(effects) > 0: section['effects'] = effects fetch_spell_components(curs, section['section_id']) components = [] for component in curs.fetchall(): c = {"type": component['component_type']} if component['description']: c['text'] = component['description'] components.append(c) if len(components) > 0: section['components'] = components finally: curs.close()