RequirementRecursiveError => RequirementError
Properties in "apply_requires" are now transitive (but only if tested property is in properties list) New requirement option (a boolean), don't touch properties if PropertyError in "apply_requires"
This commit is contained in:
@ -22,7 +22,7 @@
|
||||
# ____________________________________________________________
|
||||
from time import time
|
||||
from copy import copy
|
||||
from tiramisu.error import RequirementRecursionError, PropertiesOptionError
|
||||
from tiramisu.error import RequirementError, PropertiesOptionError
|
||||
from tiramisu.i18n import _
|
||||
|
||||
|
||||
@ -278,7 +278,7 @@ class Setting(object):
|
||||
else:
|
||||
raise_text = "trying to access to an option named: {0} with properties {1}"
|
||||
raise PropertiesOptionError(_(raise_text).format(opt_or_descr._name,
|
||||
str(properties)),
|
||||
str(list(properties))),
|
||||
list(properties))
|
||||
|
||||
def _get_permissive(self, opt=None):
|
||||
@ -355,19 +355,28 @@ def apply_requires(opt, config):
|
||||
if len(require) == 3:
|
||||
option, expected, action = require
|
||||
inverse = False
|
||||
transitive = True
|
||||
elif len(require) == 4:
|
||||
option, expected, action, inverse = require
|
||||
transitive = True
|
||||
elif len(require) == 5:
|
||||
option, expected, action, inverse, transitive = require
|
||||
path = descr.impl_get_path_by_opt(option)
|
||||
if path == optpath or path.startswith(optpath + '.'):
|
||||
raise RequirementRecursionError(_("malformed requirements "
|
||||
"imbrication detected for option: '{0}' "
|
||||
"with requirement on: '{1}'").format(optpath, path))
|
||||
raise RequirementError(_("malformed requirements "
|
||||
"imbrication detected for option: '{0}' "
|
||||
"with requirement on: '{1}'").format(optpath, path))
|
||||
try:
|
||||
value = config.cfgimpl_get_context()._getattr(path, force_permissive=True)
|
||||
except PropertiesOptionError, err:
|
||||
if not transitive:
|
||||
continue
|
||||
properties = err.proptype
|
||||
raise PropertiesOptionError(_("option '{0}' has requirement's property error: "
|
||||
"{1} {2}").format(opt._name, path, properties), properties)
|
||||
if action not in err.proptype:
|
||||
raise RequirementError(_("option '{0}' has requirement's property error: "
|
||||
"{1} {2}").format(opt._name, path, properties), properties)
|
||||
#transitive action, force expected
|
||||
value = expected
|
||||
except AttributeError:
|
||||
raise AttributeError(_("required option not found: "
|
||||
"{0}").format(path))
|
||||
|
Reference in New Issue
Block a user