merge from val_prop_plugin branch
[tiramisu.git] / tiramisu / setting.py
index 5414994..a341d7a 100644 (file)
@@ -268,22 +268,34 @@ class Settings(object):
     def validate_properties(self, opt_or_descr, is_descr, is_write,
                             value=None, force_permissive=False,
                             force_properties=None):
+        """
+        validation upon the properties related to `opt_or_descr`
+
+        :param opt_or_descr: an option or an option description object
+        :param force_permissive: behaves as if the permissive property was present
+        :param is_descr: we have to know if we are in an option description,
+                         just because the mandatory property doesn't exist there
+
+        :param is_write: in the validation process, an option is to be modified,
+                         the behavior can be different (typically with the `frozen`
+                         property)
+        """
         #opt properties
         properties = copy(self._getproperties(opt_or_descr))
         #remove opt permissive
         properties -= self._p_.getpermissive(self._getkey(opt_or_descr))
         #remove global permissive if need
         self_properties = copy(self._getproperties())
-        if force_permissive is True or 'permissive' in self_properties:
+            if force_permissive is True or 'permissive' in self_properties:
             properties -= self._p_.getpermissive()
 
-        #global properties
+        # global properties
         if force_properties is not None:
             self_properties.update(force_properties)
 
-        #calc properties
+        # calc properties
         properties &= self_properties
-        #mandatory and frozen are special properties
+        # mandatory and frozen are special properties
         if is_descr:
             properties -= frozenset(('mandatory', 'frozen'))
         else:
@@ -295,7 +307,7 @@ class Settings(object):
                 properties.add('frozen')
             elif 'frozen' in properties and not is_write:
                 properties.remove('frozen')
-
+        # at this point an option should not remain in properties
         if properties != frozenset():
             props = list(properties)
             if 'frozen' in properties: