Skip to content

Commit

Permalink
Stats on import
Browse files Browse the repository at this point in the history
  • Loading branch information
kfsone committed Jan 1, 2015
1 parent 7575f41 commit 46686cb
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
TradeDangerous, Copyright (C) Oliver "kfsone" Smith, July 2014
==============================================================================

Work In Progress:
. (kfsone) Import reports stats on completion (so its more obvious it worked)

v6.4.0 Jan 01 2015
. (kfsone) Added "rare" sub-command,
. (kfsone) Added RareItem table,
Expand Down
24 changes: 20 additions & 4 deletions cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ def processPrices(tdenv, priceFile, db, defaultZero):
categoryName = None
facility = None
processedStations = {}
processedSystems = set()
processedItems = {}
itemPrefix = ""
DELETED = corrections.DELETED
Expand Down Expand Up @@ -395,6 +396,7 @@ def changeStation(matches):
processedStations[stationID]
)

processedSystems.add(systemName)
processedStations[stationID] = lineNo
processedItems = {}

Expand Down Expand Up @@ -571,7 +573,11 @@ def processItemLine(matches):

processItemLine(matches)

return warnings, items, buys, sells

numSys = len(processedSystems)
numStn = len(processedStations)

return warnings, items, buys, sells, numSys, numStn


######################################################################
Expand All @@ -580,7 +586,7 @@ def processPricesFile(tdenv, db, pricesPath, pricesFh=None, defaultZero=False):
tdenv.DEBUG0("Processing Prices file '{}'", pricesPath)

with pricesFh or pricesPath.open('rU') as pricesFh:
warnings, items, buys, sells = processPrices(
warnings, items, buys, sells, numSys, numStn = processPrices(
tdenv, pricesFh, db, defaultZero
)

Expand All @@ -605,8 +611,18 @@ def processPricesFile(tdenv, db, pricesPath, pricesFh=None, defaultZero=False):

db.commit()

if warnings and not tdenv.quiet:
print("Import completed despite warnings")
if not tdenv.quiet:
if warnings:
print("NOTE: Import completed despite warnings")
print("Import complete: "
"{} items ({} buy prices, {} sell prices) "
"for {} stations "
"in {} systems".format(
len(items),
len(buys), len(sells),
numStn,
numSys,
))


######################################################################
Expand Down

0 comments on commit 46686cb

Please sign in to comment.