processing start, out, and task commands
This commit is contained in:
parent
fa2413810d
commit
4edabbdf3b
25
dwtt
25
dwtt
@ -6,7 +6,7 @@ import getopt
|
|||||||
|
|
||||||
from CmdWindow import CmdWindow
|
from CmdWindow import CmdWindow
|
||||||
from Command import Command
|
from Command import Command
|
||||||
from DataStore import DataStore
|
from DataStore import DataStore, TaskRef
|
||||||
|
|
||||||
PROGRAM_NAME = 'dwtt'
|
PROGRAM_NAME = 'dwtt'
|
||||||
|
|
||||||
@ -48,10 +48,26 @@ def doCmdWindow():
|
|||||||
return c.main()
|
return c.main()
|
||||||
|
|
||||||
def processStart(cmd, store):
|
def processStart(cmd, store):
|
||||||
pass
|
processOut(cmd, store)
|
||||||
|
task = store.getTaskByName(cmd.argstr)
|
||||||
|
if task is None:
|
||||||
|
parent = store.getParentTaskByName(cmd.argstr)
|
||||||
|
if parent is None:
|
||||||
|
return 'Could not find task "%s"' % \
|
||||||
|
(':'.join(cmd.argstr.split(':')[:-1]))
|
||||||
|
taskid = store.createTask(cmd.argstr.split(':')[-1], '', parent.taskid)
|
||||||
|
else:
|
||||||
|
taskid = task.taskid
|
||||||
|
store.updateCurrentTask(TaskRef(taskid, cmd.time))
|
||||||
|
|
||||||
def processOut(cmd, store):
|
def processOut(cmd, store):
|
||||||
pass
|
ct = store.getCurrentTask()
|
||||||
|
if ct is not None:
|
||||||
|
seconds = (cmd.time - ct.time).seconds
|
||||||
|
store.addTime(cmd.time.strftime('%Y-%m-%d'), ct.taskid, seconds)
|
||||||
|
store.clearCurrentTask()
|
||||||
|
return False
|
||||||
|
return 'No current task defined'
|
||||||
|
|
||||||
def processTask(cmd, store):
|
def processTask(cmd, store):
|
||||||
parts = cmd.argstr.split(',', 1)
|
parts = cmd.argstr.split(',', 1)
|
||||||
@ -63,8 +79,7 @@ def processTask(cmd, store):
|
|||||||
# the task already exists, update it
|
# the task already exists, update it
|
||||||
store.updateTask(task.taskid, nameparts[-1], longname)
|
store.updateTask(task.taskid, nameparts[-1], longname)
|
||||||
return False
|
return False
|
||||||
parenttaskname = ':'.join(nameparts[:-1])
|
parenttask = store.getParentTaskByName(fullname)
|
||||||
parenttask = store.getTaskByName(parenttaskname)
|
|
||||||
if parenttask is None:
|
if parenttask is None:
|
||||||
return 'Parent task not found'
|
return 'Parent task not found'
|
||||||
store.createTask(nameparts[-1].strip(), longname, parenttask.taskid)
|
store.createTask(nameparts[-1].strip(), longname, parenttask.taskid)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user