1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-15 08:40:34 +03:00

Use case-insensitive comparisons for modules.

Fixes #25.
This commit is contained in:
Jonathan Harris 2015-09-23 17:18:40 +01:00
parent 0534b955bf
commit ec4c2f480d
5 changed files with 216 additions and 216 deletions

View File

@ -48,31 +48,31 @@ commodity_map= {
} }
ship_map = { ship_map = {
'Adder' : 'Adder', 'adder' : 'Adder',
'Anaconda' : 'Anaconda', 'anaconda' : 'Anaconda',
'Asp' : 'Asp', 'asp' : 'Asp',
'CobraMkIII' : 'Cobra Mk III', 'cobramkiii' : 'Cobra Mk III',
'DiamondBack' : 'Diamondback Scout', 'diamondback' : 'Diamondback Scout',
'DiamondBackXL' : 'Diamondback Explorer', 'diamondbackxl' : 'Diamondback Explorer',
'Eagle' : 'Eagle', 'eagle' : 'Eagle',
'Empire_Courier' : 'Imperial Courier', 'empire_courier' : 'Imperial Courier',
'Empire_Eagle' : 'Imperial Eagle', 'empire_eagle' : 'Imperial Eagle',
'Empire_Fighter' : 'Imperial Fighter', 'empire_fighter' : 'Imperial Fighter',
'Empire_Trader' : 'Imperial Clipper', 'empire_trader' : 'Imperial Clipper',
'Federation_Dropship' : 'Federal Dropship', 'federation_dropship' : 'Federal Dropship',
'Federation_Dropship_MkII' : 'Federal Assault Ship', 'federation_dropship_mkii' : 'Federal Assault Ship',
'Federation_Gunship' : 'Federal Gunship', 'federation_gunship' : 'Federal Gunship',
'Federation_Fighter' : 'F63 Condor', 'federation_fighter' : 'F63 Condor',
'FerDeLance' : 'Fer-de-Lance', 'ferdelance' : 'Fer-de-Lance',
'Hauler' : 'Hauler', 'hauler' : 'Hauler',
'Orca' : 'Orca', 'orca' : 'Orca',
'Python' : 'Python', 'python' : 'Python',
'SideWinder' : 'Sidewinder', 'sidewinder' : 'Sidewinder',
'Type6' : 'Type-6 Transporter', 'type6' : 'Type-6 Transporter',
'Type7' : 'Type-7 Transporter', 'type7' : 'Type-7 Transporter',
'Type9' : 'Type-9 Heavy', 'type9' : 'Type-9 Heavy',
'Viper' : 'Viper', 'viper' : 'Viper',
'Vulture' : 'Vulture', 'vulture' : 'Vulture',
} }

View File

@ -13,12 +13,12 @@ import companion
slot_map = { slot_map = {
'HugeHardpoint' : 'hardpoints', 'hugehardpoint' : 'hardpoints',
'LargeHardpoint' : 'hardpoints', 'largehardpoint' : 'hardpoints',
'MediumHardpoint' : 'hardpoints', 'mediumhardpoint' : 'hardpoints',
'SmallHardpoint' : 'hardpoints', 'smallhardpoint' : 'hardpoints',
'TinyHardpoint' : 'utility', 'tinyhardpoint' : 'utility',
'Slot' : 'internal', 'slot' : 'internal',
} }
# Map draft E:D Shipyard & EDDN outfitting to Coriolis # Map draft E:D Shipyard & EDDN outfitting to Coriolis
@ -26,7 +26,7 @@ slot_map = {
# http://cdn.coriolis.io/schemas/ship-loadout/2.json # http://cdn.coriolis.io/schemas/ship-loadout/2.json
ship_map = dict(companion.ship_map) ship_map = dict(companion.ship_map)
ship_map['Asp'] = 'Asp Explorer' ship_map['asp'] = 'Asp Explorer'
category_map = { category_map = {
'standard' : 'standard', 'standard' : 'standard',
@ -77,12 +77,12 @@ def export(data):
querytime = config.getint('querytime') or int(time.time()) querytime = config.getint('querytime') or int(time.time())
ship = companion.ship_map.get(data['ship']['name'], data['ship']['name']) ship = companion.ship_map.get(data['ship']['name'].lower(), data['ship']['name'])
loadout = OrderedDict([ # Mimic Coriolis export ordering loadout = OrderedDict([ # Mimic Coriolis export ordering
('$schema', 'http://cdn.coriolis.io/schemas/ship-loadout/2.json#'), ('$schema', 'http://cdn.coriolis.io/schemas/ship-loadout/2.json#'),
('name', ship_map.get(data['ship']['name'], data['ship']['name'])), ('name', ship_map.get(data['ship']['name'].lower(), data['ship']['name'])),
('ship', ship_map.get(data['ship']['name'], data['ship']['name'])), ('ship', ship_map.get(data['ship']['name'].lower(), data['ship']['name'])),
('components', OrderedDict([ ('components', OrderedDict([
('standard', OrderedDict([(x,None) for x in standard_map.values()])), ('standard', OrderedDict([(x,None) for x in standard_map.values()])),
('hardpoints', []), ('hardpoints', []),
@ -101,7 +101,7 @@ def export(data):
if not v: if not v:
# Need to add nulls for empty slots. Assumes that standard slots can't be empty. # Need to add nulls for empty slots. Assumes that standard slots can't be empty.
for s in slot_map: for s in slot_map:
if slot.startswith(s): if slot.lower().startswith(s):
loadout['components'][slot_map[s]].append(None) loadout['components'][slot_map[s]].append(None)
break break
continue continue

View File

@ -93,6 +93,6 @@ def export_shipyard(data):
'message' : { 'message' : {
'systemName' : data['lastSystem']['name'].strip(), 'systemName' : data['lastSystem']['name'].strip(),
'stationName' : data['lastStarport']['name'].strip(), 'stationName' : data['lastStarport']['name'].strip(),
'ships' : [ship_map[ship['name']] for ship in (data['lastStarport']['ships'].get('shipyard_list') or {}).values() + data['lastStarport']['ships'].get('unavailable_list') if ship['name'] in ship_map], 'ships' : [ship_map[ship['name'].lower()] for ship in (data['lastStarport']['ships'].get('shipyard_list') or {}).values() + data['lastStarport']['ships'].get('unavailable_list') if ship['name'].lower() in ship_map],
} }
}) })

View File

@ -13,19 +13,19 @@ from companion import ship_map
# API slot names to E:D Shipyard slot names # API slot names to E:D Shipyard slot names
slot_map = { slot_map = {
'HugeHardpoint' : 'H', 'hugehardpoint' : 'H',
'LargeHardpoint' : 'L', 'largehardpoint' : 'L',
'MediumHardpoint' : 'M', 'mediumhardpoint' : 'M',
'SmallHardpoint' : 'S', 'smallhardpoint' : 'S',
'TinyHardpoint' : 'U', 'tinyhardpoint' : 'U',
'Armour' : 'BH', 'armour' : 'BH',
'PowerPlant' : 'RB', 'powerplant' : 'RB',
'MainEngines' : 'TM', 'mainengines' : 'TM',
'FrameShiftDrive' : 'FH', 'frameshiftdrive' : 'FH',
'LifeSupport' : 'EC', 'lifesupport' : 'EC',
'PowerDistributor' : 'PC', 'powerdistributor' : 'PC',
'Radar' : 'SS', 'radar' : 'SS',
'FuelTank' : 'FS', 'fueltank' : 'FS',
} }
def export(data): def export(data):
@ -40,7 +40,7 @@ def export(data):
querytime = config.getint('querytime') or int(time.time()) querytime = config.getint('querytime') or int(time.time())
ship = ship_map.get(data['ship']['name'], data['ship']['name']) ship = ship_map.get(data['ship']['name'].lower(), data['ship']['name'])
loadout = defaultdict(list) loadout = defaultdict(list)
@ -62,11 +62,11 @@ def export(data):
name = module['name'] name = module['name']
for s in slot_map: for s in slot_map:
if slot.startswith(s): if slot.lower().startswith(s):
loadout[slot_map[s]].append(cr + name) loadout[slot_map[s]].append(cr + name)
break break
else: else:
if slot.startswith('Slot'): if slot.lower().startswith('slot'):
loadout[slot[-1]].append(cr + name) loadout[slot[-1]].append(cr + name)
elif __debug__: print 'Loadout: Unknown slot %s' % slot elif __debug__: print 'Loadout: Unknown slot %s' % slot

View File

@ -16,154 +16,154 @@ outfile = 'outfitting.csv'
outfitting = {} outfitting = {}
armour_map = { armour_map = {
'Grade1' : 'Lightweight Alloy', 'grade1' : 'Lightweight Alloy',
'Grade2' : 'Reinforced Alloy', 'grade2' : 'Reinforced Alloy',
'Grade3' : 'Military Grade Composite', 'grade3' : 'Military Grade Composite',
'Mirrored' : 'Mirrored Surface Composite', 'mirrored' : 'Mirrored Surface Composite',
'Reactive' : 'Reactive Surface Composite', 'reactive' : 'Reactive Surface Composite',
} }
weapon_map = { weapon_map = {
'AdvancedTorpPylon' : 'Torpedo Pylon', 'advancedtorppylon' : 'Torpedo Pylon',
'BasicMissileRack' : 'Missile Rack', 'basicmissilerack' : 'Missile Rack',
'BeamLaser' : 'Beam Laser', 'beamlaser' : 'Beam Laser',
('BeamLaser','Heat') : 'Retributor Beam Laser', ('beamlaser','heat') : 'Retributor Beam Laser',
'Cannon' : 'Cannon', 'cannon' : 'Cannon',
'DrunkMissileRack' : 'Pack-Hound Missile Rack', 'drunkmissilerack' : 'Pack-Hound Missile Rack',
'DumbfireMissileRack' : 'Missile Rack', 'dumbfiremissilerack' : 'Missile Rack',
'MineLauncher' : 'Mine Launcher', 'minelauncher' : 'Mine Launcher',
('MineLauncher','Impulse') : 'Impulse Mine Launcher', # Not seen in game? ('minelauncher','impulse') : 'Impulse Mine Launcher', # Not seen in game?
'MiningLaser' : 'Mining Laser', 'mininglaser' : 'Mining Laser',
('MiningLaser','Advanced') : 'Mining Lance Beam Laser', ('mininglaser','advanced') : 'Mining Lance Beam Laser',
'MultiCannon' : 'Multi-Cannon', 'multicannon' : 'Multi-Cannon',
('MultiCannon','Strong') : 'Enforcer Cannon', ('multicannon','strong') : 'Enforcer Cannon',
'PlasmaAccelerator' : 'Plasma Accelerator', 'plasmaaccelerator' : 'Plasma Accelerator',
('PlasmaAccelerator','Advanced') : 'Advanced Plasma Accelerator', ('plasmaaccelerator','advanced') : 'Advanced Plasma Accelerator',
'PulseLaser' : 'Pulse Laser', 'pulselaser' : 'Pulse Laser',
('PulseLaser','Disruptor') : 'Pulse Disruptor Laser', ('pulselaser','disruptor') : 'Pulse Disruptor Laser',
'PulseLaserBurst' : 'Burst Laser', 'pulselaserburst' : 'Burst Laser',
('PulseLaserBurst','Scatter') : 'Cytoscrambler Burst Laser', ('pulselaserburst','scatter') : 'Cytoscrambler Burst Laser',
'Railgun' : 'Rail Gun', 'railgun' : 'Rail Gun',
('Railgun','Burst') : 'Imperial Hammer Rail Gun', ('railgun','burst') : 'Imperial Hammer Rail Gun',
'Slugshot' : 'Fragment Cannon', 'slugshot' : 'Fragment Cannon',
('Slugshot','Range') : 'Pacifier Frag-Cannon', ('slugshot','range') : 'Pacifier Frag-Cannon',
} }
missiletype_map = { missiletype_map = {
'AdvancedTorpPylon' : 'Seeker', 'advancedtorppylon' : 'Seeker',
'BasicMissileRack' : 'Seeker', 'basicmissilerack' : 'Seeker',
'DrunkMissileRack' : 'Swarm', 'drunkmissilerack' : 'Swarm',
'DumbfireMissileRack' : 'Dumbfire', 'dumbfiremissilerack' : 'Dumbfire',
} }
weaponmount_map = { weaponmount_map = {
'Fixed' : 'Fixed', 'fixed' : 'Fixed',
'Gimbal' : 'Gimballed', 'gimbal' : 'Gimballed',
'Turret' : 'Turreted', 'turret' : 'Turreted',
} }
weaponclass_map = { weaponclass_map = {
'Tiny' : '0', 'tiny' : '0',
'Small' : '1', 'small' : '1',
'Medium' : '2', 'medium' : '2',
'Large' : '3', 'large' : '3',
'Huge' : '4', 'huge' : '4',
} }
# There's no discernable pattern for weapon ratings, so here's a lookup table # There's no discernable pattern for weapon ratings, so here's a lookup table
weaponrating_map = { weaponrating_map = {
'Hpt_AdvancedTorpPylon_Fixed_Small': 'I', 'hpt_advancedtorppylon_fixed_small' : 'I',
'Hpt_AdvancedTorpPylon_Fixed_Medium': 'I', 'hpt_advancedtorppylon_fixed_medium': 'I',
'Hpt_BasicMissileRack_Fixed_Small': 'B', 'hpt_basicmissilerack_fixed_small' : 'B',
'Hpt_BasicMissileRack_Fixed_Medium': 'B', 'hpt_basicmissilerack_fixed_medium' : 'B',
'Hpt_BeamLaser_Fixed_Small': 'E', 'hpt_beamlaser_fixed_small' : 'E',
'Hpt_BeamLaser_Fixed_Medium': 'D', 'hpt_beamlaser_fixed_medium' : 'D',
'Hpt_BeamLaser_Fixed_Large': 'C', 'hpt_beamlaser_fixed_large': 'C',
'Hpt_BeamLaser_Gimbal_Small': 'E', 'hpt_beamlaser_gimbal_small': 'E',
'Hpt_BeamLaser_Gimbal_Medium': 'D', 'hpt_beamlaser_gimbal_medium': 'D',
'Hpt_BeamLaser_Gimbal_Large': 'C', 'hpt_beamlaser_gimbal_large': 'C',
'Hpt_BeamLaser_Turret_Small': 'F', 'hpt_beamlaser_turret_small': 'F',
'Hpt_BeamLaser_Turret_Medium': 'E', 'hpt_beamlaser_turret_medium': 'E',
'Hpt_BeamLaser_Turret_Large': 'D', 'hpt_beamlaser_turret_large': 'D',
'Hpt_Cannon_Fixed_Small': 'D', 'hpt_cannon_fixed_small': 'D',
'Hpt_Cannon_Fixed_Medium': 'D', 'hpt_cannon_fixed_medium': 'D',
'Hpt_Cannon_Fixed_Large': 'C', 'hpt_cannon_fixed_large': 'C',
'Hpt_Cannon_Fixed_Huge': 'B', 'hpt_cannon_fixed_huge': 'B',
'Hpt_Cannon_Gimbal_Small': 'E', 'hpt_cannon_gimbal_small': 'E',
'Hpt_Cannon_Gimbal_Medium': 'D', 'hpt_cannon_gimbal_medium': 'D',
'Hpt_Cannon_Gimbal_Large': 'C', 'hpt_cannon_gimbal_large': 'C',
'Hpt_Cannon_Gimbal_Huge': 'B', 'hpt_cannon_gimbal_huge': 'B',
'Hpt_Cannon_Turret_Small': 'F', 'hpt_cannon_turret_small': 'F',
'Hpt_Cannon_Turret_Medium': 'E', 'hpt_cannon_turret_medium': 'E',
'Hpt_Cannon_Turret_Large': 'D', 'hpt_cannon_turret_large': 'D',
'Hpt_DrunkMissileRack_Fixed_Medium': 'B', 'hpt_drunkmissilerack_fixed_medium': 'B',
'Hpt_DumbfireMissileRack_Fixed_Small': 'B', 'hpt_dumbfiremissilerack_fixed_small': 'B',
'Hpt_DumbfireMissileRack_Fixed_Medium': 'B', 'hpt_dumbfiremissilerack_fixed_medium': 'B',
'Hpt_MineLauncher_Fixed_Small': 'I', 'hpt_minelauncher_fixed_small': 'I',
'Hpt_MineLauncher_Fixed_Medium': 'I', 'hpt_minelauncher_fixed_medium': 'I',
'Hpt_MiningLaser_Fixed_Small': 'D', 'hpt_mininglaser_fixed_small': 'D',
'Hpt_MiningLaser_Fixed_Medium': 'D', 'hpt_mininglaser_fixed_medium': 'D',
'Hpt_MultiCannon_Fixed_Small': 'F', 'hpt_multicannon_fixed_small': 'F',
'Hpt_MultiCannon_Fixed_Medium': 'E', 'hpt_multicannon_fixed_medium': 'E',
'Hpt_MultiCannon_Gimbal_Small': 'G', 'hpt_multicannon_gimbal_small': 'G',
'Hpt_MultiCannon_Gimbal_Medium': 'F', 'hpt_multicannon_gimbal_medium': 'F',
'Hpt_MultiCannon_Turret_Small': 'G', 'hpt_multicannon_turret_small': 'G',
'Hpt_MultiCannon_Turret_Medium': 'F', 'hpt_multicannon_turret_medium': 'F',
'Hpt_PlasmaAccelerator_Fixed_Medium': 'C', 'hpt_plasmaaccelerator_fixed_medium': 'C',
'Hpt_PlasmaAccelerator_Fixed_Large': 'B', 'hpt_plasmaaccelerator_fixed_large': 'B',
'Hpt_PlasmaAccelerator_Fixed_Huge': 'A', 'hpt_plasmaaccelerator_fixed_huge': 'A',
'Hpt_PulseLaser_Fixed_Small': 'F', 'hpt_pulselaser_fixed_small': 'F',
'Hpt_PulseLaser_Fixed_Medium': 'E', 'hpt_pulselaser_fixed_medium': 'E',
'Hpt_PulseLaser_Fixed_Large': 'D', 'hpt_pulselaser_fixed_large': 'D',
'Hpt_PulseLaser_Gimbal_Small': 'G', 'hpt_pulselaser_gimbal_small': 'G',
'Hpt_PulseLaser_Gimbal_Medium': 'F', 'hpt_pulselaser_gimbal_medium': 'F',
'Hpt_PulseLaser_Gimbal_Large': 'E', 'hpt_pulselaser_gimbal_large': 'E',
'Hpt_PulseLaser_Turret_Small': 'G', 'hpt_pulselaser_turret_small': 'G',
'Hpt_PulseLaser_Turret_Medium': 'F', 'hpt_pulselaser_turret_medium': 'F',
'Hpt_PulseLaser_Turret_Large': 'F', 'hpt_pulselaser_turret_large': 'F',
'Hpt_PulseLaserBurst_Fixed_Small': 'F', 'hpt_pulselaserburst_fixed_small': 'F',
'Hpt_PulseLaserBurst_Fixed_Medium': 'E', 'hpt_pulselaserburst_fixed_medium': 'E',
'Hpt_PulseLaserBurst_Fixed_Large': 'D', 'hpt_pulselaserburst_fixed_large': 'D',
'Hpt_PulseLaserBurst_Gimbal_Small': 'G', 'hpt_pulselaserburst_gimbal_small': 'G',
'Hpt_PulseLaserBurst_Gimbal_Medium': 'F', 'hpt_pulselaserburst_gimbal_medium': 'F',
'Hpt_PulseLaserBurst_Gimbal_Large': 'E', 'hpt_pulselaserburst_gimbal_large': 'E',
'Hpt_PulseLaserBurst_Turret_Small': 'G', 'hpt_pulselaserburst_turret_small': 'G',
'Hpt_PulseLaserBurst_Turret_Medium': 'F', 'hpt_pulselaserburst_turret_medium': 'F',
'Hpt_PulseLaserBurst_Turret_Large': 'E', 'hpt_pulselaserburst_turret_large': 'E',
'Hpt_Railgun_Fixed_Small': 'D', 'hpt_railgun_fixed_small': 'D',
'Hpt_Railgun_Fixed_Medium': 'B', 'hpt_railgun_fixed_medium': 'B',
'Hpt_Slugshot_Fixed_Small': 'E', 'hpt_slugshot_fixed_small': 'E',
'Hpt_Slugshot_Fixed_Medium': 'A', 'hpt_slugshot_fixed_medium': 'A',
'Hpt_Slugshot_Fixed_Large': 'C', 'hpt_slugshot_fixed_large': 'C',
'Hpt_Slugshot_Gimbal_Small': 'E', 'hpt_slugshot_gimbal_small': 'E',
'Hpt_Slugshot_Gimbal_Medium': 'D', 'hpt_slugshot_gimbal_medium': 'D',
'Hpt_Slugshot_Gimbal_Large': 'C', 'hpt_slugshot_gimbal_large': 'C',
'Hpt_Slugshot_Turret_Small': 'E', 'hpt_slugshot_turret_small': 'E',
'Hpt_Slugshot_Turret_Medium': 'D', 'hpt_slugshot_turret_medium': 'D',
'Hpt_Slugshot_Turret_Large': 'C', 'hpt_slugshot_turret_large': 'C',
} }
# Old standard weapon variants # Old standard weapon variants
weaponoldvariant_map = { weaponoldvariant_map = {
'F' : 'Focussed', 'f' : 'Focussed',
'HI' : 'High Impact', 'hi' : 'High Impact',
'LH' : 'Low Heat', 'lh' : 'Low Heat',
'OC' : 'Overcharged', 'oc' : 'Overcharged',
'SS' : 'Scatter Spray', 'ss' : 'Scatter Spray',
} }
countermeasure_map = { countermeasure_map = {
'ChaffLauncher' : ('Chaff Launcher', 'I'), 'chafflauncher' : ('Chaff Launcher', 'I'),
'ElectronicCountermeasure' : ('Electronic Countermeasure', 'F'), 'electroniccountermeasure' : ('Electronic Countermeasure', 'F'),
'HeatSinkLauncher' : ('Heat Sink Launcher', 'I'), 'heatsinklauncher' : ('Heat Sink Launcher', 'I'),
'PlasmaPointDefence' : ('Point Defence', 'I'), 'plasmapointdefence' : ('Point Defence', 'I'),
} }
utility_map = { utility_map = {
'CargoScanner' : 'Cargo Scanner', 'cargoscanner' : 'Cargo Scanner',
'CloudScanner' : 'Frame Shift Wake Scanner', 'cloudscanner' : 'Frame Shift Wake Scanner',
'CrimeScanner' : 'Kill Warrant Scanner', 'crimescanner' : 'Kill Warrant Scanner',
'ShieldBooster' : 'Shield Booster', 'shieldbooster' : 'Shield Booster',
} }
rating_map = { rating_map = {
@ -175,37 +175,37 @@ rating_map = {
} }
standard_map = { standard_map = {
# 'Armour' : handled separately # 'armour' : handled separately
'Engine' : 'Thrusters', 'engine' : 'Thrusters',
'FuelTank' : 'Fuel Tank', 'fueltank' : 'Fuel Tank',
'Hyperdrive' : 'Frame Shift Drive', 'hyperdrive' : 'Frame Shift Drive',
'LifeSupport' : 'Life Support', 'lifesupport' : 'Life Support',
'PowerDistributor' : 'Power Distributor', 'powerdistributor' : 'Power Distributor',
'Powerplant' : 'Power Plant', 'powerplant' : 'Power Plant',
'Sensors' : 'Sensors', 'sensors' : 'Sensors',
} }
stellar_map = { stellar_map = {
'Standard' : ('Basic Discovery Scanner', 'E'), 'standard' : ('Basic Discovery Scanner', 'E'),
'Intermediate' : ('Intermediate Discovery Scanner', 'D'), 'intermediate' : ('Intermediate Discovery Scanner', 'D'),
'Advanced' : ('Advanced Discovery Scanner', 'C'), 'advanced' : ('Advanced Discovery Scanner', 'C'),
'Tiny' : ('Detailed Surface Scanner', 'C'), 'tiny' : ('Detailed Surface Scanner', 'C'),
} }
internal_map = { internal_map = {
'CargoRack' : 'Cargo Rack', 'cargorack' : 'Cargo Rack',
'Collection' : 'Collector Limpet Controller', 'collection' : 'Collector Limpet Controller',
'FSDInterdictor' : 'Frame Shift Drive Interdictor', 'fsdinterdictor' : 'Frame Shift Drive Interdictor',
'FuelScoop' : 'Fuel Scoop', 'fuelscoop' : 'Fuel Scoop',
'FuelTransfer' : 'Fuel Transfer Limpet Controller', 'fueltransfer' : 'Fuel Transfer Limpet Controller',
'HullReinforcement' : 'Hull Reinforcement Package', 'hullreinforcement' : 'Hull Reinforcement Package',
'Prospector' : 'Prospector Limpet Controller', 'prospector' : 'Prospector Limpet Controller',
'Refinery' : 'Refinery', 'refinery' : 'Refinery',
'Repairer' : 'Auto Field-Maintenance Unit', 'repairer' : 'Auto Field-Maintenance Unit',
'ResourceSiphon' : 'Hatch Breaker Limpet Controller', 'resourcesiphon' : 'Hatch Breaker Limpet Controller',
'ShieldCellBank' : 'Shield Cell Bank', 'shieldcellbank' : 'Shield Cell Bank',
'ShieldGenerator' : 'Shield Generator', 'shieldgenerator' : 'Shield Generator',
('ShieldGenerator','Strong') : 'Prismatic Shield Generator', ('shieldgenerator','strong') : 'Prismatic Shield Generator',
} }
@ -219,12 +219,12 @@ def lookup(module):
# if not module.get('category'): raise AssertionError('%s: Missing category' % module['id']) # only present post 1.3, and not present in ship loadout # if not module.get('category'): raise AssertionError('%s: Missing category' % module['id']) # only present post 1.3, and not present in ship loadout
if not module.get('name'): raise AssertionError('%s: Missing name' % module['id']) if not module.get('name'): raise AssertionError('%s: Missing name' % module['id'])
name = module['name'].split('_') name = module['name'].lower().split('_')
new = {} new = {}
# Armour - e.g. Federation_Dropship_Armour_Grade2 # Armour - e.g. Federation_Dropship_Armour_Grade2
if name[-2] == 'Armour': if name[-2] == 'armour':
name = module['name'].rsplit('_', 2) # Armour is ship-specific, and ship names can have underscores name = module['name'].lower().rsplit('_', 2) # Armour is ship-specific, and ship names can have underscores
new['category'] = 'standard' new['category'] = 'standard'
new['name'] = armour_map[name[2]] new['name'] = armour_map[name[2]]
new['ship'] = ship_map.get(name[0], name[0]) new['ship'] = ship_map.get(name[0], name[0])
@ -232,11 +232,11 @@ def lookup(module):
new['rating'] = 'I' new['rating'] = 'I'
# Skip uninteresting stuff # Skip uninteresting stuff
elif name[0].lower() in ['decal', 'paintjob']: # Have seen "paintjob" and "PaintJob" elif name[0] in ['decal', 'paintjob']:
return None return None
# Skip PP-specific modules in outfitting which have an sku like ELITE_SPECIFIC_V_POWER_100100 # Skip PP-specific modules in outfitting which have an sku like ELITE_SPECIFIC_V_POWER_100100
elif module.get('category') == 'powerplay': elif 'category' in module and module['category'].lower() == 'powerplay':
return None return None
# Shouldn't be listing player-specific paid stuff # Shouldn't be listing player-specific paid stuff
@ -244,7 +244,7 @@ def lookup(module):
raise AssertionError('%s: Unexpected sku "%s"' % (module['id'], module['sku'])) raise AssertionError('%s: Unexpected sku "%s"' % (module['id'], module['sku']))
# Hardpoints - e.g. Hpt_Slugshot_Fixed_Medium # Hardpoints - e.g. Hpt_Slugshot_Fixed_Medium
elif name[0]=='Hpt' and name[1] in weapon_map: elif name[0]=='hpt' and name[1] in weapon_map:
if name[2] not in weaponmount_map: raise AssertionError('%s: Unknown weapon mount "%s"' % (module['id'], name[2])) if name[2] not in weaponmount_map: raise AssertionError('%s: Unknown weapon mount "%s"' % (module['id'], name[2]))
if name[3] not in weaponclass_map: raise AssertionError('%s: Unknown weapon class "%s"' % (module['id'], name[3])) if name[3] not in weaponclass_map: raise AssertionError('%s: Unknown weapon class "%s"' % (module['id'], name[3]))
new['category'] = 'hardpoint' new['category'] = 'hardpoint'
@ -257,37 +257,37 @@ def lookup(module):
new['rating'] = weaponrating_map.get(('_').join(name[:4]), '?') # assumes same rating as base weapon new['rating'] = weaponrating_map.get(('_').join(name[:4]), '?') # assumes same rating as base weapon
else: else:
new['name'] = weapon_map[name[1]] new['name'] = weapon_map[name[1]]
new['rating'] = weaponrating_map.get(module['name'], '?') # no obvious rule - needs lookup table new['rating'] = weaponrating_map.get(module['name'].lower(), '?') # no obvious rule - needs lookup table
new['mount'] = weaponmount_map[name[2]] new['mount'] = weaponmount_map[name[2]]
if name[1] in missiletype_map: # e.g. Hpt_DumbfireMissileRack_Fixed_Small if name[1] in missiletype_map: # e.g. Hpt_DumbfireMissileRack_Fixed_Small
new['guidance'] = missiletype_map[name[1]] new['guidance'] = missiletype_map[name[1]]
new['class'] = weaponclass_map[name[3]] new['class'] = weaponclass_map[name[3]]
# Countermeasures - e.g. Hpt_PlasmaPointDefence_Turret_Tiny # Countermeasures - e.g. Hpt_PlasmaPointDefence_Turret_Tiny
elif name[0]=='Hpt' and name[1] in countermeasure_map: elif name[0]=='hpt' and name[1] in countermeasure_map:
new['category'] = 'utility' new['category'] = 'utility'
new['name'], new['rating'] = countermeasure_map[len(name)>4 and (name[1],name[4]) or name[1]] new['name'], new['rating'] = countermeasure_map[len(name)>4 and (name[1],name[4]) or name[1]]
new['class'] = weaponclass_map[name[-1]] new['class'] = weaponclass_map[name[-1]]
# Utility - e.g. Hpt_CargoScanner_Size0_Class1 # Utility - e.g. Hpt_CargoScanner_Size0_Class1
elif name[0]=='Hpt' and name[1] in utility_map: elif name[0]=='hpt' and name[1] in utility_map:
new['category'] = 'utility' new['category'] = 'utility'
new['name'] = utility_map[len(name)>4 and (name[1],name[4]) or name[1]] new['name'] = utility_map[len(name)>4 and (name[1],name[4]) or name[1]]
if not name[2].startswith('Size') or not name[3].startswith('Class'): raise AssertionError('%s: Unknown class/rating "%s/%s"' % (module['id'], name[2], name[3])) if not name[2].startswith('size') or not name[3].startswith('class'): raise AssertionError('%s: Unknown class/rating "%s/%s"' % (module['id'], name[2], name[3]))
new['class'] = name[2][4:] new['class'] = name[2][4:]
new['rating'] = rating_map[name[3][5:]] new['rating'] = rating_map[name[3][5:]]
elif name[0]=='Hpt': elif name[0]=='hpt':
raise AssertionError('%s: Unknown weapon "%s"' % (module['id'], name[1])) raise AssertionError('%s: Unknown weapon "%s"' % (module['id'], name[1]))
# Stellar scanners - e.g. Int_StellarBodyDiscoveryScanner_Standard # Stellar scanners - e.g. Int_StellarBodyDiscoveryScanner_Standard
elif name[1] in ['StellarBodyDiscoveryScanner', 'DetailedSurfaceScanner']: elif name[1] in ['stellarbodydiscoveryscanner', 'detailedsurfacescanner']:
new['category'] = 'internal' new['category'] = 'internal'
new['name'], new['rating'] = stellar_map[name[2]] new['name'], new['rating'] = stellar_map[name[2]]
new['class'] = '1' new['class'] = '1'
# Docking Computer - e.g. Int_DockingComputer_Standard # Docking Computer - e.g. Int_DockingComputer_Standard
elif name[1] == 'DockingComputer' and name[2] == 'Standard': elif name[1] == 'dockingcomputer' and name[2] == 'standard':
new['category'] = 'internal' new['category'] = 'internal'
new['name'] = 'Standard Docking Computer' new['name'] = 'Standard Docking Computer'
new['class'] = '1' new['class'] = '1'
@ -296,9 +296,9 @@ def lookup(module):
# Standard & Internal # Standard & Internal
else: else:
# Reported category is not necessarily helpful. e.g. "Int_DockingComputer_Standard" has category "utility" # Reported category is not necessarily helpful. e.g. "Int_DockingComputer_Standard" has category "utility"
if name[0] != 'Int': raise AssertionError('%s: Unknown prefix "%s"' % (module['id'], name[0])) if name[0] != 'int': raise AssertionError('%s: Unknown prefix "%s"' % (module['id'], name[0]))
if name[1] == 'DroneControl': # e.g. Int_DroneControl_Collection_Size1_Class1 if name[1] == 'dronecontrol': # e.g. Int_DroneControl_Collection_Size1_Class1
name.pop(0) name.pop(0)
if name[1] in standard_map: # e.g. Int_Engine_Size2_Class1 if name[1] in standard_map: # e.g. Int_Engine_Size2_Class1
@ -310,7 +310,7 @@ def lookup(module):
else: else:
raise AssertionError('%s: Unknown module "%s"' % (module['id'], name[1])) raise AssertionError('%s: Unknown module "%s"' % (module['id'], name[1]))
if not name[2].startswith('Size') or not name[3].startswith('Class'): raise AssertionError('%s: Unknown class/rating "%s/%s"' % (module['id'], name[2], name[3])) if not name[2].startswith('size') or not name[3].startswith('class'): raise AssertionError('%s: Unknown class/rating "%s/%s"' % (module['id'], name[2], name[3]))
new['class'] = name[2][4:] new['class'] = name[2][4:]
new['rating'] = rating_map[name[3][5:]] new['rating'] = rating_map[name[3][5:]]