Skip to content

Commit

Permalink
lookupStation will now take a system in which to search for said station
Browse files Browse the repository at this point in the history
  • Loading branch information
kfsone committed Sep 5, 2014
1 parent cab0110 commit e4ba25e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion tradedb.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ def _loadStations(self):
if self.debug > 1: print("# Loaded %d Stations" % len(stationByID))


def lookupStation(self, name):
def lookupStation(self, name, system=None):
"""
Look up a Station object by it's name or system.
"""
Expand All @@ -477,6 +477,10 @@ def lookupStation(self, name):
raise ValueError("System '%s' has %d stations, please specify a station instead." % (name.str(), len(name.stations)))
return name.stations[0]

if system:
system = self.lookupSystem(system)
return TradeDB.listSearch("Station", name, system.stations, key=lambda system: system.dbname)

stationID, station, systemID, system = None, None, None, None
try:
system = TradeDB.listSearch("System", name, self.systemByID.values(), key=lambda system: system.dbname)
Expand Down

0 comments on commit e4ba25e

Please sign in to comment.