From 967842c23932a9d8e6eb5fdfa3bd45d23a39089a Mon Sep 17 00:00:00 2001 From: gwen Date: Thu, 26 Jul 2012 16:55:01 +0200 Subject: [PATCH] mandatory warnings works now --- tiramisu/config.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/tiramisu/config.py b/tiramisu/config.py index d9432fc..41944f7 100644 --- a/tiramisu/config.py +++ b/tiramisu/config.py @@ -513,7 +513,7 @@ class Config(object): lines.insert(0, "%s[%s]" % (indent, self._cfgimpl_descr._name,)) return '\n'.join(lines) - def getpaths(self, include_groups=False, allpaths=False): + def getpaths(self, include_groups=False, allpaths=False, mandatory=False): """returns a list of all paths in self, recursively, taking care of the context (hidden/disabled) """ @@ -521,11 +521,12 @@ class Config(object): for path in self._cfgimpl_descr.getpaths(include_groups=include_groups): try: value = getattr(self, path) + except MandatoryError: + if mandatory or allpaths: + paths.append(path) except Exception, e: - if not allpaths: - pass # hidden or disabled option - else: - paths.append(path) # hidden or disabled option added + if allpaths: + paths.append(path) # hidden or disabled or mandatory option added else: paths.append(path) return paths @@ -547,11 +548,11 @@ def make_dict(config, flatten=False): return options def mandatory_warnings(config): - for path in config.getpaths(): + mandatory = config._cfgimpl_mandatory + config._cfgimpl_mandatory = True + for path in config.getpaths(mandatory=True): try: - value = getattr(config, path) + value = getattr(config, path) except MandatoryError: yield path - except: - pass - + config._cfgimpl_mandatory = mandatory