Compare commits
No commits in common. "b7d97275e36cfe224334788df4184bf0ef696fd2" and "6b0a0d8e56704bc4b62038a6e39594dfd88a0c23" have entirely different histories.
b7d97275e3
...
6b0a0d8e56
6 changed files with 29 additions and 58 deletions
|
|
@ -4,7 +4,7 @@ requires = ["flit_core >=3.8.0,<4"]
|
|||
|
||||
[project]
|
||||
name = "tiramisu"
|
||||
version = "5.2.0a20"
|
||||
version = "5.2.0a19"
|
||||
authors = [{name = "Emmanuel Garette", email = "gnunux@gnunux.info"}]
|
||||
readme = "README.md"
|
||||
description = "an options controller tool"
|
||||
|
|
|
|||
|
|
@ -200,24 +200,6 @@ def test_groups_is_leader(config_type):
|
|||
# assert not list_sessions()
|
||||
|
||||
|
||||
def test_leader_follower_index():
|
||||
ip = StrOption('ip', "", ['val1', 'val2'], multi=True)
|
||||
netmask = StrOption('netmask', "", multi=True, default_multi='value')
|
||||
interface1 = Leadership('leadership', '', [ip, netmask])
|
||||
od1 = OptionDescription('od', '', [interface1])
|
||||
cfg = Config(od1)
|
||||
assert cfg.option('leadership.ip').value.get() == ['val1', 'val2']
|
||||
with pytest.raises(ConfigError):
|
||||
cfg.option('leadership.ip').index(0)
|
||||
follower = cfg.option('leadership.netmask')
|
||||
with pytest.raises(ConfigError):
|
||||
follower.value.get()
|
||||
assert follower.index(0).value.get() == 'value'
|
||||
assert follower.index(0).index(None).index() is None
|
||||
with pytest.raises(ConfigError):
|
||||
follower.index(0).index(None).value.get()
|
||||
|
||||
|
||||
def test_leader_list(config_type):
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", ['val1'], multi=True)
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau", multi=True, default_multi='value')
|
||||
|
|
|
|||
|
|
@ -64,17 +64,15 @@ def test_hidden_owner():
|
|||
od1 = OptionDescription('tiramisu', '', [gcdummy])
|
||||
cfg = Config(od1)
|
||||
cfg.property.read_write()
|
||||
with pytest.raises(PropertiesOptionError):
|
||||
cfg.option('dummy').value.get()
|
||||
with pytest.raises(PropertiesOptionError):
|
||||
cfg.option('dummy').owner.isdefault()
|
||||
#with pytest.raises(PropertiesOptionError):
|
||||
# cfg.forcepermissive.option('dummy').owner.get()
|
||||
#with pytest.raises(PropertiesOptionError):
|
||||
# cfg.option('dummy').owner.isdefault()
|
||||
#with pytest.raises(PropertiesOptionError):
|
||||
# cfg.forcepermissive.option('dummy').owner.isdefault()
|
||||
cfg.permissive.add('hidden')
|
||||
cfg.forcepermissive.option('dummy').value.get()
|
||||
cfg.forcepermissive.option('dummy').owner.isdefault()
|
||||
option = cfg.option("dummy")
|
||||
option.forcepermissive()
|
||||
option.value.get()
|
||||
option.owner.isdefault()
|
||||
# assert not list_sessions()
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
__version__ = "5.2.0a20"
|
||||
__version__ = "5.2.0a19"
|
||||
|
|
|
|||
|
|
@ -253,12 +253,11 @@ class CommonTiramisuOption(CommonTiramisu):
|
|||
path: str,
|
||||
index: Optional[int],
|
||||
config_bag: ConfigBag,
|
||||
subconfig: Optional[SubConfig]=None,
|
||||
) -> None:
|
||||
self._path = path
|
||||
self._index = index
|
||||
self._config_bag = config_bag
|
||||
self._subconfig = subconfig
|
||||
self._subconfig = None
|
||||
self._set_subconfig()
|
||||
|
||||
|
||||
|
|
@ -663,16 +662,11 @@ class _TiramisuOptionOption(_TiramisuOptionOptionDescription):
|
|||
return r"^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$"
|
||||
|
||||
@option_type(["option", "with_or_without_index", "symlink"])
|
||||
def index(self, index=undefined):
|
||||
def index(self, index=None):
|
||||
"""Get index of option"""
|
||||
if index is undefined:
|
||||
if index is None:
|
||||
return self._subconfig.index
|
||||
subconfig = self._subconfig.parent.get_child(
|
||||
self._subconfig.option,
|
||||
index,
|
||||
True,
|
||||
)
|
||||
return TiramisuOption(self._path, index, self._config_bag, subconfig=subconfig)
|
||||
return TiramisuOption(self._path, index, self._config_bag)
|
||||
|
||||
@option_type(["symlink", "optiondescription", "allow_dynoption"])
|
||||
def option(self, *args, **kwargs):
|
||||
|
|
@ -1068,6 +1062,11 @@ class TiramisuOptionValue(CommonTiramisuOption, _TiramisuODGet):
|
|||
self.__class__.__name__, func.__name__
|
||||
)
|
||||
raise ConfigError(msg)
|
||||
if (
|
||||
"force_store_value" in self._subconfig.properties
|
||||
and "force_store_value" in self._config_bag.properties
|
||||
):
|
||||
return self._get(self._subconfig)
|
||||
return self._config_bag.context.get_values().get_default_value(self._subconfig)
|
||||
|
||||
@option_type(
|
||||
|
|
@ -1239,7 +1238,6 @@ class TiramisuOption(
|
|||
self._path,
|
||||
self._index,
|
||||
self._config_bag,
|
||||
self._subconfig,
|
||||
)
|
||||
raise ConfigError(
|
||||
_("please specify a valid sub function ({0}.{1}) for {2}").format(
|
||||
|
|
@ -1319,10 +1317,6 @@ class TiramisuOption(
|
|||
self._load_dict()
|
||||
return self._tiramisu_dict.set_updates(body)
|
||||
|
||||
def forcepermissive(self):
|
||||
self._set_subconfig()
|
||||
self._subconfig.config_bag.set_permissive()
|
||||
|
||||
|
||||
class TiramisuContextInformation(TiramisuConfig):
|
||||
"""Manage config informations"""
|
||||
|
|
|
|||
|
|
@ -318,31 +318,28 @@ class Values:
|
|||
elif isinstance(value, list):
|
||||
# copy
|
||||
value = value.copy()
|
||||
elif isinstance(value, Calculation):
|
||||
value, _has_calculation = get_calculated_value(
|
||||
subconfig,
|
||||
value,
|
||||
)
|
||||
self._setvalue(
|
||||
subconfig,
|
||||
ori_value,
|
||||
owner,
|
||||
)
|
||||
if (
|
||||
"force_store_value" in setting_properties
|
||||
"force_store_value" in self_properties
|
||||
and subconfig.option.impl_is_leader()
|
||||
):
|
||||
leader = subconfig.option.impl_get_leadership()
|
||||
parent = subconfig.parent
|
||||
try:
|
||||
if isinstance(value, Calculation):
|
||||
value, has_calculation = get_calculated_value(
|
||||
subconfig,
|
||||
value,
|
||||
)
|
||||
parent._length = len(value)
|
||||
leader.follower_force_store_value(
|
||||
value,
|
||||
parent,
|
||||
owners.forced,
|
||||
)
|
||||
except:
|
||||
pass
|
||||
parent._length = len(value)
|
||||
leader.follower_force_store_value(
|
||||
value,
|
||||
parent,
|
||||
owners.forced,
|
||||
)
|
||||
validator = (
|
||||
"validator" in setting_properties
|
||||
and "validator" in self_properties
|
||||
|
|
|
|||
Loading…
Reference in a new issue