documentation update

This commit is contained in:
gwen
2013-08-20 16:38:06 +02:00
parent 564fecc261
commit 5c8bb1f8f9
4 changed files with 57 additions and 32 deletions

View File

@ -261,22 +261,34 @@ class Setting(object):
def validate_properties(self, opt_or_descr, is_descr, is_write,
value=None, force_permissive=False,
force_properties=None):
#opt properties
"""
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._get_properties(opt_or_descr))
#remove opt permissive
# remove opt permissive
properties -= self._get_permissive(opt_or_descr)
#remove global permissive if need
# remove global permissive if need
self_properties = copy(self._get_properties())
if force_permissive is True or 'permissive' in self_properties:
properties -= self._get_permissive()
#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:
@ -288,7 +300,7 @@ class Setting(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: