Skip to content

Commit

Permalink
Added mechanism for supporting star/station name changes
Browse files Browse the repository at this point in the history
  • Loading branch information
kfsone committed Oct 26, 2014
1 parent 3971e19 commit 62004d1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
8 changes: 5 additions & 3 deletions buildcache.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from pathlib import Path
from collections import namedtuple
from tradeexcept import TradeException
from data import corrections

# Find the non-comment part of a string
noCommentRe = re.compile(r'^\s*(?P<text>(?:[^\\#]|\\.)*)\s*(#|$)')
Expand Down Expand Up @@ -196,9 +197,10 @@ def genSQLFromPriceLines(priceFile, db, defaultZero, debug=0):
matches = systemStationRe.match(text)
if matches:
# Change which station we're at
stationName = "%s/%s" % (matches.group(1).upper(), matches.group(2))
stationID, categoryID, uiOrder = systemByName[stationName], None, 0
if debug > 1: print("NEW STATION: {}".format(stationName))
systemName, stationName = (corrections.correct(matches.group(1)), corrections.correct(matches.group(2)))
facility = systemName.upper() + '/' + stationName
stationID, categoryID, uiOrder = systemByName[facility], None, 0
if debug > 1: print("NEW STATION: {}".format(facility))
continue
if not stationID:
print("Expecting: '@ SYSTEM / Station'.")
Expand Down
14 changes: 14 additions & 0 deletions data/corrections.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Provides an interface for correcting star/station names that
# have changed in recent versions.

corrections = {
'LOUIS DE LACAILLE PROSPECT': 'Lacaille Prospect',
'HOPKINS HANGAR': 'Hopkins Hanger',
}

def correct(oldName):
try:
return corrections[oldName.upper()]
except KeyError:
return oldName

0 comments on commit 62004d1

Please sign in to comment.