<s> import sys <EOL> if sys . version < '<STR_LIT:3>' : <EOL> from c import * <EOL> else : <EOL> from . c import * <EOL> class TodoTask ( ) : <EOL> id = <NUM_LIT:0> <EOL> project = '<STR_LIT>' <EOL> state = '<STR_LIT>' <EOL> tagsA = [ ] <EOL> lvl = <NUM_LIT:0> <EOL> fileName = '<STR_LIT>' <EOL> comment = '<STR_LIT>' <EOL> editor = '<STR_LIT>' <EOL> stamp = False <EOL> old_state = '<STR_LIT>' <EOL> old_tagsA = [ ] <EOL> old_lvl = '<STR_LIT>' <EOL> old_fileName = '<STR_LIT>' <EOL> old_comment = '<STR_LIT>' <EOL> parentDb = False <EOL> savedA = { } <EOL> initial = True <EOL> def __init__ ( self , _id , _project , _parentDB ) : <EOL> self . id = _id <EOL> self . project = _project <EOL> self . savedA = { } <EOL> self . parentDb = _parentDB <EOL> self . setSaved ( SAVE_STATES . IDLE ) <EOL> self . initial = True <EOL> def setTags ( self , _tagsA ) : <EOL> self . tagsA = [ ] <EOL> for tagName in _tagsA : self . tagsA . append ( tagName . strip ( ) ) <EOL> def set ( self , _state , _tagsA , _lvl , _fileName , _comment , _editor , _stamp ) : <EOL> self . setSaved ( SAVE_STATES . READY ) <EOL> self . state = _state <EOL> self . setTags ( _tagsA ) <EOL> self . lvl = int ( _lvl ) or <NUM_LIT:0> <EOL> self . fileName = _fileName or '<STR_LIT>' <EOL> self . comment = _comment <EOL> self . editor = _editor <EOL> self . stamp = _stamp <EOL> def savedReset ( self ) : <EOL> self . savedA = { } <EOL> self . setSaved ( SAVE_STATES . INIT ) <EOL> def setSaved ( self , _state , _dbIdx = - <NUM_LIT:1> ) : <EOL> self . initial = False <EOL> if _dbIdx < <NUM_LIT:0> : <EOL> for _dbIdx in self . parentDb . dbA : <EOL> self . setSavedDb ( _state , _dbIdx ) <EOL> else : <EOL> self . setSavedDb ( _state , _dbIdx ) <EOL> self . shadowCast ( ) <EOL> def setSavedDb ( self , _state , _dbIdx ) : <EOL> if _dbIdx in self . savedA and _state == SAVE_STATES . READY and self . savedA [ _dbIdx ] == SAVE_STATES . FORCE : <EOL> return <EOL> self . savedA [ _dbIdx ] = _state <EOL> def shadowCast ( self ) : <EOL> for cSaved in self . savedA : <EOL> if self . savedA [ cSaved ] != SAVE_STATES . IDLE : <EOL> return <EOL> self . old_state = self . state <EOL> self . old_tagsA = self . tagsA <EOL> self . old_lvl = self . lvl <EOL> self . old_fileName = self . fileName <EOL> self . old_comment = self . comment <EOL> def shadowDiffers ( self ) : <EOL> return self . differs ( self . old_state , self . old_tagsA , self . old_lvl , self . old_fileName , self . old_comment ) <EOL> def taskDiffers ( self , _task ) : <EOL> return self . differs ( _task . state , _task . tagsA , _task . lvl , _task . fileName , _task . comment ) <EOL> def differs ( self , _state , _tagsA , _lvl , _fileName , _comment ) : <EOL> if _state != self . state : <EOL> return True <EOL> if sorted ( _tagsA ) != sorted ( self . tagsA ) : <EOL> return True <EOL> if _lvl != self . lvl : <EOL> return True <EOL> if _fileName != self . fileName : <EOL> return True <EOL> if _comment != self . comment : <EOL> return True <EOL> def savePending ( self , _dbIdx ) : <EOL> if self . savedA [ _dbIdx ] == SAVE_STATES . FORCE : <EOL> return True <EOL> if self . savedA [ _dbIdx ] == SAVE_STATES . READY and self . shadowDiffers ( ) : <EOL> return True <EOL> def saveProgress ( self , _dbIdx ) : <EOL> if self . savedA [ _dbIdx ] == SAVE_STATES . HOLD : <EOL> return True <EOL> def saveInit ( self , _dbIdx ) : <EOL> if self . savedA [ _dbIdx ] == SAVE_STATES . INIT : <EOL> return True </s>
