add permissive in the requirements
authorgwen <gremond@cadoles.com>
Fri, 30 Nov 2012 09:47:35 +0000 (10:47 +0100)
committergwen <gremond@cadoles.com>
Fri, 30 Nov 2012 09:47:35 +0000 (10:47 +0100)
tiramisu/config.py
tiramisu/option.py

index a24e10a..89df89f 100644 (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)))
index a403264..08b6c11 100644 (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))