mandatory warnings works now

This commit is contained in:
gwen 2012-07-26 16:55:01 +02:00
parent c9bc9f3823
commit 967842c239
1 changed files with 11 additions and 10 deletions

View File

@ -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