config not metaconfig
This commit is contained in:
parent
fdbb0d83ff
commit
8e3b9f2d85
3 changed files with 35 additions and 38 deletions
|
@ -10,7 +10,6 @@ from tiramisu import Config, MetaConfig, \
|
|||
StrOption, SymLinkOption, OptionDescription, MasterSlaves, DynOptionDescription, \
|
||||
getapi, submulti, undefined, owners, Params, ParamOption
|
||||
from tiramisu.error import PropertiesOptionError, APIError, ConfigError, SlaveError
|
||||
from tiramisu.api import display_count
|
||||
from collections import OrderedDict
|
||||
ICON = u'\u2937'
|
||||
|
||||
|
@ -1772,4 +1771,3 @@ def test_options(paths):
|
|||
weakrefs, **get_kwargs(lpath))
|
||||
del cfg
|
||||
check_deref(weakrefs)
|
||||
display_count()
|
||||
|
|
|
@ -115,18 +115,20 @@ class CommonTiramisu(TiramisuHelp):
|
|||
self.option_bag.path,
|
||||
self.option_bag.index,
|
||||
self.option_bag.config_bag)
|
||||
index = self.option_bag.index
|
||||
if index is not None:
|
||||
if option.impl_is_optiondescription() or not option.impl_is_master_slaves('slave'):
|
||||
raise APIError('index must be set only with a slave option')
|
||||
self._length = self.subconfig.cfgimpl_get_length_slave(self.option_bag)
|
||||
if index >= self._length:
|
||||
raise SlaveError(_('index "{}" is higher than the master length "{}" '
|
||||
'for option "{}"').format(index,
|
||||
self._length,
|
||||
option.impl_get_display_name()))
|
||||
if not self.allow_optiondescription and option.impl_is_optiondescription():
|
||||
raise APIError(_('option must not be an optiondescription'))
|
||||
if self.option_bag.config_bag.setting_properties:
|
||||
self.option_bag.config_bag.context.cfgimpl_get_settings().validate_properties(self.option_bag)
|
||||
index = self.option_bag.index
|
||||
if index is not None:
|
||||
if option.impl_is_optiondescription() or not option.impl_is_master_slaves('slave'):
|
||||
raise APIError('index must be set only with a slave option')
|
||||
self._length = self.subconfig.cfgimpl_get_length_slave(self.option_bag)
|
||||
if index >= self._length:
|
||||
raise SlaveError(_('index "{}" is higher than the master length "{}" '
|
||||
'for option "{}"').format(index,
|
||||
self._length,
|
||||
option.impl_get_display_name()))
|
||||
if not self.allow_optiondescription and option.impl_is_optiondescription():
|
||||
raise APIError(_('option must not be an optiondescription'))
|
||||
return option
|
||||
|
||||
|
||||
|
@ -504,7 +506,7 @@ class TiramisuOption(CommonTiramisu):
|
|||
return self.registers[subfunc](self._name,
|
||||
self.subconfig,
|
||||
self.option_bag)
|
||||
elif self._get_option().impl_is_optiondescription():
|
||||
elif self._get_option().impl_is_optiondescription() and not subfunc.startswith('_'):
|
||||
return getattr(self, '_' + subfunc)
|
||||
raise APIError(_('please specify a valid sub function ({})').format(subfunc))
|
||||
|
||||
|
|
|
@ -249,24 +249,17 @@ class SubConfig(object):
|
|||
option_bag,
|
||||
_commit=True):
|
||||
|
||||
#self, name = self.cfgimpl_get_home_by_path(option_bag.path,
|
||||
# option_bag.config_bag)
|
||||
#if config_bag.option is None:
|
||||
# config_bag.option = self.cfgimpl_get_description().impl_getchild(name,
|
||||
# config_bag,
|
||||
# self)
|
||||
if option_bag.option.impl_is_symlinkoption():
|
||||
raise ConfigError(_("can't assign to a SymLinkOption"))
|
||||
else:
|
||||
context = self.cfgimpl_get_context()
|
||||
if option_bag.config_bag.setting_properties:
|
||||
context.cfgimpl_get_settings().validate_properties(option_bag)
|
||||
self.cfgimpl_get_description().impl_validate_value(option_bag.option,
|
||||
value,
|
||||
self)
|
||||
return context.cfgimpl_get_values().setvalue(value,
|
||||
option_bag,
|
||||
_commit)
|
||||
context = option_bag.config_bag.context
|
||||
if option_bag.config_bag.setting_properties:
|
||||
context.cfgimpl_get_settings().validate_properties(option_bag)
|
||||
self.cfgimpl_get_description().impl_validate_value(option_bag.option,
|
||||
value,
|
||||
self)
|
||||
return context.cfgimpl_get_values().setvalue(value,
|
||||
option_bag,
|
||||
_commit)
|
||||
|
||||
def delattr(self,
|
||||
option_bag):
|
||||
|
@ -812,25 +805,27 @@ class GroupConfig(_CommonConfig):
|
|||
"""
|
||||
ret = []
|
||||
for child in self._impl_children:
|
||||
cconfig_bag = config_bag.copy()
|
||||
cconfig_bag.context = child
|
||||
try:
|
||||
if isinstance(child, GroupConfig):
|
||||
ret.extend(child.set_value(path,
|
||||
index,
|
||||
value,
|
||||
config_bag,
|
||||
cconfig_bag,
|
||||
only_config=only_config,
|
||||
_commit=False))
|
||||
else:
|
||||
subconfig, name = child.cfgimpl_get_home_by_path(path,
|
||||
config_bag)
|
||||
cconfig_bag)
|
||||
option = subconfig.cfgimpl_get_description().impl_getchild(name,
|
||||
config_bag,
|
||||
cconfig_bag,
|
||||
child)
|
||||
option_bag = OptionBag()
|
||||
option_bag.set_option(option,
|
||||
path,
|
||||
index,
|
||||
config_bag)
|
||||
cconfig_bag)
|
||||
child.setattr(value,
|
||||
option_bag,
|
||||
_commit=False)
|
||||
|
@ -978,16 +973,18 @@ class MetaConfig(GroupConfig):
|
|||
' cannot be set together'))
|
||||
opt = self.cfgimpl_get_description().impl_get_opt_by_path(path)
|
||||
for child in self._impl_children:
|
||||
cconfig_bag = config_bag.copy()
|
||||
cconfig_bag.context = child
|
||||
subconfig, name = child.cfgimpl_get_home_by_path(path,
|
||||
config_bag)
|
||||
cconfig_bag)
|
||||
option = subconfig.cfgimpl_get_description().impl_getchild(name,
|
||||
config_bag,
|
||||
cconfig_bag,
|
||||
child)
|
||||
option_bag = OptionBag()
|
||||
option_bag.set_option(option,
|
||||
path,
|
||||
index,
|
||||
config_bag)
|
||||
cconfig_bag)
|
||||
if force_default_if_same:
|
||||
if not child.cfgimpl_get_values()._p_.hasvalue(path):
|
||||
child_value = undefined
|
||||
|
|
Loading…
Reference in a new issue