X-Git-Url: https://git.madduck.net/etc/taskwarrior.git/blobdiff_plain/dcbdcdd11c981b4600ea4a5522230d0456e45d21..4a289416db9f24d81cacd14da40f5db196454e79:/tasklib/backends.py diff --git a/tasklib/backends.py b/tasklib/backends.py index 12a9234..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""" @@ -209,3 +221,11 @@ class TaskWarrior(object): 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']) +