Skip to content

Commit

Permalink
More consistent use of Path
Browse files Browse the repository at this point in the history
  • Loading branch information
kfsone committed Dec 3, 2014
1 parent e0f481b commit 470614b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -804,14 +804,13 @@ def buildCache(tdenv, dbPath, sqlPath, pricesPath, importTables, defaultZero=Fal
dbFilename = str(dbPath)
# Create an in-memory database to populate with our data.
tdenv.DEBUG0("Creating temporary database in memory")
tempDBName = dbFilename + ".new"
backupDBName = dbFilename + ".prev"
tempPath, backupPath = Path(tempDBName), Path(backupDBName)
tempPath = dbPath.with_suffix(".new")
backupPath = dbPath.with_suffix(".prev")

if tempPath.exists():
tempPath.unlink()

tempDB = sqlite3.connect(tempDBName)
tempDB = sqlite3.connect(str(tempPath))
tempDB.execute("PRAGMA foreign_keys=ON")
# Read the SQL script so we are ready to populate structure, etc.
tdenv.DEBUG0("Executing SQL Script '{}' from '{}'", sqlPath, os.getcwd())
Expand Down Expand Up @@ -858,6 +857,8 @@ def importDataFromFile(tdb, tdenv, path, reset=False):
existing records for that station in the database.
"""

assert isinstance(path, Path)

if not path.exists():
raise TradeException("No such file: {}".format(
str(path)
Expand Down

0 comments on commit 470614b

Please sign in to comment.