X-Git-Url: https://git.madduck.net/etc/taskwarrior.git/blobdiff_plain/74a51236ca846890982928e16a7561d3f370ddf7..f881626c51f4a954f0330ef141b1b3ff944e35df:/tasklib/backends.py diff --git a/tasklib/backends.py b/tasklib/backends.py index b15e8bd..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 @@ -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))