From 1263cd7a3cfca81ae3e6976a489e2d3d4013d64b Mon Sep 17 00:00:00 2001 From: kali Date: Thu, 30 Aug 2012 00:36:50 +0900 Subject: 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 :) --- src/leap/base/config.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/leap/base/config.py') 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): -- cgit v1.2.3