mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-13 07:47:14 +03:00
Send 2.4-style mod info to EDShipyard and Coriolis
This commit is contained in:
parent
771e786eaa
commit
6ffcfc74a1
29
companion.py
29
companion.py
@ -381,20 +381,27 @@ def ship(data):
|
||||
# subset of "ship" that's not noisy
|
||||
description = {}
|
||||
for props in [
|
||||
('cargo', 'capacity'),
|
||||
('free',),
|
||||
('fuel', 'main', 'capacity'),
|
||||
('fuel', 'reserve', 'capacity'),
|
||||
('id',),
|
||||
('name',),
|
||||
('value', 'hull'),
|
||||
('value', 'modules'),
|
||||
('value', 'unloaned'),
|
||||
('cargo', 'capacity'),
|
||||
('free',),
|
||||
('fuel', 'main', 'capacity'),
|
||||
('fuel', 'reserve', 'capacity'),
|
||||
('id',),
|
||||
('launchBays',),
|
||||
('name',),
|
||||
('shipID',),
|
||||
('shipName',),
|
||||
('value', 'hull'),
|
||||
('value', 'modules'),
|
||||
('value', 'unloaned'),
|
||||
]: addleaf(data['ship'], description, props)
|
||||
|
||||
description['modules'] = {}
|
||||
for slot in data['ship'].get('modules', {}):
|
||||
for prop in ['free', 'id', 'modifiers', 'name', 'on', 'priority', 'recipeLevel', 'recipeName', 'recipeValue', 'unloaned', 'value']:
|
||||
addleaf(data['ship']['modules'], description['modules'], (slot, 'module', prop))
|
||||
for prop in data['ship']['modules'][slot]:
|
||||
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
|
||||
|
@ -18,7 +18,7 @@ import companion
|
||||
# Return a URL for the current ship
|
||||
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()
|
||||
with gzip.GzipFile(fileobj=out, mode='w') as f:
|
||||
|
@ -154,7 +154,7 @@ def export(data, filename=None):
|
||||
# Return a URL for the current ship
|
||||
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()
|
||||
with gzip.GzipFile(fileobj=out, mode='w') as f:
|
||||
|
@ -11,7 +11,7 @@ import companion
|
||||
# Export ship loadout in Companion API json format
|
||||
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:
|
||||
with open(filename, 'wt') as h:
|
||||
|
Loading…
x
Reference in New Issue
Block a user