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,)) lines.insert(0, "%s[%s]" % (indent, self._cfgimpl_descr._name,))
return '\n'.join(lines) 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 """returns a list of all paths in self, recursively, taking care of
the context (hidden/disabled) the context (hidden/disabled)
""" """
@ -521,11 +521,12 @@ class Config(object):
for path in self._cfgimpl_descr.getpaths(include_groups=include_groups): for path in self._cfgimpl_descr.getpaths(include_groups=include_groups):
try: try:
value = getattr(self, path) value = getattr(self, path)
except MandatoryError:
if mandatory or allpaths:
paths.append(path)
except Exception, e: except Exception, e:
if not allpaths: if allpaths:
pass # hidden or disabled option paths.append(path) # hidden or disabled or mandatory option added
else:
paths.append(path) # hidden or disabled option added
else: else:
paths.append(path) paths.append(path)
return paths return paths
@ -547,11 +548,11 @@ def make_dict(config, flatten=False):
return options return options
def mandatory_warnings(config): 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: try:
value = getattr(config, path) value = getattr(config, path)
except MandatoryError: except MandatoryError:
yield path yield path
except: config._cfgimpl_mandatory = mandatory
pass