]> git.madduck.net Git - etc/taskwarrior.git/commitdiff

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:

TaskWarrior: Add method to parse config
authorTomas Babej <tomasbabej@gmail.com>
Wed, 8 Apr 2015 19:00:53 +0000 (21:00 +0200)
committerTomas Babej <tomasbabej@gmail.com>
Wed, 8 Apr 2015 20:00:53 +0000 (22:00 +0200)
tasklib/task.py

index 9af111b06ddc8f45cf7dbfbe34fa4f64453195ca..0f8d963140949683cc878f9a192a83bf1802bfb4 100644 (file)
@@ -5,6 +5,7 @@ import json
 import logging
 import os
 import pytz
+import re
 import six
 import sys
 import subprocess
@@ -949,6 +950,22 @@ class TaskWarrior(object):
         stdout, stderr = [x.decode('utf-8') for x in p.communicate()]
         return stdout.strip('\n')
 
+    def get_config(self):
+        raw_output = self.execute_command(
+                ['show'],
+                config_override={'verbose': 'nothing'}
+            )
+
+        config = dict()
+        config_regex = re.compile(r'^(?P<key>[_a-z\.]+)\s+(?P<value>[^\s].+$)')
+
+        for line in raw_output:
+            match = config_regex.match(line)
+            if match:
+                config[match.group('key')] = match.group('value').strip()
+
+        return config
+
     def execute_command(self, args, config_override={}, allow_failure=True,
                         return_all=False):
         command_args = self._get_command_args(