mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-06-04 01:21:03 +03:00
parent
02772872fd
commit
98059e1d18
52
shipyard.py
Normal file
52
shipyard.py
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
# Export list of ships as CSV
|
||||||
|
|
||||||
|
import time
|
||||||
|
|
||||||
|
from config import config
|
||||||
|
|
||||||
|
|
||||||
|
ship_map = {
|
||||||
|
'adder' : 'Adder',
|
||||||
|
'anaconda' : 'Anaconda',
|
||||||
|
'asp' : 'Asp',
|
||||||
|
'cobramkiii' : 'Cobra Mk III',
|
||||||
|
'diamondback' : 'Diamondback Scout',
|
||||||
|
'diamondbackxl' : 'Diamondback Explorer',
|
||||||
|
'eagle' : 'Eagle',
|
||||||
|
'empire_courier' : 'Imperial Courier',
|
||||||
|
'empire_eagle' : 'Imperial Eagle',
|
||||||
|
'empire_fighter' : 'Imperial Fighter',
|
||||||
|
'empire_trader' : 'Imperial Clipper',
|
||||||
|
'federation_dropship' : 'Federal Dropship',
|
||||||
|
'federation_dropship_mkii' : 'Federal Assault Ship',
|
||||||
|
'federation_gunship' : 'Federal Gunship',
|
||||||
|
'federation_fighter' : 'F63 Condor',
|
||||||
|
'ferdelance' : 'Fer-de-Lance',
|
||||||
|
'hauler' : 'Hauler',
|
||||||
|
'orca' : 'Orca',
|
||||||
|
'python' : 'Python',
|
||||||
|
'sidewinder' : 'Sidewinder',
|
||||||
|
'type6' : 'Type-6 Transporter',
|
||||||
|
'type7' : 'Type-7 Transporter',
|
||||||
|
'type9' : 'Type-9 Heavy',
|
||||||
|
'viper' : 'Viper',
|
||||||
|
'vulture' : 'Vulture',
|
||||||
|
}
|
||||||
|
|
||||||
|
def export(data, filename):
|
||||||
|
|
||||||
|
querytime = config.getint('querytime') or int(time.time())
|
||||||
|
|
||||||
|
assert data['lastSystem'].get('name')
|
||||||
|
assert data['lastStarport'].get('name')
|
||||||
|
assert data['lastStarport'].get('ships')
|
||||||
|
|
||||||
|
timestamp = time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime(querytime))
|
||||||
|
header = 'System,Station,Ship,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))
|
||||||
|
h.close()
|
Loading…
x
Reference in New Issue
Block a user