mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-17 17:42:20 +03:00
cleanup coriolis.py
This commit is contained in:
parent
f08d60d9b1
commit
87b7f639bb
@ -7,17 +7,21 @@ import io
|
|||||||
|
|
||||||
# Migrate settings from <= 3.01
|
# Migrate settings from <= 3.01
|
||||||
from config import config
|
from config import config
|
||||||
|
|
||||||
if not config.get('shipyard_provider') and config.getint('shipyard'):
|
if not config.get('shipyard_provider') and config.getint('shipyard'):
|
||||||
config.set('shipyard_provider', 'Coriolis')
|
config.set('shipyard_provider', 'Coriolis')
|
||||||
|
|
||||||
config.delete('shipyard')
|
config.delete('shipyard')
|
||||||
|
|
||||||
|
|
||||||
def plugin_start3(plugin_dir):
|
def plugin_start3(_):
|
||||||
return 'Coriolis'
|
return 'Coriolis'
|
||||||
|
|
||||||
# Return a URL for the current ship
|
|
||||||
def shipyard_url(loadout, is_beta):
|
def shipyard_url(loadout, is_beta):
|
||||||
string = json.dumps(loadout, ensure_ascii=False, sort_keys=True, separators=(',', ':')).encode('utf-8') # most compact representation
|
"""Return a URL for the current ship"""
|
||||||
|
# most compact representation
|
||||||
|
string = json.dumps(loadout, ensure_ascii=False, sort_keys=True, separators=(',', ':')).encode('utf-8')
|
||||||
if not string:
|
if not string:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -25,4 +29,7 @@ def shipyard_url(loadout, is_beta):
|
|||||||
with gzip.GzipFile(fileobj=out, mode='w') as f:
|
with gzip.GzipFile(fileobj=out, mode='w') as f:
|
||||||
f.write(string)
|
f.write(string)
|
||||||
|
|
||||||
return (is_beta and 'https://beta.coriolis.io/import?data=' or 'https://coriolis.io/import?data=') + base64.urlsafe_b64encode(out.getvalue()).decode().replace('=', '%3D')
|
encoded = base64.urlsafe_b64encode(out.getvalue()).decode().replace('=', '%3D')
|
||||||
|
url = 'https://beta.coriolis.io/import?data=' if is_beta else 'https://coriolis.io/import?data='
|
||||||
|
|
||||||
|
return f"{url}{encoded}"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user