From fe6b70b78cf3fbd333fe6ee2bbb5c4cb55dacf0b Mon Sep 17 00:00:00 2001 From: Tomas Babej Date: Sat, 15 Aug 2015 03:41:08 +0200 Subject: [PATCH] TaskWarrior: Use config propery instead of get_config call --- tasklib/backends.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) 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): -- 2.39.5