add permissive in the requirements

This commit is contained in:
gwen 2012-11-30 10:47:35 +01:00
parent 1dea71c17f
commit e0490c2bed
2 changed files with 10 additions and 4 deletions

View file

@ -121,7 +121,7 @@ class Config(object):
def _validate(self, name, opt_or_descr, permissive=False):
"validation for the setattr and the getattr"
apply_requires(opt_or_descr, self)
apply_requires(opt_or_descr, self, permissive=permissive)
if not isinstance(opt_or_descr, Option) and \
not isinstance(opt_or_descr, OptionDescription):
raise TypeError('Unexpected object: {0}'.format(repr(opt_or_descr)))

View file

@ -520,7 +520,7 @@ def build_actions(requires):
trigger_actions.setdefault(action, []).append(require)
return trigger_actions
def apply_requires(opt, config):
def apply_requires(opt, config, permissive=False):
"carries out the jit (just in time requirements between options"
if hasattr(opt, '_requires') and opt._requires is not None:
rootconfig = config._cfgimpl_get_toplevel()
@ -540,8 +540,14 @@ def apply_requires(opt, config):
try:
value = homeconfig._getattr(shortname, permissive=True)
except PropertiesOptionError, err:
raise NotFoundError("required option has property error: "
"{0} {1}".format(name, err.proptype))
permissives = err.proptype
if permissive:
for perm in settings.permissive:
if perm in properties:
properties.remove(perm)
if properties != []:
raise NotFoundError("option '{0}' has requirement's property error: "
"{1} {2}".format(opt._name, name, properties))
except Exception, err:
raise NotFoundError("required option not found: "
"{0}".format(name))