1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-08 05:20:03 +03:00
Athanasius ef3306e3f5 Remove all use of defunct 'anonymous' option
The UI for setting the 'anonymous' option was removed in
f17f5d3f257e2359d4728ce8c296d70dc5e7609f ("PKCE OAuth2 access to cAPI").
Since then there's been no way for a user to set, or unset, this option
(and the associated custom uploaderID).  However anyone with the registry keys
still set would have had them take effect.

This commit removes the last bits of code that were making use of it.

Note that the EDDN Relay anonymises all uploaderID values, so no listener
has been seeing the 'raw' values for a long time now.

close #575
2020-07-10 08:36:13 +01:00

64 lines
2.6 KiB
Python

# Export to Trade Dangerous
from os.path import join
from collections import defaultdict
import codecs
import numbers
from operator import itemgetter
from platform import system
from sys import platform
import time
from config import applongname, appversion, config
demandbracketmap = { 0: '?',
1: 'L',
2: 'M',
3: 'H', }
stockbracketmap = { 0: '-',
1: 'L',
2: 'M',
3: 'H', }
def export(data):
querytime = config.getint('querytime') or int(time.time())
filename = join(config.get('outdir'), '%s.%s.%s.prices' % (data['lastSystem']['name'].strip(), data['lastStarport']['name'].strip(), time.strftime('%Y-%m-%dT%H.%M.%S', time.localtime(querytime))))
timestamp = time.strftime('%Y-%m-%d %H:%M:%S', time.strptime(data['timestamp'], '%Y-%m-%dT%H:%M:%SZ'))
# Format described here: https://bitbucket.org/kfsone/tradedangerous/wiki/Price%20Data
h = open(filename, 'wb') # codecs can't automatically handle line endings, so encode manually where required
h.write('#! trade.py import -\n# Created by {appname} {appversion} on {platform} for Cmdr {cmdr}.\n'
'#\n# <item name> <sellCR> <buyCR> <demand> <stock> <timestamp>\n\n'
'@ {system}/{starport}\n'.format(
appname=applongname,
appversion=appversion,
platform=platform == 'darwin' and "Mac OS" or system(),
cmdr=data['commander']['name'].strip(),
system=data['lastSystem']['name'].strip(),
starport=data['lastStarport']['name'].strip()
).encode('utf-8'))
# sort commodities by category
bycategory = defaultdict(list)
for commodity in data['lastStarport']['commodities']:
bycategory[commodity['categoryname']].append(commodity)
for category in sorted(bycategory):
h.write(' + {}\n'.format(category).encode('utf-8'))
# corrections to commodity names can change the sort order
for commodity in sorted(bycategory[category], key=itemgetter('name')):
h.write(' {:<23} {:7d} {:7d} {:9}{:1} {:8}{:1} {}\n'.format(
commodity['name'],
int(commodity['sellPrice']),
int(commodity['buyPrice']),
int(commodity['demand']) if commodity['demandBracket'] else '',
demandbracketmap[commodity['demandBracket']],
int(commodity['stock']) if commodity['stockBracket'] else '',
stockbracketmap[commodity['stockBracket']],
timestamp).encode('utf-8'))
h.close()