1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-14 00:07:14 +03:00

Handle new Cargo event variant in 3.3

This commit is contained in:
Jonathan Harris 2018-10-31 19:11:55 +00:00
parent 10b36aa60b
commit 8c3b0b8de3

View File

@ -491,6 +491,9 @@ class EDLogs(FileSystemEventHandler):
elif entry['event'] == 'Cargo':
self.state['Cargo'] = defaultdict(int)
if 'Inventory' not in entry: # From 3.3 full Cargo event (after the first one) is written to a separate file
with open(join(self.currentdir, 'Cargo.json'), 'rb') as h:
entry = json.load(h, object_pairs_hook=OrderedDict) # Preserve property order because why not?
self.state['Cargo'].update({ self.canonicalise(x['Name']): x['Count'] for x in entry['Inventory'] })
elif entry['event'] in ['CollectCargo', 'MarketBuy', 'BuyDrones', 'MiningRefined']:
commodity = self.canonicalise(entry['Type'])