Compare commits

..

No commits in common. "6f2f4793640ef5dabf45780ad02100fd619cca18" and "60e259fef247dcb7888d742ebb9dcd28baaca0e2" have entirely different histories.

6 changed files with 23 additions and 105 deletions

View file

@ -515,8 +515,6 @@ def test_dyndescription_subdyn():
assert cfg.option('od.dod2val1.dodval1.st').type() == "string"
assert cfg.option('od.dod2.dod').type() == "optiondescription"
assert cfg.option('od.dod2val1.dodval1').type() == "optiondescription"
assert cfg.option('od.dod2.dod').group_type() == "default"
assert cfg.option('od.dod2val1.dodval1').group_type() == "default"
#
with pytest.raises(AttributeOptionError):
cfg.option('od.dod2.dod').identifiers()

View file

@ -162,9 +162,7 @@ def option_type(typ):
kwargs["is_group"] = True
return func(self, options_bag, *args[1:], **kwargs)
self._set_subconfig()
if (
not isinstance(typ, list) or "allow_dynoption" not in typ
) and self._subconfig.is_dynamic_without_identifiers:
if (not isinstance(typ, list) or "allow_dynoption" not in typ) and self._subconfig.is_dynamic_without_identifiers:
raise AttributeOptionError(self._subconfig.path, "option-dynamic")
option = self._subconfig.option
@ -323,15 +321,7 @@ class _TiramisuOptionOptionDescription:
"""Test if option is a leader or a follower"""
return self._subconfig.option.impl_is_leadership()
@option_type(
[
"optiondescription",
"option",
"with_or_without_index",
"symlink",
"allow_dynoption",
]
)
@option_type(["optiondescription", "option", "with_or_without_index", "symlink", "allow_dynoption"])
def description(
self,
with_quote: bool = False,
@ -348,15 +338,7 @@ class _TiramisuOptionOptionDescription:
None,
)
@option_type(
[
"optiondescription",
"option",
"symlink",
"with_or_without_index",
"allow_dynoption",
]
)
@option_type(["optiondescription", "option", "symlink", "with_or_without_index", "allow_dynoption"])
def name(
self,
*,
@ -369,15 +351,7 @@ class _TiramisuOptionOptionDescription:
raise AttributeOptionError(self._subconfig.path, "option-dynamic")
return self._subconfig.true_path.rsplit(".", 1)[-1]
@option_type(
[
"optiondescription",
"option",
"with_or_without_index",
"symlink",
"allow_dynoption",
]
)
@option_type(["optiondescription", "option", "with_or_without_index", "symlink", "allow_dynoption"])
def path(
self,
*,
@ -469,15 +443,7 @@ class _TiramisuOptionOptionDescription:
)
return options
@option_type(
[
"option",
"optiondescription",
"symlink",
"with_or_without_index",
"allow_dynoption",
]
)
@option_type(["option", "optiondescription", "symlink", "with_or_without_index", "allow_dynoption"])
def type(self, only_self=False, translation=False):
"""Get de option type"""
option = self._subconfig.option
@ -500,15 +466,7 @@ class _TiramisuOptionOptionDescription:
"""Get de option extra"""
return self._subconfig.option.impl_get_extra(extra)
@option_type(
[
"option",
"optiondescription",
"symlink",
"with_or_without_index",
"allow_dynoption",
]
)
@option_type(["option", "optiondescription", "symlink", "with_or_without_index", "allow_dynoption"])
def isdynamic(self, *, only_self: bool = False):
"""Test if option is a dynamic optiondescription"""
if not only_self:
@ -717,9 +675,7 @@ class TiramisuOptionProperty(CommonTiramisuOption):
_validate_properties = False
@option_type(
["option", "optiondescription", "with_index", "symlink", "allow_dynoption"]
)
@option_type(["option", "optiondescription", "with_index", "symlink", "allow_dynoption"])
def get(
self,
*,
@ -851,15 +807,7 @@ class TiramisuOptionInformation(CommonTiramisuOption):
_validate_properties = False
@option_type(
[
"option",
"optiondescription",
"with_or_without_index",
"symlink",
"allow_dynoption",
]
)
@option_type(["option", "optiondescription", "with_or_without_index", "symlink", "allow_dynoption"])
def get(
self,
name: str,
@ -892,15 +840,7 @@ class TiramisuOptionInformation(CommonTiramisuOption):
path=self._path,
)
@option_type(
[
"option",
"optiondescription",
"with_or_without_index",
"symlink",
"allow_dynoption",
]
)
@option_type(["option", "optiondescription", "with_or_without_index", "symlink", "allow_dynoption"])
def list(self) -> list:
"""List information's keys"""
lst1 = set(self._subconfig.option._list_information())
@ -1209,7 +1149,7 @@ class TiramisuOption(
subconfig=sub_subconfig,
)
@option_type(["optiondescription", "allow_dynoption"])
@option_type("optiondescription")
def group_type(self):
"""Get type for an optiondescription (only for optiondescription)"""
self._set_subconfig()

View file

@ -25,13 +25,7 @@ from copy import copy, deepcopy
from typing import Optional, List, Any, Union
from os.path import commonprefix
from .error import (
PropertiesOptionError,
ConfigError,
ConflictError,
LeadershipError,
AttributeOptionError,
)
from .error import PropertiesOptionError, ConfigError, ConflictError, LeadershipError, AttributeOptionError
from .option import DynOptionDescription, Leadership, Option
from .setting import ConfigBag, Settings, undefined, groups
from .value import Values, owners
@ -279,16 +273,8 @@ class SubConfig:
self.true_path = true_path
if self.option.impl_is_dynoptiondescription():
self.is_dynamic = True
self.is_dynamic_without_identifiers = identifiers is None or (
parent and identifiers == parent.identifiers
)
if (
check_dynamic_without_identifiers
and parent
and parent.is_dynamic
and self.is_dynamic_without_identifiers
!= parent.is_dynamic_without_identifiers
):
self.is_dynamic_without_identifiers = identifiers is None or (parent and identifiers == parent.identifiers)
if check_dynamic_without_identifiers and parent and parent.is_dynamic and self.is_dynamic_without_identifiers != parent.is_dynamic_without_identifiers:
raise AttributeOptionError(true_path, "option-dynamic")
elif parent:
self.is_dynamic = parent.is_dynamic
@ -412,7 +398,7 @@ class SubConfig:
name = dyn_child.path
if name in children_name:
raise ConflictError(
_('option name "{0}" is not unique in {1}').format(
_("option name \"{0}\" is not unique in {1}").format(
name,
self.option.impl_get_display_name(
self, with_quote=True
@ -434,7 +420,7 @@ class SubConfig:
name = child.impl_getpath()
if name in children_name:
raise ConflictError(
_('option name "{0}" is not unique in {1}').format(
_("option name \"{0}\" is not unique in {1}").format(
name,
self.option.impl_get_display_name(
self, with_quote=True
@ -770,7 +756,7 @@ class _Config(CCache):
):
if path == dyn_child.path:
raise ConflictError(
_('option name "{0}" is not unique in {1}').format(
_("option name \"{0}\" is not unique in {1}").format(
name,
option.impl_get_display_name(
subconfig, with_quote=True
@ -779,7 +765,7 @@ class _Config(CCache):
)
elif child.impl_getname() == name:
raise ConflictError(
_('option name "{0}" is not unique in {1}').format(
_("option name \"{0}\" is not unique in {1}").format(
name,
self.option.impl_get_display_name(
self, with_quote=True

View file

@ -364,10 +364,10 @@ class ValueOptionError(_CommonError, ValueError):
def __init__(self, **kwargs):
if ValueOptionError.tmpl is None:
opt = kwargs.get("opt")
opt = kwargs.get('opt')
if opt and opt._do_not_display_value_in_error:
if kwargs.get("index") is None:
self.tmpl = _("{2} has an invalid {1}")
self.tmpl = _('{2} has an invalid {1}')
else:
self.tmpl = _('{2} at index "{3}" has an invalid {1}')
else:

View file

@ -138,7 +138,9 @@ class DynOptionDescription(OptionDescription):
raise ValueError(
_(
"DynOptionDescription identifiers for option {0}, is not a list ({1})"
).format(name, values)
).format(
name, values
)
)
values_ = []
for val in values:

View file

@ -31,15 +31,7 @@ class IntOption(Option):
_type = "integer"
_t_type = _("integer")
def __init__(
self,
*args,
min_number=None,
max_number=None,
min_integer=None,
max_integer=None,
**kwargs,
):
def __init__(self, *args, min_number=None, max_number=None, min_integer=None, max_integer=None, **kwargs):
extra = {}
if min_number is not None:
extra["min_integer"] = min_number