X-Git-Url: https://git.madduck.net/etc/taskwarrior.git/blobdiff_plain/309a51f5271dbcb1a1639204cdf78b5b2879c302..f881626c51f4a954f0330ef141b1b3ff944e35df:/tasklib/backends.py diff --git a/tasklib/backends.py b/tasklib/backends.py index 25193cc..fd3069c 100644 --- a/tasklib/backends.py +++ b/tasklib/backends.py @@ -75,7 +75,7 @@ class Backend(object): Converts TW syntax datetime string to a localized datetime object. This method is not mandatory. """ - raise NotImplemented + raise NotImplementedError class TaskWarriorException(Exception): @@ -171,11 +171,17 @@ class TaskWarrior(Backend): if task.saved: for field in task._modified_fields: add_field(field) + # For new tasks, pass all fields that make sense else: for field in task._data.keys(): + # We cannot set stuff that's read only (ID, UUID, ..) if field in task.read_only_fields: continue + # We do not want to do field deletion for new tasks + if task._data[field] is None: + continue + # Otherwise we're fine add_field(field) return args @@ -298,7 +304,7 @@ class TaskWarrior(Backend): def filter_tasks(self, filter_obj): self.enforce_recurrence() - args = ['export', '--'] + filter_obj.get_filter_params() + args = ['export'] + filter_obj.get_filter_params() tasks = [] for line in self.execute_command(args): if line: @@ -323,8 +329,10 @@ class TaskWarrior(Backend): id_lines = [l for l in output if l.startswith('Created task ')] # Complain loudly if it seems that more tasks were created - # Should not happen - if len(id_lines) != 1 or len(id_lines[0].split(' ')) != 3: + # Should not happen. + # Expected output: Created task 1. + # Created task 1 (recurrence template). + if len(id_lines) != 1 or len(id_lines[0].split(' ')) not in (3, 5): raise TaskWarriorException("Unexpected output when creating " "task: %s" % '\n'.join(id_lines)) @@ -392,7 +400,7 @@ class TaskWarrior(Backend): for key, value in data.items(): taskfilter.add_filter_param(key, value) - output = self.execute_command(['export', '--'] + + output = self.execute_command(['export'] + taskfilter.get_filter_params()) # If more than 1 task has been matched still, raise an exception