From: Tomas Babej Date: Sat, 8 Aug 2015 17:58:18 +0000 (+0200) Subject: Task: Move TW-specific start/stop logic into TW backend X-Git-Url: https://git.madduck.net/etc/taskwarrior.git/commitdiff_plain/dcbdcdd11c981b4600ea4a5522230d0456e45d21?ds=sidebyside Task: Move TW-specific start/stop logic into TW backend --- diff --git a/tasklib/backends.py b/tasklib/backends.py index 6bf11bb..12a9234 100644 --- a/tasklib/backends.py +++ b/tasklib/backends.py @@ -204,3 +204,8 @@ 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']) diff --git a/tasklib/task.py b/tasklib/task.py index 61f944a..b7bba4b 100644 --- a/tasklib/task.py +++ b/tasklib/task.py @@ -605,7 +605,7 @@ class Task(TaskResource): elif self.active: raise Task.ActiveTask("Task is already active") - self.warrior.execute_command([self['uuid'], 'start']) + self.backend.start_task(self) # Refresh the status again, so that we have updated info stored self.refresh(only_fields=['status', 'start']) @@ -620,7 +620,7 @@ class Task(TaskResource): if not self.active: raise Task.InactiveTask("Cannot stop an inactive task") - self.warrior.execute_command([self['uuid'], 'stop']) + self.backend.stop_task(self) # Refresh the status again, so that we have updated info stored self.refresh(only_fields=['status', 'start'])