X-Git-Url: https://git.madduck.net/etc/taskwarrior.git/blobdiff_plain/57c5057d9885ce0020fca03b83d1c75f6143fdc3..5f02f81952c8267636cc57e977dc5d257320129f:/tasklib/task.py?ds=sidebyside diff --git a/tasklib/task.py b/tasklib/task.py index 85ba042..4681418 100644 --- a/tasklib/task.py +++ b/tasklib/task.py @@ -52,6 +52,19 @@ class Task(object): return None return datetime.datetime.strptime(date_str, DATE_FORMAT) + def serialize_annotations(self, annotations): + ann_list = list(annotations) + for ann in ann_list: + ann['entry'] = ann['entry'].strftime(DATE_FORMAT) + return ann_list + + def deserialize_annotations(self, annotations): + ann_list = list(annotations) + for ann in ann_list: + ann['entry'] = datetime.datetime.strptime( + ann['entry'], DATE_FORMAT) + return ann_list + def regenerate_uuid(self): self['uuid'] = str(uuid.uuid4()) @@ -87,7 +100,7 @@ class TaskFilter(object): self.filter_params.append('{0}:{1}'.format(key, value)) def get_filter_params(self): - return ['({})'.format(f) for f in self.filter_params if f] + return [f for f in self.filter_params if f] def clone(self): c = self.__class__() @@ -162,7 +175,7 @@ class TaskQuerySet(object): """ Fetch the tasks which match the current filters. """ - return self.warrior._execute_filter(self.filter_obj) + return self.warrior.filter_tasks(self.filter_obj) def all(self): """ @@ -230,8 +243,8 @@ class TaskWarrior(object): raise TaskWarriorException(stderr.strip()) return stdout.strip().split('\n') - def _execute_filter(self, filter_obj): - args = filter_obj.get_filter_params() + ['export'] + def filter_tasks(self, filter_obj): + args = ['export', '--'] + filter_obj.get_filter_params() tasks = [] for line in self._execute_command(args): if line: