mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-06-09 03:42:16 +03:00
Include numeric FDevIDs in command-line output
This commit is contained in:
parent
26415df492
commit
b8c2430c53
@ -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']])
|
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:
|
else:
|
||||||
sep = ','
|
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']])
|
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
|
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']]
|
bracketmap[commodity['stockBracket']]
|
||||||
])
|
])
|
||||||
if kind==COMMODITY_DEFAULT:
|
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:
|
else:
|
||||||
line = sep.join([line, timestamp, '\n'])
|
line = sep.join([line, timestamp, '\n'])
|
||||||
h.write(line.encode('utf-8'))
|
h.write(line.encode('utf-8'))
|
||||||
|
@ -457,7 +457,7 @@ def export(data, filename):
|
|||||||
assert data['lastStarport'].get('name')
|
assert data['lastStarport'].get('name')
|
||||||
|
|
||||||
timestamp = time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime(querytime))
|
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'])
|
rowheader = '%s,%s' % (data['lastSystem']['name'], data['lastStarport']['name'])
|
||||||
|
|
||||||
h = open(filename, 'wt')
|
h = open(filename, 'wt')
|
||||||
@ -466,7 +466,7 @@ def export(data, filename):
|
|||||||
try:
|
try:
|
||||||
m = lookup(v, companion.ship_map)
|
m = lookup(v, companion.ship_map)
|
||||||
if m:
|
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:
|
except AssertionError as e:
|
||||||
if __debug__: print 'Outfitting: %s' % e # Silently skip unrecognized modules
|
if __debug__: print 'Outfitting: %s' % e # Silently skip unrecognized modules
|
||||||
except:
|
except:
|
||||||
|
@ -15,11 +15,11 @@ def export(data, filename):
|
|||||||
assert data['lastStarport'].get('ships')
|
assert data['lastStarport'].get('ships')
|
||||||
|
|
||||||
timestamp = time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime(querytime))
|
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'])
|
rowheader = '%s,%s' % (data['lastSystem']['name'], data['lastStarport']['name'])
|
||||||
|
|
||||||
h = open(filename, 'wt')
|
h = open(filename, 'wt')
|
||||||
h.write(header)
|
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]:
|
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\n' % (rowheader, name, timestamp))
|
h.write('%s,%s,%s,%s\n' % (rowheader, name, fdevid, timestamp))
|
||||||
h.close()
|
h.close()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user