Skip to content

Commit

Permalink
Settings functionality to add/update last processed index in specifie…
Browse files Browse the repository at this point in the history
…d Paradox file for specified task. Task is accessed by GUID since user can remove task and add task with same name but different files.
  • Loading branch information
grigoryvp committed Mar 2, 2012
1 parent 5d4413d commit a0ebbc2
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
dst TEXT);
CREATE TABLE IF NOT EXISTS index_last (
guid TEXT,
name TEXT,
file TEXT,
index_last INTEGER);
"""
SQL_TASK_ADD = """INSERT INTO task (guid, name, src, dst)
Expand All @@ -26,6 +26,10 @@
SQL_TASK_DEL_BY_NAME = """DELETE FROM task WHERE name = :name"""
SQL_TASK_GUID_BY_NAME = """SELECT guid FROM task WHERE name = :name"""
SQL_INDEX_LAST_DEL = """DELETE FROM index_last WHERE guid = :guid"""
SQL_INDEX_LAST_UPDATE = """UPDATE index_last SET index_last = :index_last
WHERE guid = :guid AND file = :file"""
SQL_INDEX_LAST_ADD = """INSERT INTO index_last (guid, file, index_last)
VALUES (:guid, :file, :index_last)"""

class Settings( object ) :

Expand Down Expand Up @@ -66,6 +70,19 @@ def taskAdd( self, i_sName, i_sSrc, i_sDst ) :
finally :
self.notifyIfNeeded()

@classmethod
def indexLastSet( i_sGuid, i_sFile, i_nIndex ) :
with sqlite3.connect( FILE_CFG ) as oConn :
mArgs = {
'guid' : i_sGuid,
'file' : i_sFile,
'index_last' : i_nIndex }
oRet = oConn.execute( SQL_INDEX_LAST_UPDATE, mArgs )
if oRet.rowcount > 0 :
return
## No record for guid and name pair: add one.
oConn.execute( SQL_INDEX_LAST_ADD, mArgs )

@classmethod
def taskDelByName( self, i_sName ) :
with sqlite3.connect( FILE_CFG ) as oConn :
Expand Down

0 comments on commit a0ebbc2

Please sign in to comment.