summaryrefslogtreecommitdiff
path: root/src/leap/base
diff options
context:
space:
mode:
authorkali <kali@leap.se>2012-08-30 00:36:50 +0900
committerkali <kali@leap.se>2012-08-30 00:42:29 +0900
commit1263cd7a3cfca81ae3e6976a489e2d3d4013d64b (patch)
tree95e6897a949d8772248a52ee714eec19bd2c6e72 /src/leap/base
parented4ad3a392caf0211e51a48d2d7b6c5a2f7bb17a (diff)
add lazy evaluation to config specs
now callables are allowed in specs *only at one level depth* to allow for last-minute evaluation on context-sensitive data, like paths affected by os.environ also some minor modifications to make check tests pass after putting the new jsonconfig-based eipconfig in place. aaaaaall green again :)
Diffstat (limited to 'src/leap/base')
-rw-r--r--src/leap/base/config.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/leap/base/config.py b/src/leap/base/config.py
index 465016db..c7871f22 100644
--- a/src/leap/base/config.py
+++ b/src/leap/base/config.py
@@ -111,6 +111,13 @@ class JSONLeapConfig(BaseLeapConfig):
folder, filename = os.path.split(to)
if folder and not os.path.isdir(folder):
mkdir_p(folder)
+ # lazy evaluation until first level nest
+ # to allow lambdas with context-dependant info
+ # like os.path.expanduser
+ config = self.get_config()
+ for k, v in config.iteritems():
+ if callable(v):
+ config[k] = v()
self._config.serialize(to)
def load(self, fromfile=None):