From e0490c2bedbf1a00532099e31848c481b60662a8 Mon Sep 17 00:00:00 2001 From: gwen Date: Fri, 30 Nov 2012 10:47:35 +0100 Subject: [PATCH] add permissive in the requirements --- tiramisu/config.py | 2 +- tiramisu/option.py | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/tiramisu/config.py b/tiramisu/config.py index a24e10a..89df89f 100644 --- a/tiramisu/config.py +++ b/tiramisu/config.py @@ -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))) diff --git a/tiramisu/option.py b/tiramisu/option.py index a403264..08b6c11 100644 --- a/tiramisu/option.py +++ b/tiramisu/option.py @@ -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))