1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-06-07 10:53:26 +03:00

Send 2.4-style mod info to EDShipyard and Coriolis

This commit is contained in:
Jonathan Harris 2017-08-24 19:21:53 +01:00
parent 771e786eaa
commit 6ffcfc74a1
4 changed files with 21 additions and 14 deletions

View File

@ -381,20 +381,27 @@ def ship(data):
# subset of "ship" that's not noisy # subset of "ship" that's not noisy
description = {} description = {}
for props in [ for props in [
('cargo', 'capacity'), ('cargo', 'capacity'),
('free',), ('free',),
('fuel', 'main', 'capacity'), ('fuel', 'main', 'capacity'),
('fuel', 'reserve', 'capacity'), ('fuel', 'reserve', 'capacity'),
('id',), ('id',),
('name',), ('launchBays',),
('value', 'hull'), ('name',),
('value', 'modules'), ('shipID',),
('value', 'unloaned'), ('shipName',),
('value', 'hull'),
('value', 'modules'),
('value', 'unloaned'),
]: addleaf(data['ship'], description, props) ]: addleaf(data['ship'], description, props)
description['modules'] = {} description['modules'] = {}
for slot in data['ship'].get('modules', {}): for slot in data['ship'].get('modules', {}):
for prop in ['free', 'id', 'modifiers', 'name', 'on', 'priority', 'recipeLevel', 'recipeName', 'recipeValue', 'unloaned', 'value']: for prop in data['ship']['modules'][slot]:
addleaf(data['ship']['modules'], description['modules'], (slot, 'module', prop)) if prop == 'module':
for prop2 in ['free', 'id', 'name', 'on', 'priority', 'value', 'unloaned']:
addleaf(data['ship']['modules'], description['modules'], (slot, prop, prop2))
else:
addleaf(data['ship']['modules'], description['modules'], (slot, prop))
return description return description

View File

@ -18,7 +18,7 @@ import companion
# Return a URL for the current ship # Return a URL for the current ship
def url(data, is_beta): def url(data, is_beta):
string = json.dumps(companion.ship(data), ensure_ascii=False, sort_keys=True, separators=(',', ':')) # most compact representation string = json.dumps(companion.ship(data), ensure_ascii=False, sort_keys=True, separators=(',', ':')).encode('utf-8') # most compact representation
out = StringIO.StringIO() out = StringIO.StringIO()
with gzip.GzipFile(fileobj=out, mode='w') as f: with gzip.GzipFile(fileobj=out, mode='w') as f:

View File

@ -154,7 +154,7 @@ def export(data, filename=None):
# Return a URL for the current ship # Return a URL for the current ship
def url(data, is_beta): def url(data, is_beta):
string = json.dumps(companion.ship(data), ensure_ascii=False, sort_keys=True, separators=(',', ':')) # most compact representation string = json.dumps(companion.ship(data), ensure_ascii=False, sort_keys=True, separators=(',', ':')).encode('utf-8') # most compact representation
out = StringIO.StringIO() out = StringIO.StringIO()
with gzip.GzipFile(fileobj=out, mode='w') as f: with gzip.GzipFile(fileobj=out, mode='w') as f:

View File

@ -11,7 +11,7 @@ import companion
# Export ship loadout in Companion API json format # Export ship loadout in Companion API json format
def export(data, filename=None): def export(data, filename=None):
string = json.dumps(companion.ship(data), ensure_ascii=False, indent=2, sort_keys=True, separators=(',', ': ')) # pretty print string = json.dumps(companion.ship(data), ensure_ascii=False, indent=2, sort_keys=True, separators=(',', ': ')).encode('utf-8') # pretty print
if filename: if filename:
with open(filename, 'wt') as h: with open(filename, 'wt') as h: