add force_metaconfig_on_freeze special properties

This commit is contained in:
2019-02-23 22:10:43 +01:00
parent c3f968dbde
commit 1bbcea60ab
8 changed files with 129 additions and 34 deletions

View File

@ -113,6 +113,7 @@ RW_REMOVE = frozenset(['permissive', 'everything_frozen', 'mandatory',
FORBIDDEN_SET_PROPERTIES = frozenset(['force_store_value'])
FORBIDDEN_SET_PERMISSIVES = frozenset(['force_default_on_freeze',
'force_metaconfig_on_freeze',
'force_store_value'])
@ -164,11 +165,14 @@ class OptionBag:
def __delattr__(self, key):
if key in ['properties', 'permissives']:
try:
super().__delattr__(key)
except AttributeError:
pass
return
raise KeyError('unknown key {} for ConfigBag'.format(key)) # pragma: no cover
def copy(self):
kwargs = {}
option_bag = OptionBag()
for key in self.__slots__:
if key == 'properties' and self.config_bag is undefined:
@ -182,7 +186,7 @@ class ConfigBag:
'properties', # properties for current context
'true_properties', # properties for current context
'permissives', # permissives for current context
)
)
def __init__(self, context, **kwargs):
self.context = context
for key, value in kwargs.items():
@ -302,10 +306,10 @@ groups = GroupModule()
groups.default = groups.DefaultGroupType('default')
"""groups.leadership
leadership group is a special optiondescription, all suboptions should be
multi option and all values should have same length, to find leader's
option, the optiondescription's name should be same than de leader's
option"""
leadership group is a special optiondescription, all suboptions should
be multi option and all values should have same length, to find
leader's option, the optiondescription's name should be same than de
leader's option"""
groups.leadership = groups.LeadershipGroupType('leadership')
""" groups.family
@ -607,10 +611,9 @@ class Settings(object):
def set_context_properties(self,
properties,
context):
self.setproperties(None,
properties,
None,
context)
self._p_.setproperties(None,
properties)
context.cfgimpl_reset_cache(None)
def setproperties(self,
path,
@ -621,33 +624,29 @@ class Settings(object):
(never save properties if same has option properties)
"""
# should have index !!!
if path is not None and option_bag.option.impl_getrequires() is not None:
opt = option_bag.option
if opt.impl_getrequires() is not None:
not_allowed_props = properties & \
getattr(option_bag.option, '_calc_properties', static_set)
getattr(opt, '_calc_properties', static_set)
if not_allowed_props:
raise ValueError(_('cannot set property {} for option "{}" this property is '
'calculated').format(display_list(list(not_allowed_props),
add_quote=True),
option_bag.option.impl_get_display_name()))
if option_bag is None:
opt = None
else:
opt = option_bag.option
if opt and opt.impl_is_symlinkoption():
opt.impl_get_display_name()))
if opt.impl_is_symlinkoption():
raise TypeError(_("can't assign property to the symlinkoption \"{}\""
"").format(opt.impl_get_display_name()))
if 'force_default_on_freeze' in properties and \
if ('force_default_on_freeze' in properties or 'force_metaconfig_on_freeze' in properties) and \
'frozen' not in properties and \
opt.impl_is_leader():
raise ConfigError(_('a leader ({0}) cannot have '
'"force_default_on_freeze" property without "frozen"'
'"force_default_on_freeze" or "force_metaconfig_on_freeze" property without "frozen"'
'').format(opt.impl_get_display_name()))
self._p_.setproperties(path,
properties)
# values too because of follower values could have a PropertiesOptionError has value
context.cfgimpl_reset_cache(option_bag)
if option_bag is not None:
del option_bag.properties
del option_bag.properties
def set_context_permissives(self,
permissives):