From 633edd5381cf0c2aae4e6aff6bee5df292c926e3 Mon Sep 17 00:00:00 2001 From: Jonathan Harris Date: Wed, 26 Oct 2016 01:51:54 +0100 Subject: [PATCH] Fix for offline collation --- collate.py | 4 ++-- edshipyard.py | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/collate.py b/collate.py index 04ba176b..852f2864 100755 --- a/collate.py +++ b/collate.py @@ -175,8 +175,8 @@ if __name__ == "__main__": print 'No starport!' else: if data['lastStarport'].get('commodities'): - session.fixup(data['lastStarport']['commodities']) - addcommodities(data) + fixed = session.fixup(data) + addcommodities(fixed) else: print 'No market' if data['lastStarport'].get('modules'): diff --git a/edshipyard.py b/edshipyard.py index 0e7ac68c..bce50396 100644 --- a/edshipyard.py +++ b/edshipyard.py @@ -19,8 +19,9 @@ def export(data, filename=None): # special handling for completely empty trees p = props[0] - if not data[p]: + if p in data and not data[p]: to[p] = data[p] + return # Does the leaf exist ? tail = data @@ -47,17 +48,22 @@ def export(data, filename=None): # subset of "ship" that's not noisy ship = {} for props in [ + ('alive',), ('cargo', 'capacity'), + ('free',), ('fuel', 'main', 'capacity'), ('fuel', 'reserve', 'capacity'), ('fuel', 'superchargedFSD'), ('id',), ('name',), + ('value', 'hull'), + ('value', 'modules'), + ('value', 'unloaned'), ]: addleaf(data['ship'], ship, props) ship['modules'] = {} for slot in data['ship'].get('modules', {}): - for prop in ('id', 'modifiers', 'name', 'on', 'priority'): + for prop in ['free', 'id', 'modifiers', 'name', 'on', 'priority', 'recipeLevel', 'recipeName', 'recipeValue', 'unloaned', 'value']: addleaf(data['ship']['modules'], ship['modules'], (slot, 'module', prop)) string = json.dumps(ship, ensure_ascii=False, indent=2, sort_keys=True, separators=(',', ': ')).encode('utf-8')