X-Git-Url: https://git.madduck.net/etc/taskwarrior.git/blobdiff_plain/7b0f22cf6cf519ece57e5282412669f460859293..4a289416db9f24d81cacd14da40f5db196454e79:/tasklib/backends.py diff --git a/tasklib/backends.py b/tasklib/backends.py index 6bf11bb..bf4cd67 100644 --- a/tasklib/backends.py +++ b/tasklib/backends.py @@ -38,6 +38,18 @@ class Backend(object): def stop_task(self, task): pass + @abc.abstractmethod + def complete_task(self, task): + pass + + @abc.abstractmethod + def refresh_task(self, task): + """ + Refreshes the given task. Returns new data dict with serialized + attributes. + """ + pass + @abc.abstractmethod def sync(self): """Syncs the backend database with the taskd server""" @@ -204,3 +216,16 @@ class TaskWarrior(object): def delete_task(self, task): self.execute_command([task['uuid'], 'delete']) + def start_task(self, task): + self.execute_command([task['uuid'], 'start']) + + def stop_task(self, task): + self.execute_command([task['uuid'], 'stop']) + + def complete_task(self, task): + # Older versions of TW do not stop active task at completion + if self.version < VERSION_2_4_0 and task.active: + task.stop() + + self.execute_command([task['uuid'], 'done']) +