works on permissive
This commit is contained in:
@ -326,11 +326,15 @@ class TiramisuOptionPermissive(CommonTiramisuOption):
|
||||
slave_need_index = False
|
||||
|
||||
def __init__(self,
|
||||
name,
|
||||
path,
|
||||
index,
|
||||
subconfig,
|
||||
config_bag):
|
||||
super(TiramisuOptionPermissive, self).__init__(path,
|
||||
super(TiramisuOptionPermissive, self).__init__(name,
|
||||
path,
|
||||
index,
|
||||
subconfig,
|
||||
config_bag)
|
||||
self.settings = config_bag.config.cfgimpl_get_settings()
|
||||
|
||||
@ -340,16 +344,16 @@ class TiramisuOptionPermissive(CommonTiramisuOption):
|
||||
if TIRAMISU_VERSION == 2:
|
||||
args = [self.setting_properties, self.path]
|
||||
else:
|
||||
args = [self._opt, self.path]
|
||||
args = [self.get_option(), self.path]
|
||||
return self.settings.getpermissive(*args)
|
||||
|
||||
@count
|
||||
def set(self, permissive):
|
||||
def set(self, permissives):
|
||||
if TIRAMISU_VERSION == 2:
|
||||
permissive = tuple(permissive)
|
||||
self.settings.setpermissive(opt=self._opt,
|
||||
permissive = tuple(permissives)
|
||||
self.settings.setpermissive(opt=self.get_option(),
|
||||
path=self.path,
|
||||
permissive=permissive)
|
||||
permissives=permissives)
|
||||
|
||||
@count
|
||||
def reset(self, path):
|
||||
@ -575,14 +579,14 @@ class TiramisuContextProperty(TiramisuContext):
|
||||
def add(self, prop):
|
||||
props = self.get()
|
||||
props.add(prop)
|
||||
self.set(props)
|
||||
self.set(frozenset(props))
|
||||
self.config_bag.setting_properties = self.config_bag.config.cfgimpl_get_settings().get_context_properties()
|
||||
|
||||
@count
|
||||
def pop(self, prop):
|
||||
props = self.get()
|
||||
props.remove(prop)
|
||||
self.set(props)
|
||||
self.set(frozenset(props))
|
||||
self.config_bag.setting_properties = self.config_bag.config.cfgimpl_get_settings().get_context_properties()
|
||||
|
||||
@count
|
||||
@ -599,7 +603,7 @@ class TiramisuContextProperty(TiramisuContext):
|
||||
|
||||
@count
|
||||
def set(self, props):
|
||||
self.config_bag.config.cfgimpl_get_settings().set_context_properties(frozenset(props))
|
||||
self.config_bag.config.cfgimpl_get_settings().set_context_properties(props)
|
||||
self.config_bag.setting_properties = self.config_bag.config.cfgimpl_get_settings().get_context_properties()
|
||||
|
||||
def reset(self):
|
||||
@ -610,8 +614,6 @@ class TiramisuContextPermissive(TiramisuContext):
|
||||
|
||||
@count
|
||||
def set(self, permissives):
|
||||
if TIRAMISU_VERSION != 2:
|
||||
permissives = frozenset(permissives)
|
||||
self.config_bag.config.cfgimpl_get_settings().set_context_permissive(permissives)
|
||||
|
||||
|
||||
|
@ -82,14 +82,14 @@ class PropertiesOptionError(AttributeError):
|
||||
msg = []
|
||||
for action, msg_ in req.items():
|
||||
msg.append('"{0}" ({1})'.format(action, display_list(msg_)))
|
||||
msg = display_list(msg)
|
||||
else:
|
||||
only_one = len(self.proptype) == 1
|
||||
msg = list(self.proptype)
|
||||
msg = display_list(list(self.proptype), add_quote=True)
|
||||
if only_one:
|
||||
prop_msg = _('property')
|
||||
else:
|
||||
prop_msg = _('properties')
|
||||
msg = display_list(msg)
|
||||
if self._orig_opt:
|
||||
return str(_('cannot access to {0} "{1}" because "{2}" has {3} {4}'
|
||||
'').format(self._type,
|
||||
|
@ -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:
|
||||
|
Reference in New Issue
Block a user