add demoting_error_warning properties
This commit is contained in:
@ -176,6 +176,7 @@ class OptionBag:
|
||||
class ConfigBag:
|
||||
__slots__ = ('context', # link to the current context
|
||||
'properties', # properties for current context
|
||||
'true_properties', # properties for current context
|
||||
'permissives', # permissives for current context
|
||||
)
|
||||
def __init__(self, context, **kwargs):
|
||||
@ -190,6 +191,8 @@ class ConfigBag:
|
||||
if key == 'permissives':
|
||||
self.permissives = self.context.cfgimpl_get_settings().get_context_permissives()
|
||||
return self.permissives
|
||||
if key == 'true_properties':
|
||||
return self.properties
|
||||
raise KeyError('unknown key {} for ConfigBag'.format(key)) # pragma: no cover
|
||||
|
||||
def remove_warnings(self):
|
||||
@ -198,6 +201,10 @@ class ConfigBag:
|
||||
def remove_validation(self):
|
||||
self.properties = frozenset(self.properties - {'validator'})
|
||||
|
||||
def unrestraint(self):
|
||||
self.true_properties = self.properties
|
||||
self.properties = frozenset(['cache'])
|
||||
|
||||
def set_permissive(self):
|
||||
self.properties = frozenset(self.properties | {'permissive'})
|
||||
|
||||
@ -210,14 +217,15 @@ class ConfigBag:
|
||||
return
|
||||
raise KeyError('unknown key {} for ConfigBag'.format(key)) # pragma: no cover
|
||||
|
||||
#def __setattr__(self, key, value):
|
||||
# super().__setattr__(key, value)
|
||||
# def __setattr__(self, key, value):
|
||||
# super().__setattr__(key, value)
|
||||
|
||||
def copy(self):
|
||||
kwargs = {}
|
||||
for key in self.__slots__:
|
||||
if key in ['properties', 'permissives'] and \
|
||||
if key in ['properties', 'permissives', 'true_properties'] and \
|
||||
not hasattr(self.context, '_impl_settings'):
|
||||
# not for GroupConfig
|
||||
continue
|
||||
kwargs[key] = getattr(self, key)
|
||||
return ConfigBag(**kwargs)
|
||||
@ -503,23 +511,26 @@ class Settings(object):
|
||||
elif option.impl_is_multi() and option_bag.index is not None:
|
||||
is_indexed = True
|
||||
config_bag = option_bag.config_bag.copy()
|
||||
config_bag.set_permissive()
|
||||
soption_bag = OptionBag()
|
||||
soption_bag.set_option(option,
|
||||
reqpath,
|
||||
idx,
|
||||
config_bag)
|
||||
if option_bag.option == option:
|
||||
soption_bag.config_bag.properties = frozenset()
|
||||
soption_bag.config_bag.unrestraint()
|
||||
soption_bag.config_bag.remove_validation()
|
||||
soption_bag.apply_requires = False
|
||||
else:
|
||||
soption_bag.config_bag.properties = soption_bag.config_bag.true_properties
|
||||
soption_bag.config_bag.set_permissive()
|
||||
try:
|
||||
value = context.getattr(reqpath,
|
||||
soption_bag)
|
||||
if is_indexed:
|
||||
value = value[option_bag.index]
|
||||
except PropertiesOptionError as err:
|
||||
properties = err.proptype
|
||||
# if not transitive, properties must be verify in current requires
|
||||
# otherwise if same_action, property must be in properties
|
||||
# otherwise add property in returned properties (if operator is 'and')
|
||||
if not transitive:
|
||||
if all_properties is None:
|
||||
all_properties = []
|
||||
@ -550,6 +561,8 @@ class Settings(object):
|
||||
breaked = True
|
||||
break
|
||||
else:
|
||||
if is_indexed:
|
||||
value = value[option_bag.index]
|
||||
if (not inverse and value in expected or
|
||||
inverse and value not in expected):
|
||||
if operator != 'and':
|
||||
|
Reference in New Issue
Block a user