Skip to content

Commit

Permalink
Added --ignore-unknown option to buildcache
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliver Smith committed Nov 23, 2014
1 parent c85ed3f commit 45879bf
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ v6.0.5 Nov 22 2014 (w/Gamma 1)
. (kfsone) Added "--height" (-H) option to update GUI
. (kfsone) Added "--front" (-F) to keep the update gui infront of TD
. (kfsone) Added Pilot's Federation/Jameson Memorial
. (kfsone) Added '--ignore-unknown' option to buildcache

v6.0.4 Nov 21 2014 (Beta 3.9.1)
. (kfsone) Added "sell" command (find places to sell a specific item)
Expand Down
24 changes: 21 additions & 3 deletions cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,12 @@ def changeStation(matches):
facility, stationNameIn,
), file=sys.stderr)
if stationID < 0 :
raise UnknownStationError(priceFile, lineNo, facility) from None
ex = UnknownStationError(priceFile, lineNo, facility)
if not tdenv.ignoreUnknown:
raise ex
stationID = DELETED
print(ex)
return

# Check for duplicates
if stationID in processedStations:
Expand All @@ -443,6 +448,7 @@ def changeStation(matches):
def changeCategory(matches):
nonlocal uiOrder, categoryID

categoryID = -1
categoryName, uiOrder = matches.group(1), 0

tdenv.DEBUG1("NEW CATEGORY: {}", categoryName)
Expand All @@ -461,7 +467,12 @@ def changeCategory(matches):
categoryID = categoriesByName[categoryName]
tdenv.DEBUG1("Renamed: {}", categoryName)
except KeyError:
raise UnknownCategoryError(priceFile, lineNo, categoryName)
ex = UnknownCategoryError(priceFile, lineNo, categoryName)
if not tdenv.ignoreUnknown:
raise ex
print(ex)
categoryID = DELETED
return


def processItemLine(matches):
Expand Down Expand Up @@ -500,7 +511,11 @@ def processItemLine(matches):
itemID = itemByName[itemPrefix + itemName]
tdenv.DEBUG1("Renamed {} -> {}", oldName, itemName)
except KeyError:
raise UnknownItemError(priceFile, lineNo, itemName)
ex = UnknownItemError(priceFile, lineNo, itemName)
if not tdenv.ignoreUnknown:
raise ex
print(ex)
return

# Check for duplicate items within the station.
if itemID in processedItems:
Expand Down Expand Up @@ -553,6 +568,9 @@ def processItemLine(matches):
raise SyntaxError(priceFile, lineNo,
"Expecting '+ Category Name' line", text)

if categoryID == DELETED:
continue

########################################
### "Item sell buy ..." lines.
matches = newItemPriceRe.match(text)
Expand Down
11 changes: 10 additions & 1 deletion commands/buildcache_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,16 @@
"replace a defaulted station name. Corrections are "
"printed to stderr so you can capture them and add them "
"to your data/corrections.py."
)
),
),
ParseArgument(
'--ignore-unknown',
default=False, action='store_true',
dest='ignoreUnknown',
help=(
"Data for systems, stations and items that are not "
"recognized is reported as warning but skipped."
),
),
]

Expand Down

0 comments on commit 45879bf

Please sign in to comment.