simplification
This commit is contained in:
@ -429,9 +429,8 @@ class Settings(object):
|
||||
self._getcontext().cfgimpl_reset_cache()
|
||||
|
||||
#____________________________________________________________
|
||||
def validate_properties(self, opt_or_descr, is_descr, is_write, path,
|
||||
def validate_properties(self, opt_or_descr, is_descr, check_frozen, path,
|
||||
value=None, force_permissive=False,
|
||||
force_properties=None,
|
||||
setting_properties=undefined,
|
||||
self_properties=undefined,
|
||||
index=None):
|
||||
@ -441,13 +440,11 @@ class Settings(object):
|
||||
:param opt_or_descr: an option or an option description object
|
||||
:param force_permissive: behaves as if the permissive property
|
||||
was present
|
||||
:param force_properties: set() with properties that is force to add
|
||||
in global properties
|
||||
:param is_descr: we have to know if we are in an option description,
|
||||
just because the mandatory property
|
||||
doesn't exist here
|
||||
|
||||
:param is_write: in the validation process, an option is to be modified,
|
||||
:param check_frozen: in the validation process, an option is to be modified,
|
||||
the behavior can be different
|
||||
(typically with the `frozen` property)
|
||||
"""
|
||||
@ -468,31 +465,24 @@ class Settings(object):
|
||||
if force_permissive is True or 'permissive' in setting_properties:
|
||||
properties -= self._p_.getpermissive()
|
||||
|
||||
if force_properties is not None:
|
||||
forced_properties = copy(setting_properties)
|
||||
forced_properties.add('mandatory')
|
||||
else:
|
||||
forced_properties = setting_properties
|
||||
|
||||
# calc properties
|
||||
properties &= forced_properties
|
||||
# mandatory and frozen are special properties
|
||||
if is_descr:
|
||||
properties -= frozenset(('mandatory', 'frozen'))
|
||||
else:
|
||||
properties &= setting_properties
|
||||
if not is_descr:
|
||||
#mandatory
|
||||
if 'mandatory' in properties and \
|
||||
not self._getcontext().cfgimpl_get_values()._isempty(
|
||||
opt_or_descr, value, index=index):
|
||||
properties.remove('mandatory')
|
||||
elif opt_or_descr.impl_is_multi() and \
|
||||
not is_write and 'empty' in forced_properties and \
|
||||
'empty' in setting_properties and \
|
||||
not opt_or_descr.impl_is_master_slaves('slave') and \
|
||||
self._getcontext().cfgimpl_get_values()._isempty(
|
||||
opt_or_descr, value, force_allow_empty_list=True):
|
||||
properties.add('mandatory')
|
||||
if is_write and 'everything_frozen' in forced_properties:
|
||||
# should return 'frozen' only when tried to modify a value
|
||||
if check_frozen and 'everything_frozen' in setting_properties:
|
||||
properties.add('frozen')
|
||||
elif 'frozen' in properties and not is_write:
|
||||
elif 'frozen' in properties and not check_frozen:
|
||||
properties.remove('frozen')
|
||||
# at this point an option should not remain in properties
|
||||
if properties != frozenset():
|
||||
@ -504,7 +494,7 @@ class Settings(object):
|
||||
opt_or_descr.impl_getname()),
|
||||
props)
|
||||
else:
|
||||
if opt_or_descr.impl_is_optiondescription():
|
||||
if is_descr:
|
||||
opt_type = 'optiondescription'
|
||||
else:
|
||||
opt_type = 'option'
|
||||
|
Reference in New Issue
Block a user