From b8c2430c53d92d09c3095af551acff3f68835d85 Mon Sep 17 00:00:00 2001 From: Jonathan Harris Date: Mon, 5 Mar 2018 23:36:38 +0000 Subject: [PATCH] Include numeric FDevIDs in command-line output --- commodity.py | 4 ++-- outfitting.py | 4 ++-- shipyard.py | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/commodity.py b/commodity.py index e9b91961..87e4701c 100644 --- a/commodity.py +++ b/commodity.py @@ -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')) diff --git a/outfitting.py b/outfitting.py index 25b3b4d2..7a9d7502 100644 --- a/outfitting.py +++ b/outfitting.py @@ -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: diff --git a/shipyard.py b/shipyard.py index a5b90129..fb6b2bf7 100644 --- a/shipyard.py +++ b/shipyard.py @@ -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()