def process_gear(table_data, gear_list): remap = { "Cost": "price", "Weight": "weight", "Name": "name", "Aura": "aura"} for gear in gear_list: item = {"type": "item"} fix_cost(gear) fields = gear.keys() fields.sort() for key in fields: misc = item.setdefault('misc', []) if gear['Name'] in table_data.get('distinct_section', {}): value = gear[key] subsection = table_data['distinct_section'][gear['Name']] if key == "Cost": key = "Price" if not key == "Name": misc.append({ "field": key, "subsection": subsection, "value": value}) else: if key in remap.keys(): item[remap[key]] = gear[key] else: value = gear[key] misc.append({ "field": key, "value": value}) gear['item'] = item set_subtype(table_data, 'Gear Type', gear) return gear_list
def process_gear(table_data, gear_list): remap = { "Cost": "price", "Weight": "weight", "Name": "name", "Aura": "aura" } for gear in gear_list: item = {"type": "item"} fix_cost(gear) fields = gear.keys() fields.sort() for key in fields: misc = item.setdefault('misc', []) if gear['Name'] in table_data.get('distinct_section', {}): value = gear[key] subsection = table_data['distinct_section'][gear['Name']] if key == "Cost": key = "Price" if not key == "Name": misc.append({ "field": key, "subsection": subsection, "value": value }) else: if key in remap.keys(): item[remap[key]] = gear[key] else: value = gear[key] misc.append({"field": key, "value": value}) gear['item'] = item set_subtype(table_data, 'Gear Type', gear) return gear_list
def process_weapons(table_data, weapons): remap = {"Cost": "price", "Weight": "weight", "Name": "name"} for weapon in weapons: item = {"type": "item"} set_damage(weapon) fix_cost(weapon) fields = weapon.keys() fields.sort() for key in fields: if key in remap.keys(): item[remap[key]] = weapon[key] else: misc = item.setdefault('misc', []) subsection = "Weapon" value = weapon[key] if weapon['Name'] in table_data.get('distinct_section', {}): subsection = table_data['distinct_section'][weapon['Name']] misc.append({ "field": key, "subsection": subsection, "value": value}) weapon['item'] = item set_subtype(table_data, "Weapon Class", weapon) #pp = pprint.PrettyPrinter(indent=4) #pp.pprint(weapons) return weapons