Requires need option, not path

Valid requires
This commit is contained in:
2013-04-26 14:40:44 +02:00
parent 509f41e14c
commit 2c5bbb7bc0
6 changed files with 37 additions and 35 deletions

View File

@ -749,7 +749,16 @@ def validate_requires_arg(requires, name):
for req in requires:
if not type(req) == tuple:
raise ValueError(_("malformed requirements type for option:"
" {0}, must be a tuple").format(name))
" {0}, must be a tuple").format(name))
if not isinstance(req[0], Option):
raise ValueError(_('malformed requirements first argument '
'must be an option in option {0}').format(name))
if req[0].optimpl_is_multi():
raise ValueError(_('malformed requirements option {0} '
'should not be a multi').format(name))
if not req[0]._validate(req[1]):
raise ValueError(_('malformed requirements second argument '
'must be valid for option {0}').format(name))
if len(req) == 3:
action = req[2]
inverse = False

View File

@ -359,15 +359,17 @@ def apply_requires(opt, config):
settings = config.cfgimpl_get_settings()
setting = Property(settings, settings._get_properties(opt, False), opt)
trigger_actions = build_actions(opt._requires)
optpath = config.cfgimpl_get_context().cfgimpl_get_description().optimpl_get_path_by_opt(opt)
descr = config.cfgimpl_get_context().cfgimpl_get_description()
optpath = descr.optimpl_get_path_by_opt(opt)
for requires in trigger_actions.values():
matches = False
for require in requires:
if len(require) == 3:
path, expected, action = require
option, expected, action = require
inverse = False
elif len(require) == 4:
path, expected, action, inverse = require
option, expected, action, inverse = require
path = descr.optimpl_get_path_by_opt(option)
if path == optpath or path.startswith(optpath + '.'):
raise RequirementRecursionError(_("malformed requirements "
"imbrication detected for option: '{0}' "