Only send outfitting data for stations that eddb thinks provide outfitting.

Update stations database from eddb.
This commit is contained in:
Jonathan Harris committed 2015-10-10 19:41:46 +01:00
1 parent 51a57e1a60
commit f6e6af63bd
3 files changed
+12 -12

No files matched your search

+9 -9
View File
@@ -85,7 +85,7 @@ class HyperlinkLabel(ttk.Label):
class AppWindow:
STATION_UNDOCKED = '-' # "Station" name to display when not docked
STATION_UNDOCKED = '×' # "Station" name to display when not docked = U+00D7
def __init__(self, master):
@@ -319,11 +319,9 @@ class AppWindow:
else:
# Finally - the data looks sane and we're docked at a station
(station_id, has_shipyard, has_outfitting) = EDDB.station(self.system['text'], self.station['text'])
station = EDDB.station(self.system['text'], self.station['text'])
has_shipyard = station and station[1]
if (config.getint('output') & config.OUT_EDDN) and not data['lastStarport'].get('commodities') and not data['lastStarport'].get('modules') and not has_shipyard:
if (config.getint('output') & config.OUT_EDDN) and not data['lastStarport'].get('commodities') and not has_outfitting and not has_shipyard:
self.status['text'] = _("Station doesn't have anything!")
elif not data['lastStarport'].get('commodities'):
@@ -345,7 +343,9 @@ class AppWindow:
self.status['text'] = _('Sending data to EDDN...')
self.w.update_idletasks()
eddn.export_commodities(data)
eddn.export_outfitting(data)
if has_outfitting:
# Only send if eddb says that the station provides outfitting
eddn.export_outfitting(data)
if has_shipyard:
# Only send if eddb says that the station has a shipyard -
# https://github.com/Marginal/EDMarketConnector/issues/16
@@ -413,9 +413,9 @@ class AppWindow:
def station_url(self, text):
if text:
station = EDDB.station(self.system['text'], self.station['text'])
if station:
return 'http://eddb.io/station/%d' % station[0]
(station_id, has_shipyard, has_outfitting) = EDDB.station(self.system['text'], self.station['text'])
if station_id:
return 'http://eddb.io/station/%d' % station_id
system_id = EDDB.system(self.system['text'])
if system_id:
+3 -3
View File
@@ -19,9 +19,9 @@ class EDDB:
def system(self, system_name):
return self.system_ids.get(system_name, 0) # return 0 on failure (0 is not a valid id)
# (system_name, station_name) -> (station_id, has_shipyard) or None
# (system_name, station_name) -> (station_id, has_shipyard, has_outfitting)
def station(self, system_name, station_name):
return self.station_ids.get((self.system_ids.get(system_name), station_name))
return self.station_ids.get((self.system_ids.get(system_name), station_name), (0,False,False))
def respath(self):
if getattr(sys, 'frozen', False):
@@ -54,6 +54,6 @@ if __name__ == "__main__":
cPickle.dump(system_ids, open('systems.p', 'wb'), protocol = cPickle.HIGHEST_PROTOCOL)
# station_id by (system_id, station_name)
station_ids = dict([((x['system_id'], str(x['name'])), (x['id'],bool(x['has_shipyard']))) for x in stations])
station_ids = dict([((x['system_id'], str(x['name'])), (x['id'], bool(x['has_shipyard']), bool(x['has_outfitting']))) for x in stations])
cPickle.dump(station_ids, open('stations.p', 'wb'), protocol = cPickle.HIGHEST_PROTOCOL)
BIN
View File
Binary file not shown.