X-Git-Url: https://git.madduck.net/etc/taskwarrior.git/blobdiff_plain/32554e98936380bdbb26588852c3896e2b23c9ee..c3ad5d17022aad74d430dbbb09248f8ed10b1f66:/tasklib/task.py diff --git a/tasklib/task.py b/tasklib/task.py index 1b337ba..b6c3d09 100644 --- a/tasklib/task.py +++ b/tasklib/task.py @@ -359,7 +359,7 @@ class Task(TaskResource): def remove_annotation(self, annotation): if not self.saved: - raise Task.NotSaved("Task needs to be saved to add annotation") + raise Task.NotSaved("Task needs to be saved to remove annotation") if isinstance(annotation, TaskAnnotation): annotation = annotation['description'] @@ -372,8 +372,11 @@ class Task(TaskResource): def add_field(field): # Add the output of format_field method to args list (defaults to - # field:value) - format_default = lambda k: "{0}:'{1}'".format(k, self._data[k] or '') + # field:'value') + format_default = lambda k: "{0}:{1}".format(k, + "'{0}'".format(self._data[k]) + if self._data[k] is not None + else '') format_func = getattr(self, 'format_{0}'.format(field), lambda: format_default(field)) args.append(format_func()) @@ -433,7 +436,15 @@ class TaskFilter(SerializingObject): if key == 'uuid': self.filter_params.insert(0, value) else: - self.filter_params.append('{0}:{1}'.format(key, value)) + # Surround value with aphostrophes unless it's a empty string + value = "'%s'" % value if value else '' + + # We enforce equality match by using 'is' (or 'none') modifier + # Without using this syntax, filter fails due to TW-1479 + modifier = '.is' if value else '.none' + key = key + modifier if '.' not in key else key + + self.filter_params.append("{0}:{1}".format(key, value)) def get_filter_params(self): return [f for f in self.filter_params if f] @@ -562,6 +573,7 @@ class TaskWarrior(object): self.config = { 'data.location': os.path.expanduser(data_location), 'confirmation': 'no', + 'dependency.confirmation': 'no', # See TW-1483 or taskrc man page } self.tasks = TaskQuerySet(self) self.version = self._get_version()