1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-13 15:57:14 +03:00

Include numeric FDevIDs in command-line output

This commit is contained in:
Jonathan Harris 2018-03-05 23:36:38 +00:00
parent 26415df492
commit b8c2430c53
3 changed files with 7 additions and 7 deletions

View File

@ -35,7 +35,7 @@ def export(data, kind=COMMODITY_DEFAULT, filename=None):
rowheader = sep.join([(config.getint('anonymous') and hashlib.md5(cmdr.encode('utf-8')).hexdigest()) or (sep in cmdr and '"%s"' % cmdr) or cmdr, data['lastSystem']['name'], data['lastStarport']['name']])
else:
sep = ','
header = sep.join(['System','Station','Commodity','Sell','Buy','Demand','','Supply','','Average','Date\n'])
header = sep.join(['System','Station','Commodity','Sell','Buy','Demand','','Supply','','Average','FDevID','Date\n'])
rowheader = sep.join([data['lastSystem']['name'], data['lastStarport']['name']])
h = open(filename, 'wt') # codecs can't automatically handle line endings, so encode manually where required
@ -53,7 +53,7 @@ def export(data, kind=COMMODITY_DEFAULT, filename=None):
bracketmap[commodity['stockBracket']]
])
if kind==COMMODITY_DEFAULT:
line = sep.join([line, str(int(commodity['meanPrice'])), timestamp+'\n'])
line = sep.join([line, str(int(commodity['meanPrice'])), str(commodity['id']), timestamp+'\n'])
else:
line = sep.join([line, timestamp, '\n'])
h.write(line.encode('utf-8'))

View File

@ -457,7 +457,7 @@ def export(data, filename):
assert data['lastStarport'].get('name')
timestamp = time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime(querytime))
header = 'System,Station,Category,Name,Mount,Guidance,Ship,Class,Rating,Date\n'
header = 'System,Station,Category,Name,Mount,Guidance,Ship,Class,Rating,FDevID,Date\n'
rowheader = '%s,%s' % (data['lastSystem']['name'], data['lastStarport']['name'])
h = open(filename, 'wt')
@ -466,7 +466,7 @@ def export(data, filename):
try:
m = lookup(v, companion.ship_map)
if m:
h.write('%s,%s,%s,%s,%s,%s,%s,%s,%s\n' % (rowheader, m['category'], m['name'], m.get('mount',''), m.get('guidance',''), m.get('ship',''), m['class'], m['rating'], timestamp))
h.write('%s,%s,%s,%s,%s,%s,%s,%s,%s,%s\n' % (rowheader, m['category'], m['name'], m.get('mount',''), m.get('guidance',''), m.get('ship',''), m['class'], m['rating'], m['id'], timestamp))
except AssertionError as e:
if __debug__: print 'Outfitting: %s' % e # Silently skip unrecognized modules
except:

View File

@ -15,11 +15,11 @@ def export(data, filename):
assert data['lastStarport'].get('ships')
timestamp = time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime(querytime))
header = 'System,Station,Ship,Date\n'
header = 'System,Station,Ship,FDevID,Date\n'
rowheader = '%s,%s' % (data['lastSystem']['name'], data['lastStarport']['name'])
h = open(filename, 'wt')
h.write(header)
for name in [ship_map[ship['name'].lower()] for ship in (data['lastStarport']['ships'].get('shipyard_list') or {}).values() + data['lastStarport']['ships'].get('unavailable_list') if ship['name'].lower() in ship_map]:
h.write('%s,%s,%s\n' % (rowheader, name, timestamp))
for (name,fdevid) in [(ship_map.get(ship['name'].lower(), ship['name']), ship['id']) for ship in (data['lastStarport']['ships'].get('shipyard_list') or {}).values() + data['lastStarport']['ships'].get('unavailable_list')]:
h.write('%s,%s,%s,%s\n' % (rowheader, name, fdevid, timestamp))
h.close()