X-Git-Url: https://git.madduck.net/etc/taskwarrior.git/blobdiff_plain/ff666e5453d71418ca45ee0542a82e2c58ef8442..fe6b70b78cf3fbd333fe6ee2bbb5c4cb55dacf0b:/tasklib/backends.py?ds=inline diff --git a/tasklib/backends.py b/tasklib/backends.py index 32a8018..fbe3ba3 100644 --- a/tasklib/backends.py +++ b/tasklib/backends.py @@ -103,6 +103,7 @@ class TaskWarrior(Backend): if not os.path.exists(self.taskrc_location): self.taskrc_location = '/' + self._config = None self.version = self._get_version() self.config = { 'confirmation': 'no', @@ -229,7 +230,13 @@ class TaskWarrior(Backend): # Public interface - def get_config(self): + @property + def config(self): + # First, check if memoized information is available + if self._config: + return copy.deepcopy(self._config) + + # If not, fetch the config using the 'show' command raw_output = self.execute_command( ['show'], config_override={'verbose': 'nothing'} @@ -243,7 +250,10 @@ class TaskWarrior(Backend): if match: config[match.group('key')] = match.group('value').strip() - return config + # Memoize the config dict + self._config = config + + return copy.deepcopy(config) def execute_command(self, args, config_override=None, allow_failure=True, return_all=False):