diff --git a/collate.py b/collate.py index 78df704b..b06e2379 100755 --- a/collate.py +++ b/collate.py @@ -9,11 +9,12 @@ import os from os.path import exists, isfile import sys -from companion import category_map, commodity_map, ship_map +from companion import ship_map import outfitting # keep a summary of commodities found using in-game names +# Assumes that the commodity data has already been 'fixed up' def addcommodities(data): if not data['lastStarport'].get('commodities'): return @@ -31,10 +32,10 @@ def addcommodities(data): size_pre = len(commodities) for commodity in data['lastStarport'].get('commodities'): - key = commodity_map.get(commodity['name']) or commodity['name'] + key = commodity['name'] new = { 'id' : commodity['id'], - 'category' : category_map.get(commodity['categoryname']) or commodity['categoryname'], + 'category' : commodity['categoryname'], 'average' : commodity['cost_mean'].split('.')[0] } old = commodities.get(key) diff --git a/companion.py b/companion.py index 32c184c3..90de7091 100644 --- a/companion.py +++ b/companion.py @@ -47,6 +47,7 @@ commodity_map= { 'Hafnium178' : 'Hafnium 178', 'Hazardous Environment Suits' : 'H.E. Suits', 'Heliostatic Furnaces' : 'Microbial Furnaces', + 'Ion Distributor' :('Machinery', 'Ion Distributor'), 'Low Temperature Diamond' : 'Low Temperature Diamonds', 'Marine Supplies' : 'Marine Equipment', 'Meta Alloys' : 'Meta-Alloys', @@ -58,7 +59,7 @@ commodity_map= { 'S A P8 Core Container' : 'SAP 8 Core Container', # Not seen in E:D 1.4 or later? 'Skimer Components' : 'Skimmer Components', 'Terrain Enrichment Systems' : 'Land Enrichment Systems', - 'Trinkets Of Fortune' : 'Trinkets Of Hidden Fortune', + 'Trinkets Of Fortune' :('Consumer Items', 'Trinkets Of Hidden Fortune'), 'Unknown Artifact' : 'Unknown Artefact', 'Unknown Artifact2' : 'Unknown Probe', # untested 'U S S Cargo Ancient Artefact' : 'Ancient Artefact', @@ -293,7 +294,11 @@ class Session: else: # Rewrite text fields commodity['categoryname'] = category_map.get(commodity['categoryname'], commodity['categoryname']) - commodity['name'] = commodity_map.get(commodity['name'], commodity['name']) + fixed = commodity_map.get(commodity['name']) + if type(fixed) == tuple: + (commodity['categoryname'], commodity['name']) = fixed + elif fixed: + commodity['name'] = fixed # Force demand and stock to zero if their corresponding bracket is zero # Fixes spurious "demand": 1 in ED 1.3 diff --git a/flightlog.py b/flightlog.py index cc72f8d8..42e74d46 100644 --- a/flightlog.py +++ b/flightlog.py @@ -8,7 +8,7 @@ from sys import platform import time from config import config -from companion import commodity_map, ship_map +from companion import ship_map logfile = None @@ -46,7 +46,7 @@ def export(data): commodities = defaultdict(int) for item in data['ship'].get('cargo',{}).get('items',[]): if item['commodity'] != 'drones': - commodities[commodity_map.get(item['commodity'], item['commodity'])] += item['qty'] + commodities[item['commodity']] += item['qty'] writelog(querytime, data['lastSystem']['name'],