force_permissive +> permissive
This commit is contained in:
parent
493cec1b80
commit
b381e0322f
|
@ -362,8 +362,8 @@ class TiramisuOptionPermissive(CommonTiramisuOption):
|
||||||
|
|
||||||
def get(self):
|
def get(self):
|
||||||
"""get permissives value"""
|
"""get permissives value"""
|
||||||
option = self.option_bag.option
|
return self.settings.getpermissives(self.option_bag.option,
|
||||||
return self.settings.getpermissive(option, self.option_bag.path)
|
self.option_bag.path)
|
||||||
|
|
||||||
def set(self, permissives):
|
def set(self, permissives):
|
||||||
"""set permissives value"""
|
"""set permissives value"""
|
||||||
|
@ -979,22 +979,22 @@ class TiramisuAPI(TiramisuHelp):
|
||||||
else:
|
else:
|
||||||
config = self._config
|
config = self._config
|
||||||
force = None
|
force = None
|
||||||
config_bag = ConfigBag(context=config,
|
config_bag = ConfigBag(context=config)
|
||||||
force_permissive=True)
|
config_bag.set_permissive()
|
||||||
if force is True:
|
if force is True:
|
||||||
config_bag.properties = frozenset()
|
config_bag.properties = frozenset()
|
||||||
return TiramisuAPI(config_bag)
|
return TiramisuAPI(config_bag)
|
||||||
elif subfunc == 'unrestraint':
|
elif subfunc == 'unrestraint':
|
||||||
if isinstance(self._config, ConfigBag):
|
#if isinstance(self._config, ConfigBag):
|
||||||
config = self._config.context
|
# config = self._config.context
|
||||||
force = self._config.force_permissive
|
# force = self._config.force_permissive
|
||||||
else:
|
#else:
|
||||||
config = self._config
|
config = self._config
|
||||||
force = None
|
#force = None
|
||||||
config_bag = ConfigBag(context=config)
|
config_bag = ConfigBag(context=config)
|
||||||
config_bag.properties = frozenset()
|
config_bag.properties = frozenset()
|
||||||
if force is not None:
|
#if force is not None:
|
||||||
config_bag.force_permissive = force
|
#config_bag.force_permissive = force
|
||||||
return TiramisuAPI(config_bag)
|
return TiramisuAPI(config_bag)
|
||||||
elif subfunc in self.registers:
|
elif subfunc in self.registers:
|
||||||
if not isinstance(self._config, ConfigBag):
|
if not isinstance(self._config, ConfigBag):
|
||||||
|
|
|
@ -74,7 +74,7 @@ def manager_callback(callbk: Union[ParamOption, ParamValue],
|
||||||
return orig_value
|
return orig_value
|
||||||
# don't validate if option is option that we tried to validate
|
# don't validate if option is option that we tried to validate
|
||||||
config_bag = option_bag.config_bag.copy()
|
config_bag = option_bag.config_bag.copy()
|
||||||
config_bag.force_permissive = True
|
config_bag.set_permissive()
|
||||||
soption_bag = OptionBag()
|
soption_bag = OptionBag()
|
||||||
soption_bag.set_option(opt,
|
soption_bag.set_option(opt,
|
||||||
path,
|
path,
|
||||||
|
|
|
@ -467,11 +467,9 @@ class Option(OnlyOption):
|
||||||
if consistencies:
|
if consistencies:
|
||||||
if option_bag.config_bag is undefined:
|
if option_bag.config_bag is undefined:
|
||||||
cconfig_bag = undefined
|
cconfig_bag = undefined
|
||||||
elif option_bag.config_bag.force_permissive != True:
|
|
||||||
cconfig_bag = option_bag.config_bag.copy()
|
|
||||||
cconfig_bag.force_permissive = True
|
|
||||||
else:
|
else:
|
||||||
cconfig_bag = option_bag.config_bag
|
cconfig_bag = option_bag.config_bag
|
||||||
|
cconfig_bag.set_permissive()
|
||||||
for cons_id, func, all_cons_opts, params in consistencies:
|
for cons_id, func, all_cons_opts, params in consistencies:
|
||||||
warnings_only = params.get('warnings_only', False)
|
warnings_only = params.get('warnings_only', False)
|
||||||
if (warnings_only and not check_error) or (not warnings_only and check_error):
|
if (warnings_only and not check_error) or (not warnings_only and check_error):
|
||||||
|
|
|
@ -161,12 +161,12 @@ class OptionBag:
|
||||||
class ConfigBag:
|
class ConfigBag:
|
||||||
__slots__ = ('context', # link to the current context
|
__slots__ = ('context', # link to the current context
|
||||||
'properties', # properties for current context
|
'properties', # properties for current context
|
||||||
#'permissives', # permissives for current context
|
'permissives', # permissives for current context
|
||||||
'force_permissive', # force permissive
|
#'force_permissive', # force permissive
|
||||||
'_validate', # validate
|
'_validate', # validate
|
||||||
)
|
)
|
||||||
def __init__(self, context, **kwargs):
|
def __init__(self, context, **kwargs):
|
||||||
self.force_permissive = False
|
#self.force_permissive = False
|
||||||
self.context = context
|
self.context = context
|
||||||
self._validate = True
|
self._validate = True
|
||||||
for key, value in kwargs.items():
|
for key, value in kwargs.items():
|
||||||
|
@ -176,6 +176,9 @@ class ConfigBag:
|
||||||
if key == 'properties':
|
if key == 'properties':
|
||||||
self.properties = self.context.cfgimpl_get_settings().get_context_properties()
|
self.properties = self.context.cfgimpl_get_settings().get_context_properties()
|
||||||
return self.properties
|
return self.properties
|
||||||
|
if key == 'permissives':
|
||||||
|
self.permissives = self.context.cfgimpl_get_settings().get_context_permissives()
|
||||||
|
return self.permissives
|
||||||
raise KeyError('unknown key {} for ConfigBag'.format(key))
|
raise KeyError('unknown key {} for ConfigBag'.format(key))
|
||||||
|
|
||||||
def remove_validation(self):
|
def remove_validation(self):
|
||||||
|
@ -187,6 +190,9 @@ class ConfigBag:
|
||||||
if self._validate:
|
if self._validate:
|
||||||
self.properties = frozenset(self.properties | {'validator'})
|
self.properties = frozenset(self.properties | {'validator'})
|
||||||
|
|
||||||
|
def set_permissive(self):
|
||||||
|
self.properties = frozenset(self.properties | {'permissive'})
|
||||||
|
|
||||||
def copy(self):
|
def copy(self):
|
||||||
kwargs = {}
|
kwargs = {}
|
||||||
for key in self.__slots__:
|
for key in self.__slots__:
|
||||||
|
@ -393,7 +399,7 @@ class Settings(object):
|
||||||
if apply_requires:
|
if apply_requires:
|
||||||
props |= self.apply_requires(option_bag,
|
props |= self.apply_requires(option_bag,
|
||||||
False)
|
False)
|
||||||
props -= self.getpermissive(opt,
|
props -= self.getpermissives(opt,
|
||||||
path)
|
path)
|
||||||
if apply_requires:
|
if apply_requires:
|
||||||
self._p_.setcache(path,
|
self._p_.setcache(path,
|
||||||
|
@ -404,10 +410,10 @@ class Settings(object):
|
||||||
config_bag.properties)
|
config_bag.properties)
|
||||||
return props
|
return props
|
||||||
|
|
||||||
def get_context_permissive(self):
|
def get_context_permissives(self):
|
||||||
return self.getpermissive(None, None)
|
return self.getpermissives(None, None)
|
||||||
|
|
||||||
def getpermissive(self,
|
def getpermissives(self,
|
||||||
opt,
|
opt,
|
||||||
path):
|
path):
|
||||||
if opt and opt.impl_is_symlinkoption():
|
if opt and opt.impl_is_symlinkoption():
|
||||||
|
@ -415,9 +421,9 @@ class Settings(object):
|
||||||
path = opt.impl_getpath(self._getcontext())
|
path = opt.impl_getpath(self._getcontext())
|
||||||
meta = self._getcontext().cfgimpl_get_meta()
|
meta = self._getcontext().cfgimpl_get_meta()
|
||||||
if meta is not None:
|
if meta is not None:
|
||||||
return meta.cfgimpl_get_settings().getpermissive(opt,
|
return meta.cfgimpl_get_settings().getpermissives(opt,
|
||||||
path)
|
path)
|
||||||
return self._pp_.getpermissive(path)
|
return self._pp_.getpermissives(path)
|
||||||
|
|
||||||
def apply_requires(self,
|
def apply_requires(self,
|
||||||
option_bag,
|
option_bag,
|
||||||
|
@ -497,7 +503,7 @@ class Settings(object):
|
||||||
elif option.impl_is_multi():
|
elif option.impl_is_multi():
|
||||||
is_indexed = True
|
is_indexed = True
|
||||||
config_bag = option_bag.config_bag.copy()
|
config_bag = option_bag.config_bag.copy()
|
||||||
config_bag.force_permissive = True
|
config_bag.set_permissive()
|
||||||
soption_bag = OptionBag()
|
soption_bag = OptionBag()
|
||||||
soption_bag.set_option(option,
|
soption_bag.set_option(option,
|
||||||
reqpath,
|
reqpath,
|
||||||
|
@ -703,10 +709,9 @@ class Settings(object):
|
||||||
properties = option_bag.properties & config_bag.properties - {'frozen', 'mandatory', 'empty'}
|
properties = option_bag.properties & config_bag.properties - {'frozen', 'mandatory', 'empty'}
|
||||||
|
|
||||||
# remove permissive properties
|
# remove permissive properties
|
||||||
if (config_bag.force_permissive is True or \
|
if properties and ('permissive' in config_bag.properties):
|
||||||
'permissive' in config_bag.properties) and properties:
|
|
||||||
# remove global permissive if need
|
# remove global permissive if need
|
||||||
properties -= self.get_context_permissive()
|
properties -= config_bag.permissives
|
||||||
# at this point an option should not remain in properties
|
# at this point an option should not remain in properties
|
||||||
if properties != frozenset():
|
if properties != frozenset():
|
||||||
raise PropertiesOptionError(option_bag,
|
raise PropertiesOptionError(option_bag,
|
||||||
|
@ -719,9 +724,8 @@ class Settings(object):
|
||||||
if 'mandatory' in option_bag.config_bag.properties:
|
if 'mandatory' in option_bag.config_bag.properties:
|
||||||
values = self._getcontext().cfgimpl_get_values()
|
values = self._getcontext().cfgimpl_get_values()
|
||||||
is_mandatory = False
|
is_mandatory = False
|
||||||
if (option_bag.config_bag.force_permissive is True or \
|
if ('permissive' in option_bag.config_bag.properties) and \
|
||||||
'permissive' in option_bag.config_bag.properties) and \
|
'mandatory' in option_bag.config_bag.permissives:
|
||||||
'mandatory' in self.get_context_permissive():
|
|
||||||
pass
|
pass
|
||||||
elif 'mandatory' in option_bag.properties and values.isempty(option_bag.option,
|
elif 'mandatory' in option_bag.properties and values.isempty(option_bag.option,
|
||||||
value,
|
value,
|
||||||
|
@ -742,9 +746,8 @@ class Settings(object):
|
||||||
if option_bag.config_bag.properties and \
|
if option_bag.config_bag.properties and \
|
||||||
('everything_frozen' in option_bag.config_bag.properties or
|
('everything_frozen' in option_bag.config_bag.properties or
|
||||||
'frozen' in option_bag.properties) and \
|
'frozen' in option_bag.properties) and \
|
||||||
not ((option_bag.config_bag.force_permissive is True or
|
not (('permissive' in option_bag.config_bag.properties) and
|
||||||
'permissive' in option_bag.config_bag.properties) and
|
'frozen' in option_bag.config_bag.permissives):
|
||||||
'frozen' in self.get_context_permissive()):
|
|
||||||
raise PropertiesOptionError(option_bag,
|
raise PropertiesOptionError(option_bag,
|
||||||
['frozen'],
|
['frozen'],
|
||||||
self)
|
self)
|
||||||
|
|
|
@ -82,10 +82,10 @@ class Permissives(Cache):
|
||||||
else:
|
else:
|
||||||
self._permissives[path] = permissive
|
self._permissives[path] = permissive
|
||||||
|
|
||||||
def getpermissive(self, path=None):
|
def getpermissives(self, path=None):
|
||||||
ret = self._permissives.get(path, frozenset())
|
ret = self._permissives.get(path, frozenset())
|
||||||
if DEBUG: # pragma: no cover
|
if DEBUG: # pragma: no cover
|
||||||
print('getpermissive', path, ret)
|
print('getpermissives', path, ret)
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def exportation(self):
|
def exportation(self):
|
||||||
|
|
|
@ -630,7 +630,7 @@ class Values(object):
|
||||||
setting_properties.update(['mandatory', 'empty'])
|
setting_properties.update(['mandatory', 'empty'])
|
||||||
config_bag = ConfigBag(context=config_bag.context)
|
config_bag = ConfigBag(context=config_bag.context)
|
||||||
config_bag.properties = frozenset(setting_properties)
|
config_bag.properties = frozenset(setting_properties)
|
||||||
config_bag.force_permissive = True
|
config_bag.set_permissive()
|
||||||
|
|
||||||
descr = context.cfgimpl_get_description()
|
descr = context.cfgimpl_get_description()
|
||||||
return self._mandatory_warnings(context,
|
return self._mandatory_warnings(context,
|
||||||
|
|
Loading…
Reference in New Issue