works on permissive

This commit is contained in:
2017-12-28 11:47:29 +01:00
parent 1736170e43
commit a40adea1d9
12 changed files with 367 additions and 40 deletions

View File

@ -107,7 +107,7 @@ rw_remove = set(['permissive', 'everything_frozen', 'mandatory', 'empty'])
FORBIDDEN_SET_PROPERTIES = frozenset(['force_store_value'])
forbidden_set_permissives = frozenset(['frozen', 'force_default_on_freeze'])
FORBIDDEN_SET_PERMISSIVES = frozenset(['force_default_on_freeze'])
log = getLogger('tiramisu')
@ -372,10 +372,6 @@ class Settings(object):
index,
False,
config_bag)
#if requires != set([]):
# props = copy(props)
# props |= requires
props -= self.getpermissive(opt,
path)
if config_bag.setting_properties is not None and \
@ -625,7 +621,7 @@ class Settings(object):
if opt and opt.impl_is_symlinkoption():
raise TypeError(_("can't assign permissive to the SymLinkOption \"{}\""
"").format(opt.impl_get_display_name()))
forbidden_permissives = forbidden_set_permissives & permissives
forbidden_permissives = FORBIDDEN_SET_PERMISSIVES & permissives
if forbidden_permissives:
raise ConfigError(_('cannot add those permissives: {0}').format(
' '.join(forbidden_permissives)))
@ -688,10 +684,9 @@ class Settings(object):
# remove permissive properties
if config_bag.force_permissive is True and properties:
if (config_bag.force_permissive is True or 'permissive' in config_bag.setting_properties) and properties:
# remove global permissive if need
properties -= self.get_context_permissive()
# at this point an option should not remain in properties
if properties != frozenset():
datas = {'path': path,
@ -711,14 +706,21 @@ class Settings(object):
config_bag):
values = self._getcontext().cfgimpl_get_values()
opt = config_bag.option
if config_bag.setting_properties and 'mandatory' in config_bag.setting_properties and \
('mandatory' in config_bag.properties and values.isempty(opt,
value,
index=index) or \
'empty' in config_bag.properties and values.isempty(opt,
is_mandatory = False
if config_bag.setting_properties and 'mandatory' in config_bag.setting_properties:
if (config_bag.force_permissive is True or 'permissive' in config_bag.setting_properties) and \
'mandatory' in self.get_context_permissive():
pass
elif 'mandatory' in config_bag.properties and values.isempty(opt,
value,
index=index):
is_mandatory = True
if 'empty' in config_bag.properties and values.isempty(opt,
value,
force_allow_empty_list=True,
index=index)):
index=index):
is_mandatory = True
if is_mandatory:
datas = {'path': path,
'config_bag': config_bag,
'index': index,
@ -731,8 +733,14 @@ class Settings(object):
def validate_frozen(self,
config_bag):
return 'everything_frozen' in config_bag.setting_properties or \
'frozen' in config_bag.properties
if config_bag.setting_properties and \
('everything_frozen' in config_bag.setting_properties or
'frozen' in config_bag.properties) and \
not ((config_bag.force_permissive is True or
'permissive' in config_bag.setting_properties) and
'frozen' in self.get_context_permissive()):
return True
return False
#____________________________________________________________
# read only/read write
@ -742,7 +750,7 @@ class Settings(object):
props = self._p_.getproperties(None,
default_properties)
modified = False
if remove & props != set([]):
if remove & props:
props = props - remove
modified = True
if append & props != append: