Skip to content

Commit

Permalink
Better feedback on unrecognized station in .prices
Browse files Browse the repository at this point in the history
  • Loading branch information
kfsone committed Oct 26, 2014
1 parent aa0a1e5 commit 3892ff0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ files from other commanders to fill out your database.

v4.6.3 Oct 26/2014
. (kfsone) Fixed distance-related breakage in 4.6.2
. (kfsone) Improved error feedback while processing .prices file

v4.6.2 Oct 25/2014
. (kfsone) Added support for self-correcting star/station name changes,
Expand Down
15 changes: 14 additions & 1 deletion buildcache.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,14 @@ def __str__(self):
return "{}:{} {}".format(self.fileName, self.lineNo, self.error)


class UnknownStationError(BuildCacheBaseException):
"""
Raised when the file contains an unknown star/station name.
"""
def __init__(self, fromFile, lineNo, key):
error = "Unrecognized STAR/Station, '{}'.".format(key)
super().__init__(fromFile, lineNo, error)

class UnknownItemError(BuildCacheBaseException):
"""
Raised in the case of an item name that we don't know.
Expand Down Expand Up @@ -363,12 +371,17 @@ def genSQLFromPriceLines(priceFile, db, defaultZero, debug=0):
systemName = corrections.correct(matches.group(1))
stationName = corrections.correct(matches.group(2))
facility = systemName.upper() + '/' + stationName
stationID = systemByName[facility]
categoryID, uiOrder = None, 0

if debug > 1:
print("NEW STATION: {}".format(facility))

# Make sure it's valid.
try:
stationID = systemByName[facility]
except KeyError:
raise UnknownStationError(priceFile, lineNo, facility)

# Check for duplicates
if stationID in processedStations:
raise MultipleStationEntriesError(
Expand Down

0 comments on commit 3892ff0

Please sign in to comment.