]> git.madduck.net Git - etc/taskwarrior.git/blobdiff - tasklib/task.py

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Update README to reflect new filtering API
[etc/taskwarrior.git] / tasklib / task.py
index 85ba04290b0f01af45334cf9b012a347f79ad6e8..4681418448b1ca18b77a5bf5b69f2f9850ebf9f4 100644 (file)
@@ -52,6 +52,19 @@ class Task(object):
             return None
         return datetime.datetime.strptime(date_str, DATE_FORMAT)
 
             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())
 
     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):
         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__()
 
     def clone(self):
         c = self.__class__()
@@ -162,7 +175,7 @@ class TaskQuerySet(object):
         """
         Fetch the tasks which match the current filters.
         """
         """
         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):
         """
 
     def all(self):
         """
@@ -230,8 +243,8 @@ class TaskWarrior(object):
             raise TaskWarriorException(stderr.strip())
         return stdout.strip().split('\n')
 
             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:
         tasks = []
         for line in self._execute_command(args):
             if line: