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