Skip to content

Commit

Permalink
Merge branch 'master' into devel
Browse files Browse the repository at this point in the history
  • Loading branch information
bgol committed Nov 4, 2014
2 parents 637e138 + 137d403 commit 92740a5
Show file tree
Hide file tree
Showing 10 changed files with 1,555 additions and 573 deletions.
11 changes: 11 additions & 0 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@ files from other commanders to fill out your database.
== CHANGE LOG
==============================================================================

CAUTION: So many systems changed with the Beta 3 update that old prices files
won't stand a chance of containing many valid systems. You may want to obtain
a fresh file from one of the online sources, e.g.
maddavo's site: http://www.davek.com.au/td/default.asp

v5.0.1 Nov 4/2014
. (kfsone) Issue #49 Errors in Ambiguity Error
. (kfsone) Issue #51 L and ? items weren't honoring qty limits
. (kfsone) Issue #50 Interaction between -0 and demand for a sold item
. (Smacker65) Beta 3 Systems with markets

v5.0.0 Oct 31/2014
. (kfsone) Initial Beta 3 changes
- Improved the "corrections" system which facilitates changing names
Expand Down
35 changes: 34 additions & 1 deletion buildcache.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ def genSQLFromPriceLines(priceFile, db, defaultZero, debug=0):
processedStations = {}
processedItems = {}
itemPrefix = ""
DELETED = corrections.DELETED

for line in priceFile:
lineNo += 1
Expand Down Expand Up @@ -382,6 +383,11 @@ def genSQLFromPriceLines(priceFile, db, defaultZero, debug=0):
except KeyError:
systemName = corrections.correctSystem(systemName)
stationName = corrections.correctStation(stationName)
if systemName == DELETED or stationName == DELETED:
if debug > 1:
print("- DELETED: {}".format(facility))
stationID = DELETED
continue
facility = systemName.upper() + '/' + stationName
try:
stationID = systemByName[facility]
Expand All @@ -405,6 +411,9 @@ def genSQLFromPriceLines(priceFile, db, defaultZero, debug=0):
# Need a station to process any other type of line.
raise SyntaxError(priceFile, lineNo,
"Expecting '@ SYSTEM / Station' line", text)
if stationID == DELETED:
# Ignore all values from a deleted station/system.
continue

########################################
### "+ Category" lines.
Expand All @@ -419,6 +428,9 @@ def genSQLFromPriceLines(priceFile, db, defaultZero, debug=0):
categoryID = categoriesByName[categoryName]
except KeyError:
categoryName = corrections.correctCategory(categoryName)
if categoryName == DELETED:
### TODO: Determine correct way to handle this.
raise SyntaxError("Category has been deleted.")
try:
categoryID = categoriesByName[categoryName]
if debug > 1:
Expand Down Expand Up @@ -464,6 +476,10 @@ def genSQLFromPriceLines(priceFile, db, defaultZero, debug=0):
except KeyError:
oldName = itemName
itemName = corrections.correctItem(itemName)
if itemName == DELETED:
if debug > 1:
print("- DELETED {}".format(oldName))
continue
try:
itemID = itemByName[itemPrefix + itemName]
if debug > 1:
Expand Down Expand Up @@ -580,12 +596,29 @@ def processImportFile(db, importPath, tableName, debug=0):

# import the data
importCount = 0
lineNo = 0
for linein in csvin:
if len(linein) == columnCount:
if debug > 1:
print("- Values: {}".format(', '.join(linein)))
db.execute(sql_stmt, linein)
try:
db.execute(sql_stmt, linein)
except Exception as e:
raise SystemExit(
"*** INTERNAL ERROR: {err}\n"
"CSV File: {file}:{line}\n"
"SQL Query: {query}\n"
"Params: {params}\n"
.format(
err=str(e),
file=str(importPath),
line=lineNo,
query=sql_stmt.strip(),
params=linein
)
) from None
importCount += 1
++lineNo
db.commit()
if debug:
print("* {count} {table}s imported". \
Expand Down
4 changes: 3 additions & 1 deletion data/Added.csv
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ name
'Premium Beta2'
'Beta1'
'Beta2'
'Beta2-Inferred'
'Beta2-Inferred'
'Beta2 (unverified)'
'Beta3'
2 changes: 0 additions & 2 deletions data/ShipVendor.csv
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
[email protected]_id,[email protected]_id,cost
'Anaconda','Lacaille Prospect',0
'Cobra','Aulin Enterprise',0
'Cobra','Chango Dock',0
'Eagle','Aulin Enterprise',0
Expand All @@ -8,7 +7,6 @@ [email protected]_id,[email protected]_id,cost
'Hauler','Beagle 2 Landing',0
'Lakon Type 6','Aulin Enterprise',0
'Lakon Type 6','Chango Dock',0
'Lakon Type 6','Vonarburg Co-operative',0
'Lakon Type 9','Chango Dock',0
'Sidewinder','Aulin Enterprise',0
'Sidewinder','Beagle 2 Landing',0
Expand Down
Loading

0 comments on commit 92740a5

Please sign in to comment.