force_permissive +> permissive
This commit is contained in:
@ -161,12 +161,12 @@ class OptionBag:
|
||||
class ConfigBag:
|
||||
__slots__ = ('context', # link to the current context
|
||||
'properties', # properties for current context
|
||||
#'permissives', # permissives for current context
|
||||
'force_permissive', # force permissive
|
||||
'permissives', # permissives for current context
|
||||
#'force_permissive', # force permissive
|
||||
'_validate', # validate
|
||||
)
|
||||
def __init__(self, context, **kwargs):
|
||||
self.force_permissive = False
|
||||
#self.force_permissive = False
|
||||
self.context = context
|
||||
self._validate = True
|
||||
for key, value in kwargs.items():
|
||||
@ -176,6 +176,9 @@ class ConfigBag:
|
||||
if key == 'properties':
|
||||
self.properties = self.context.cfgimpl_get_settings().get_context_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))
|
||||
|
||||
def remove_validation(self):
|
||||
@ -187,6 +190,9 @@ class ConfigBag:
|
||||
if self._validate:
|
||||
self.properties = frozenset(self.properties | {'validator'})
|
||||
|
||||
def set_permissive(self):
|
||||
self.properties = frozenset(self.properties | {'permissive'})
|
||||
|
||||
def copy(self):
|
||||
kwargs = {}
|
||||
for key in self.__slots__:
|
||||
@ -393,8 +399,8 @@ class Settings(object):
|
||||
if apply_requires:
|
||||
props |= self.apply_requires(option_bag,
|
||||
False)
|
||||
props -= self.getpermissive(opt,
|
||||
path)
|
||||
props -= self.getpermissives(opt,
|
||||
path)
|
||||
if apply_requires:
|
||||
self._p_.setcache(path,
|
||||
index,
|
||||
@ -404,20 +410,20 @@ class Settings(object):
|
||||
config_bag.properties)
|
||||
return props
|
||||
|
||||
def get_context_permissive(self):
|
||||
return self.getpermissive(None, None)
|
||||
def get_context_permissives(self):
|
||||
return self.getpermissives(None, None)
|
||||
|
||||
def getpermissive(self,
|
||||
opt,
|
||||
path):
|
||||
def getpermissives(self,
|
||||
opt,
|
||||
path):
|
||||
if opt and opt.impl_is_symlinkoption():
|
||||
opt = opt.impl_getopt()
|
||||
path = opt.impl_getpath(self._getcontext())
|
||||
meta = self._getcontext().cfgimpl_get_meta()
|
||||
if meta is not None:
|
||||
return meta.cfgimpl_get_settings().getpermissive(opt,
|
||||
path)
|
||||
return self._pp_.getpermissive(path)
|
||||
return meta.cfgimpl_get_settings().getpermissives(opt,
|
||||
path)
|
||||
return self._pp_.getpermissives(path)
|
||||
|
||||
def apply_requires(self,
|
||||
option_bag,
|
||||
@ -497,7 +503,7 @@ class Settings(object):
|
||||
elif option.impl_is_multi():
|
||||
is_indexed = True
|
||||
config_bag = option_bag.config_bag.copy()
|
||||
config_bag.force_permissive = True
|
||||
config_bag.set_permissive()
|
||||
soption_bag = OptionBag()
|
||||
soption_bag.set_option(option,
|
||||
reqpath,
|
||||
@ -703,10 +709,9 @@ class Settings(object):
|
||||
properties = option_bag.properties & config_bag.properties - {'frozen', 'mandatory', 'empty'}
|
||||
|
||||
# remove permissive properties
|
||||
if (config_bag.force_permissive is True or \
|
||||
'permissive' in config_bag.properties) and properties:
|
||||
if properties and ('permissive' in config_bag.properties):
|
||||
# remove global permissive if need
|
||||
properties -= self.get_context_permissive()
|
||||
properties -= config_bag.permissives
|
||||
# at this point an option should not remain in properties
|
||||
if properties != frozenset():
|
||||
raise PropertiesOptionError(option_bag,
|
||||
@ -719,9 +724,8 @@ class Settings(object):
|
||||
if 'mandatory' in option_bag.config_bag.properties:
|
||||
values = self._getcontext().cfgimpl_get_values()
|
||||
is_mandatory = False
|
||||
if (option_bag.config_bag.force_permissive is True or \
|
||||
'permissive' in option_bag.config_bag.properties) and \
|
||||
'mandatory' in self.get_context_permissive():
|
||||
if ('permissive' in option_bag.config_bag.properties) and \
|
||||
'mandatory' in option_bag.config_bag.permissives:
|
||||
pass
|
||||
elif 'mandatory' in option_bag.properties and values.isempty(option_bag.option,
|
||||
value,
|
||||
@ -742,9 +746,8 @@ class Settings(object):
|
||||
if option_bag.config_bag.properties and \
|
||||
('everything_frozen' in option_bag.config_bag.properties or
|
||||
'frozen' in option_bag.properties) and \
|
||||
not ((option_bag.config_bag.force_permissive is True or
|
||||
'permissive' in option_bag.config_bag.properties) and
|
||||
'frozen' in self.get_context_permissive()):
|
||||
not (('permissive' in option_bag.config_bag.properties) and
|
||||
'frozen' in option_bag.config_bag.permissives):
|
||||
raise PropertiesOptionError(option_bag,
|
||||
['frozen'],
|
||||
self)
|
||||
|
Reference in New Issue
Block a user