diff options
Diffstat (limited to 'scrap.py')
-rw-r--r-- | scrap.py | 21 |
1 files changed, 19 insertions, 2 deletions
@@ -32,11 +32,27 @@ def expand_details(snapshot): return snapshot -def get_ships(snapshot): +def get_types(snapshot): ships = {x['victim']['ship_type_id'] for x in snapshot['killmails']} return [esi.type(x) for x in ships] +def get_locations(snapshot): + solar_system_ids = {x['solar_system_id'] for x in snapshot['killmails']} + solar_systems = [esi.system(x) for x in solar_system_ids] + constellation_ids = {x['constellation_id'] for x in solar_systems} + constellations = {x: esi.constellation(x) for x in constellation_ids} + region_ids = {x['region_id'] for x in constellations.values()} + regions = {x: esi.region(x) for x in region_ids} + for system in solar_systems: + constellation = constellations[system['constellation_id']] + region_id = constellation['region_id'] + system['constellation_name'] = constellation['name'] + system['region_name'] = regions[region_id]['name'] + system['region_id'] = region_id + return solar_systems + + def output_name(args): """ Generates name of the output file based on the CLI *args*. @@ -58,7 +74,8 @@ def main(): snapshot = zkill.parse_battle_report(args.url) expand_hashes(snapshot) expand_details(snapshot) - snapshot['ships'] = get_ships(snapshot) + snapshot['types'] = get_types(snapshot) + snapshot['locations'] = get_locations(snapshot) filename = output_name(args) with open(filename, 'w') as fd: opts = {'indent': 4} if args.pretty else {} |