Compare commits
No commits in common. "main" and "5.2.0rc0" have entirely different histories.
38 changed files with 593 additions and 693 deletions
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -4,7 +4,7 @@ requires = ["flit_core >=3.8.0,<4"]
|
|||
|
||||
[project]
|
||||
name = "tiramisu"
|
||||
version = "5.2.0"
|
||||
version = "5.2.0rc0"
|
||||
authors = [{name = "Emmanuel Garette", email = "gnunux@gnunux.info"}]
|
||||
readme = "README.md"
|
||||
description = "an options controller tool"
|
||||
|
|
|
|||
|
|
@ -12,7 +12,8 @@
|
|||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
"""Configuration management library written in python"""
|
||||
"""Configuration management library written in python
|
||||
"""
|
||||
from .function import (
|
||||
calc_value,
|
||||
calc_value_property_help,
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
__version__ = "5.2.0"
|
||||
__version__ = "5.2.0rc0"
|
||||
|
|
|
|||
116
tiramisu/api.py
116
tiramisu/api.py
|
|
@ -141,8 +141,7 @@ class CommonTiramisu(TiramisuHelp):
|
|||
raise ConfigError(str(err))
|
||||
if id(self._subconfig.config_bag) != id(self._config_bag):
|
||||
subconfig = self._subconfig
|
||||
self._subconfig = subconfig.__class__(
|
||||
option=subconfig.option,
|
||||
self._subconfig = subconfig.__class__(option=subconfig.option,
|
||||
index=subconfig.index,
|
||||
path=subconfig.path,
|
||||
config_bag=self._config_bag,
|
||||
|
|
@ -154,9 +153,7 @@ class CommonTiramisu(TiramisuHelp):
|
|||
validate_properties=False,
|
||||
check_dynamic_without_identifiers=False,
|
||||
)
|
||||
self._subconfig.is_self_dynamic_without_identifiers = (
|
||||
subconfig.is_self_dynamic_without_identifiers
|
||||
)
|
||||
self._subconfig.is_self_dynamic_without_identifiers = subconfig.is_self_dynamic_without_identifiers
|
||||
else:
|
||||
self._subconfig._length = None
|
||||
if not self._subconfig:
|
||||
|
|
@ -192,11 +189,7 @@ def option_type(types):
|
|||
return func(self, options_bag, *args[1:], **kwargs)
|
||||
self._set_subconfig()
|
||||
if (
|
||||
"allow_dynoption" not in types
|
||||
and not (
|
||||
"dynoption_or_uncalculated" in types
|
||||
and kwargs.get("uncalculated", False) is True
|
||||
)
|
||||
"allow_dynoption" not in types and not ("dynoption_or_uncalculated" in types and kwargs.get("uncalculated", False) is True)
|
||||
) and self._subconfig.is_dynamic_without_identifiers:
|
||||
raise AttributeOptionError(self._subconfig.path, "option-dynamic")
|
||||
|
||||
|
|
@ -244,13 +237,7 @@ def option_type(types):
|
|||
self.__class__.__name__, func.__name__
|
||||
)
|
||||
raise ConfigError(msg)
|
||||
if self._index is None and (
|
||||
"with_index" in types
|
||||
or (
|
||||
"with_index_or_uncalculated" in types
|
||||
and kwargs.get("uncalculated", False) is False
|
||||
)
|
||||
):
|
||||
if self._index is None and ("with_index" in types or ("with_index_or_uncalculated" in types and kwargs.get("uncalculated", False) is False)):
|
||||
msg = _(
|
||||
"please specify index with a follower option ({0}.{1})"
|
||||
).format(self.__class__.__name__, func.__name__)
|
||||
|
|
@ -471,11 +458,7 @@ class _TiramisuOptionOptionDescription:
|
|||
):
|
||||
if subconfig.properties is None:
|
||||
subconfig.properties = undefined
|
||||
if (
|
||||
is_default
|
||||
and subconfig.config_bag.context.get_owner(subconfig)
|
||||
!= owners.default
|
||||
):
|
||||
if is_default and subconfig.config_bag.context.get_owner(subconfig) != owners.default:
|
||||
continue
|
||||
options.append(
|
||||
TiramisuOption(
|
||||
|
|
@ -488,11 +471,7 @@ class _TiramisuOptionOptionDescription:
|
|||
for subconfig in context.get_dynamic_from_dyn_option(
|
||||
self._subconfig, option
|
||||
):
|
||||
if (
|
||||
is_default
|
||||
and subconfig.config_bag.context.get_owner(subconfig)
|
||||
!= owners.default
|
||||
):
|
||||
if is_default and subconfig.config_bag.context.get_owner(subconfig) != owners.default:
|
||||
continue
|
||||
options.append(
|
||||
TiramisuOption(
|
||||
|
|
@ -523,11 +502,7 @@ class _TiramisuOptionOptionDescription:
|
|||
)
|
||||
t_option._set_subconfig()
|
||||
subconfig = t_option._subconfig
|
||||
if (
|
||||
is_default
|
||||
and subconfig.config_bag.context.get_owner(subconfig)
|
||||
!= owners.default
|
||||
):
|
||||
if is_default and subconfig.config_bag.context.get_owner(subconfig) != owners.default:
|
||||
continue
|
||||
options.append(
|
||||
t_option,
|
||||
|
|
@ -655,10 +630,7 @@ class _TiramisuOptionOptionDescription:
|
|||
dynconfig = None
|
||||
_subconfig = subconfig
|
||||
while not dynconfig:
|
||||
if (
|
||||
_subconfig.option.impl_is_optiondescription()
|
||||
and _subconfig.option.impl_is_dynoptiondescription()
|
||||
):
|
||||
if _subconfig.option.impl_is_optiondescription() and _subconfig.option.impl_is_dynoptiondescription():
|
||||
dynconfig = _subconfig
|
||||
else:
|
||||
_subconfig = _subconfig.parent
|
||||
|
|
@ -677,30 +649,18 @@ class _TiramisuOptionOptionDescription:
|
|||
"""
|
||||
identifiers = []
|
||||
while True:
|
||||
if (
|
||||
subconfig.option.impl_is_optiondescription()
|
||||
and subconfig.option.impl_is_dynoptiondescription()
|
||||
):
|
||||
if subconfig.option.impl_is_optiondescription() and subconfig.option.impl_is_dynoptiondescription():
|
||||
if not subconfig.is_self_dynamic_without_identifiers:
|
||||
new_identifiers = [subconfig.identifiers[-1]]
|
||||
else:
|
||||
new_identifiers = subconfig.option.get_identifiers(
|
||||
subconfig.parent, uncalculated=uncalculated, convert=convert
|
||||
)
|
||||
new_identifiers = subconfig.option.get_identifiers(subconfig.parent, uncalculated=uncalculated, convert=convert)
|
||||
if isinstance(new_identifiers, Calculation):
|
||||
if identifiers:
|
||||
identifiers = [
|
||||
[new_identifiers] + old_identifiers
|
||||
for old_identifiers in identifiers
|
||||
]
|
||||
identifiers = [[new_identifiers] + old_identifiers for old_identifiers in identifiers]
|
||||
else:
|
||||
identifiers = [new_identifiers]
|
||||
elif identifiers:
|
||||
identifiers = [
|
||||
[identifier] + old_identifiers
|
||||
for identifier in new_identifiers
|
||||
for old_identifiers in identifiers
|
||||
]
|
||||
identifiers = [[identifier] + old_identifiers for identifier in new_identifiers for old_identifiers in identifiers]
|
||||
else:
|
||||
identifiers = [[identifier] for identifier in new_identifiers]
|
||||
subconfig = subconfig.parent
|
||||
|
|
@ -722,10 +682,7 @@ class _TiramisuOptionOptionDescription:
|
|||
dynconfig = None
|
||||
_subconfig = subconfig
|
||||
while not dynconfig:
|
||||
if (
|
||||
_subconfig.option.impl_is_optiondescription()
|
||||
and _subconfig.option.impl_is_dynoptiondescription()
|
||||
):
|
||||
if _subconfig.option.impl_is_optiondescription() and _subconfig.option.impl_is_dynoptiondescription():
|
||||
dynconfig = _subconfig
|
||||
_subconfig = _subconfig.parent
|
||||
return dynconfig.option.get_identifiers(
|
||||
|
|
@ -852,7 +809,10 @@ class TiramisuOptionOwner(CommonTiramisuOption):
|
|||
"""Is option has defaut value"""
|
||||
subconfig = self._subconfig
|
||||
s_properties = subconfig.properties
|
||||
if "frozen" in s_properties and "force_default_on_freeze" in s_properties:
|
||||
if (
|
||||
"frozen" in s_properties
|
||||
and "force_default_on_freeze" in s_properties
|
||||
):
|
||||
return True
|
||||
context = self._config_bag.context
|
||||
subconfig = context._get(
|
||||
|
|
@ -884,13 +844,7 @@ class TiramisuOptionProperty(CommonTiramisuOption):
|
|||
_validate_properties = False
|
||||
|
||||
@option_type(
|
||||
[
|
||||
"option",
|
||||
"optiondescription",
|
||||
"with_index_or_uncalculated",
|
||||
"symlink",
|
||||
"allow_dynoption",
|
||||
]
|
||||
["option", "optiondescription", "with_index_or_uncalculated", "symlink", "allow_dynoption"]
|
||||
)
|
||||
def get(
|
||||
self,
|
||||
|
|
@ -1111,15 +1065,7 @@ class TiramisuOptionValue(CommonTiramisuOption, _TiramisuODGet):
|
|||
|
||||
_validate_properties = True
|
||||
|
||||
@option_type(
|
||||
[
|
||||
"option",
|
||||
"symlink",
|
||||
"with_index",
|
||||
"optiondescription",
|
||||
"dynoption_or_uncalculated",
|
||||
]
|
||||
)
|
||||
@option_type(["option", "symlink", "with_index", "optiondescription", "dynoption_or_uncalculated"])
|
||||
def get(
|
||||
self,
|
||||
*,
|
||||
|
|
@ -1183,13 +1129,7 @@ class TiramisuOptionValue(CommonTiramisuOption, _TiramisuODGet):
|
|||
values.reset(self._subconfig)
|
||||
|
||||
@option_type(
|
||||
[
|
||||
"option",
|
||||
"with_or_without_index",
|
||||
"symlink",
|
||||
"dont_validate_property",
|
||||
"dynoption_or_uncalculated",
|
||||
]
|
||||
["option", "with_or_without_index", "symlink", "dont_validate_property", "dynoption_or_uncalculated"]
|
||||
)
|
||||
def default(
|
||||
self,
|
||||
|
|
@ -1488,8 +1428,6 @@ class TiramisuOption(
|
|||
if self._tiramisu_dict is None: # pragma: no cover
|
||||
self._load_dict()
|
||||
return self._tiramisu_dict.set_updates(body)
|
||||
|
||||
|
||||
#
|
||||
# def forcepermissive(self):
|
||||
# self._set_subconfig()
|
||||
|
|
@ -1564,11 +1502,8 @@ class TiramisuContextValue(TiramisuConfig, _TiramisuODGet):
|
|||
only_mandatory=True,
|
||||
):
|
||||
if id(subconfig.config_bag) != id(config_bag):
|
||||
old_is_dynamic_without_identifiers = (
|
||||
subconfig.is_self_dynamic_without_identifiers
|
||||
)
|
||||
subconfig = subconfig.__class__(
|
||||
option=subconfig.option,
|
||||
old_is_dynamic_without_identifiers = subconfig.is_self_dynamic_without_identifiers
|
||||
subconfig = subconfig.__class__(option=subconfig.option,
|
||||
index=subconfig.index,
|
||||
path=subconfig.path,
|
||||
config_bag=config_bag,
|
||||
|
|
@ -1580,9 +1515,7 @@ class TiramisuContextValue(TiramisuConfig, _TiramisuODGet):
|
|||
validate_properties=False,
|
||||
check_dynamic_without_identifiers=False,
|
||||
)
|
||||
subconfig.is_self_dynamic_without_identifiers = (
|
||||
old_is_dynamic_without_identifiers
|
||||
)
|
||||
subconfig.is_self_dynamic_without_identifiers = old_is_dynamic_without_identifiers
|
||||
else:
|
||||
subconfig._length = None
|
||||
options.append(
|
||||
|
|
@ -2296,7 +2229,6 @@ class TiramisuAPI(TiramisuHelp):
|
|||
class ConfigProp(TiramisuAPI, TiramisuContextOption):
|
||||
pass
|
||||
|
||||
|
||||
class Config(TiramisuAPI, TiramisuContextOption):
|
||||
"""Root config object that enables us to handle the configuration options"""
|
||||
|
||||
|
|
@ -2323,8 +2255,6 @@ class Config(TiramisuAPI, TiramisuContextOption):
|
|||
permissives=permissives,
|
||||
)
|
||||
super().__init__(config_bag)
|
||||
|
||||
|
||||
#
|
||||
# def __del__(self):
|
||||
# try:
|
||||
|
|
|
|||
|
|
@ -157,9 +157,9 @@ class ParamDynOption(ParamOption):
|
|||
)
|
||||
if not isinstance(identifiers, (list, Calculation)):
|
||||
raise Exception(
|
||||
_(
|
||||
"identifiers in ParamDynOption must be a list or a calculation, not {0}"
|
||||
).format(identifiers)
|
||||
_("identifiers in ParamDynOption must be a list or a calculation, not {0}").format(
|
||||
identifiers
|
||||
)
|
||||
)
|
||||
if not isinstance(optional, bool):
|
||||
raise Exception(
|
||||
|
|
@ -628,26 +628,21 @@ def manager_callback(
|
|||
properties = config_bag.context.get_settings().getproperties(
|
||||
subconfig,
|
||||
uncalculated=True,
|
||||
) - {"validator", "mandatory", "empty"}
|
||||
) - {'validator', 'mandatory', 'empty'}
|
||||
for subconfig_ in subconfigs:
|
||||
if subconfig.path == subconfig_.path:
|
||||
values.append(orig_value)
|
||||
else:
|
||||
subconfig_.properties = properties
|
||||
values.append(
|
||||
get_value(
|
||||
values.append(get_value(
|
||||
config_bag,
|
||||
subconfig_,
|
||||
param,
|
||||
True,
|
||||
)
|
||||
)
|
||||
))
|
||||
if callback.__name__ not in FUNCTION_WAITING_FOR_DICT:
|
||||
return values
|
||||
return {
|
||||
"name": search_option.impl_get_display_name(subconfig),
|
||||
"value": values,
|
||||
}
|
||||
return {"name": search_option.impl_get_display_name(subconfig), "value": values}
|
||||
else:
|
||||
value = calc_self(
|
||||
param,
|
||||
|
|
@ -784,9 +779,7 @@ def manager_callback(
|
|||
or param.raisepropertyerror
|
||||
):
|
||||
raise err from err
|
||||
raise ConfigError(
|
||||
str(err), subconfig=subconfig
|
||||
) from err
|
||||
raise ConfigError(str(err), subconfig=subconfig) from err
|
||||
parents = new_parents
|
||||
if subconfigs_is_a_list:
|
||||
subconfigs = parents
|
||||
|
|
@ -889,8 +882,7 @@ def carry_out_calculation(
|
|||
config_bag = config_bag.copy()
|
||||
config_bag.set_permissive()
|
||||
old_is_dynamic_without_identifiers = subconfig.is_dynamic_without_identifiers
|
||||
subconfig = subconfig.__class__(
|
||||
option=subconfig.option,
|
||||
subconfig = subconfig.__class__(option=subconfig.option,
|
||||
index=subconfig.index,
|
||||
path=subconfig.path,
|
||||
config_bag=config_bag,
|
||||
|
|
|
|||
|
|
@ -18,7 +18,8 @@
|
|||
# the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/
|
||||
# the whole pypy projet is under MIT licence
|
||||
# ____________________________________________________________
|
||||
"""options handler global entry point"""
|
||||
"""options handler global entry point
|
||||
"""
|
||||
import weakref
|
||||
from copy import copy, deepcopy
|
||||
from typing import Optional, List, Any, Union
|
||||
|
|
@ -48,7 +49,7 @@ def get_common_path(path1, path2):
|
|||
if common_path in all_paths:
|
||||
# od.st is not the common_path of od.st_in
|
||||
all_paths.remove(common_path)
|
||||
if all_paths[0].startswith(common_path + "."):
|
||||
if all_paths[0].startswith(common_path + '.'):
|
||||
return common_path
|
||||
if common_path.endswith("."):
|
||||
return common_path[:-1]
|
||||
|
|
@ -104,9 +105,7 @@ class CCache:
|
|||
if not force:
|
||||
# if is_default and config_bag.context.get_owner(subconfig) != owners.default:
|
||||
# return
|
||||
for is_default, woption in subconfig.option.get_dependencies(
|
||||
subconfig.option
|
||||
):
|
||||
for is_default, woption in subconfig.option.get_dependencies(subconfig.option):
|
||||
option = woption()
|
||||
if option.issubdyn():
|
||||
# it's an option in dynoptiondescription, remove cache for all generated option
|
||||
|
|
@ -344,13 +343,7 @@ class SubConfig:
|
|||
self.config_bag.context.get_settings().validate_properties(self)
|
||||
self._properties = undefined
|
||||
self.config_bag.context.get_settings().validate_properties(self)
|
||||
if (
|
||||
validate_properties
|
||||
and self.apply_requires
|
||||
and self.option.impl_is_optiondescription()
|
||||
and self.path
|
||||
and self.properties is not None
|
||||
):
|
||||
if validate_properties and self.apply_requires and self.option.impl_is_optiondescription() and self.path and self.properties is not None:
|
||||
settings = config_bag.context.get_settings()
|
||||
self.transitive_properties = settings.calc_transitive_properties(
|
||||
self,
|
||||
|
|
@ -533,10 +526,7 @@ class SubConfig:
|
|||
)
|
||||
if check_index and index is not None:
|
||||
if option.impl_is_optiondescription() or not option.impl_is_follower():
|
||||
raise ConfigError(
|
||||
"index must be set only with a follower option",
|
||||
subconfig=subsubconfig,
|
||||
)
|
||||
raise ConfigError("index must be set only with a follower option", subconfig=subsubconfig,)
|
||||
length = self.get_length_leadership()
|
||||
if index >= length:
|
||||
raise LeadershipError(
|
||||
|
|
@ -577,9 +567,7 @@ class SubConfig:
|
|||
None,
|
||||
validate_properties=False,
|
||||
)
|
||||
subconfig.is_self_dynamic_without_identifiers = (
|
||||
self.is_self_dynamic_without_identifiers
|
||||
)
|
||||
subconfig.is_self_dynamic_without_identifiers = self.is_self_dynamic_without_identifiers
|
||||
#FIXME
|
||||
#self._length = len(cconfig_bag.context.get_value(subconfig))
|
||||
length = len(cconfig_bag.context.get_value(subconfig))
|
||||
|
|
@ -693,9 +681,7 @@ class SubConfig:
|
|||
true_path=self.true_path,
|
||||
validate_properties=False,
|
||||
)
|
||||
subconfig.is_self_dynamic_without_identifiers = (
|
||||
self.is_self_dynamic_without_identifiers
|
||||
)
|
||||
subconfig.is_self_dynamic_without_identifiers = self.is_self_dynamic_without_identifiers
|
||||
return subconfig
|
||||
|
||||
|
||||
|
|
@ -1087,7 +1073,6 @@ class _Config(CCache):
|
|||
|
||||
class _CommonConfig(_Config):
|
||||
"abstract base class for the Config, KernelGroupConfig and the KernelMetaConfig"
|
||||
|
||||
__slots__ = (
|
||||
"_impl_values",
|
||||
"_impl_values_cache",
|
||||
|
|
@ -1920,7 +1905,9 @@ class KernelMetaConfig(KernelMixConfig):
|
|||
if descr is None:
|
||||
descr = child.get_description()
|
||||
if child.impl_getname() is None:
|
||||
raise ConfigError(_("children in MetaConfig must have name"))
|
||||
raise ConfigError(
|
||||
_("children in MetaConfig must have name")
|
||||
)
|
||||
elif descr is not child.get_description():
|
||||
raise ValueError(
|
||||
_(
|
||||
|
|
|
|||
|
|
@ -230,7 +230,6 @@ class ConfigError(Exception):
|
|||
|
||||
class ConflictError(Exception):
|
||||
"duplicate options are present in a single config"
|
||||
|
||||
pass
|
||||
|
||||
|
||||
|
|
@ -309,7 +308,6 @@ class LeadershipError(Exception):
|
|||
|
||||
class ConstError(TypeError):
|
||||
"no uniq value in _NameSpace"
|
||||
|
||||
pass
|
||||
|
||||
|
||||
|
|
@ -428,8 +426,7 @@ class Errors:
|
|||
display_name = option.impl_get_display_name(subconfig, with_quote=True)
|
||||
if original_error:
|
||||
raise ConfigError(
|
||||
message.format(display_name, original_error, *extra_keys),
|
||||
subconfig=subconfig,
|
||||
message.format(display_name, original_error, *extra_keys), subconfig=subconfig,
|
||||
) from original_error
|
||||
raise ConfigError(message.format(display_name, extra_keys), subconfig=subconfig)
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,8 @@
|
|||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
"""some functions to validates or calculates value"""
|
||||
"""some functions to validates or calculates value
|
||||
"""
|
||||
from typing import Any, List, Optional
|
||||
from operator import add, mul, sub, truediv
|
||||
from ipaddress import ip_address, ip_interface, ip_network
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -18,7 +18,8 @@
|
|||
# the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/
|
||||
# the whole pypy projet is under MIT licence
|
||||
# ____________________________________________________________
|
||||
"""all official option"""
|
||||
"""all official option
|
||||
"""
|
||||
from .optiondescription import OptionDescription
|
||||
from .dynoptiondescription import DynOptionDescription
|
||||
from .leadership import Leadership
|
||||
|
|
|
|||
|
|
@ -18,7 +18,8 @@
|
|||
# the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/
|
||||
# the whole pypy projet is under MIT licence
|
||||
# ____________________________________________________________
|
||||
"""base option"""
|
||||
"""base option
|
||||
"""
|
||||
from typing import FrozenSet, Set, Any, List, Optional, Dict
|
||||
import weakref
|
||||
from itertools import chain
|
||||
|
|
@ -26,13 +27,7 @@ from itertools import chain
|
|||
|
||||
from ..i18n import _
|
||||
from ..setting import undefined
|
||||
from ..autolib import (
|
||||
Calculation,
|
||||
ParamOption,
|
||||
ParamSelfOption,
|
||||
ParamInformation,
|
||||
ParamSelfInformation,
|
||||
)
|
||||
from ..autolib import Calculation, ParamOption, ParamSelfOption, ParamInformation, ParamSelfInformation
|
||||
|
||||
STATIC_TUPLE = frozenset()
|
||||
|
||||
|
|
@ -395,7 +390,10 @@ class BaseOption(Base):
|
|||
self.value_dependency(value, is_identifier)
|
||||
|
||||
def value_dependency(
|
||||
self, value: Any, is_identifier: bool = False, type_: str = "default"
|
||||
self,
|
||||
value: Any,
|
||||
is_identifier: bool = False,
|
||||
type_: str = 'default'
|
||||
) -> Any:
|
||||
if not isinstance(is_identifier, bool):
|
||||
raise Exception()
|
||||
|
|
|
|||
|
|
@ -18,7 +18,8 @@
|
|||
# the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/
|
||||
# the whole pypy projet is under MIT licence
|
||||
# ____________________________________________________________
|
||||
"""BoolOption"""
|
||||
"""BoolOption
|
||||
"""
|
||||
|
||||
from ..i18n import _
|
||||
from .option import Option
|
||||
|
|
|
|||
|
|
@ -18,7 +18,8 @@
|
|||
# the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/
|
||||
# the whole pypy projet is under MIT licence
|
||||
# ____________________________________________________________
|
||||
"""BroadcastOption"""
|
||||
"""BroadcastOption
|
||||
"""
|
||||
from ipaddress import ip_address
|
||||
|
||||
from ..i18n import _
|
||||
|
|
|
|||
|
|
@ -18,7 +18,8 @@
|
|||
# the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/
|
||||
# the whole pypy projet is under MIT licence
|
||||
# ____________________________________________________________
|
||||
"""ChoiceOption"""
|
||||
"""ChoiceOption
|
||||
"""
|
||||
from typing import Any
|
||||
from itertools import chain
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,8 @@
|
|||
# the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/
|
||||
# the whole pypy projet is under MIT licence
|
||||
# ____________________________________________________________
|
||||
"""DateOption"""
|
||||
"""DateOption
|
||||
"""
|
||||
from datetime import datetime
|
||||
|
||||
from ..i18n import _
|
||||
|
|
|
|||
|
|
@ -18,7 +18,8 @@
|
|||
# the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/
|
||||
# the whole pypy projet is under MIT licence
|
||||
# ____________________________________________________________
|
||||
"""DomainnameOption"""
|
||||
"""DomainnameOption
|
||||
"""
|
||||
import re
|
||||
import socket
|
||||
from ipaddress import ip_interface
|
||||
|
|
|
|||
|
|
@ -18,7 +18,8 @@
|
|||
# the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/
|
||||
# the whole pypy projet is under MIT licence
|
||||
# ____________________________________________________________
|
||||
"""DynOptionDescription"""
|
||||
"""DynOptionDescription
|
||||
"""
|
||||
import re
|
||||
import weakref
|
||||
from typing import List, Any, Optional, Dict
|
||||
|
|
|
|||
|
|
@ -18,7 +18,8 @@
|
|||
# the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/
|
||||
# the whole pypy projet is under MIT licence
|
||||
# ____________________________________________________________
|
||||
"""EmailOption"""
|
||||
"""EmailOption
|
||||
"""
|
||||
import re
|
||||
|
||||
from ..i18n import _
|
||||
|
|
|
|||
|
|
@ -18,7 +18,8 @@
|
|||
# the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/
|
||||
# the whole pypy projet is under MIT licence
|
||||
# ____________________________________________________________
|
||||
"""FilenameOption"""
|
||||
"""FilenameOption
|
||||
"""
|
||||
from pathlib import Path
|
||||
|
||||
from ..i18n import _
|
||||
|
|
|
|||
|
|
@ -18,7 +18,8 @@
|
|||
# the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/
|
||||
# the whole pypy projet is under MIT licence
|
||||
# ____________________________________________________________
|
||||
"""FloatOption"""
|
||||
"""FloatOption
|
||||
"""
|
||||
|
||||
from ..i18n import _
|
||||
from .option import Option
|
||||
|
|
|
|||
|
|
@ -18,7 +18,8 @@
|
|||
# the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/
|
||||
# the whole pypy projet is under MIT licence
|
||||
# ____________________________________________________________
|
||||
"""IntOption"""
|
||||
"""IntOption
|
||||
"""
|
||||
|
||||
from ..i18n import _
|
||||
from .option import Option
|
||||
|
|
@ -26,7 +27,6 @@ from .option import Option
|
|||
|
||||
class IntOption(Option):
|
||||
"represents a choice of an integer"
|
||||
|
||||
__slots__ = tuple()
|
||||
_type = "integer"
|
||||
_t_type = _("integer")
|
||||
|
|
|
|||
|
|
@ -18,7 +18,8 @@
|
|||
# the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/
|
||||
# the whole pypy projet is under MIT licence
|
||||
# ____________________________________________________________
|
||||
"""IPOption"""
|
||||
"""IPOption
|
||||
"""
|
||||
from ipaddress import ip_address, ip_interface
|
||||
|
||||
from ..i18n import _
|
||||
|
|
|
|||
|
|
@ -74,9 +74,7 @@ class Leadership(OptionDescription):
|
|||
self._check_default_value(child)
|
||||
# remove empty property for follower
|
||||
if not child.impl_is_submulti():
|
||||
child._properties = frozenset(
|
||||
child._properties - {"empty", "unique"}
|
||||
)
|
||||
child._properties = frozenset(child._properties - {"empty", "unique"})
|
||||
followers.append(child)
|
||||
child._add_dependency(self, "leadership")
|
||||
child._leadership = weakref.ref(self)
|
||||
|
|
|
|||
|
|
@ -18,7 +18,8 @@
|
|||
# the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/
|
||||
# the whole pypy projet is under MIT licence
|
||||
# ____________________________________________________________
|
||||
"""MACOption"""
|
||||
"""MACOption
|
||||
"""
|
||||
import re
|
||||
|
||||
from ..i18n import _
|
||||
|
|
|
|||
|
|
@ -18,7 +18,8 @@
|
|||
# the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/
|
||||
# the whole pypy projet is under MIT licence
|
||||
# ____________________________________________________________
|
||||
"""NetmaskOption"""
|
||||
"""NetmaskOption
|
||||
"""
|
||||
from ipaddress import ip_network
|
||||
from ..i18n import _
|
||||
from .stroption import StrOption
|
||||
|
|
|
|||
|
|
@ -18,7 +18,8 @@
|
|||
# the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/
|
||||
# the whole pypy projet is under MIT licence
|
||||
# ____________________________________________________________
|
||||
"""NetworkOption"""
|
||||
"""NetworkOption
|
||||
"""
|
||||
from ipaddress import ip_network
|
||||
|
||||
from ..i18n import _
|
||||
|
|
@ -28,7 +29,6 @@ from .stroption import StrOption
|
|||
|
||||
class NetworkOption(IPOption):
|
||||
"represents the choice of a network"
|
||||
|
||||
__slots__ = tuple()
|
||||
_type = "network address"
|
||||
_t_type = _("network address")
|
||||
|
|
|
|||
|
|
@ -18,7 +18,8 @@
|
|||
# the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/
|
||||
# the whole pypy projet is under MIT licence
|
||||
# ____________________________________________________________
|
||||
"""OptionDescription"""
|
||||
"""OptionDescription
|
||||
"""
|
||||
import weakref
|
||||
from typing import Optional, Iterator, Union, List, Dict
|
||||
|
||||
|
|
@ -28,12 +29,7 @@ from ..setting import ConfigBag, groups, undefined, owners, Undefined
|
|||
from .baseoption import BaseOption
|
||||
|
||||
# from .syndynoption import SubDynOptionDescription, SynDynOptionDescription
|
||||
from ..error import (
|
||||
ConfigError,
|
||||
ConflictError,
|
||||
AttributeOptionError,
|
||||
PropertiesOptionError,
|
||||
)
|
||||
from ..error import ConfigError, ConflictError, AttributeOptionError, PropertiesOptionError
|
||||
|
||||
|
||||
class CacheOptionDescription(BaseOption):
|
||||
|
|
|
|||
|
|
@ -18,7 +18,8 @@
|
|||
# the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/
|
||||
# the whole pypy projet is under MIT licence
|
||||
# ____________________________________________________________
|
||||
"""PasswordOption"""
|
||||
"""PasswordOption
|
||||
"""
|
||||
|
||||
from ..i18n import _
|
||||
from ..error import display_list
|
||||
|
|
|
|||
|
|
@ -18,7 +18,8 @@
|
|||
# the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/
|
||||
# the whole pypy projet is under MIT licence
|
||||
# ____________________________________________________________
|
||||
"""PermissionsOption"""
|
||||
"""PermissionsOption
|
||||
"""
|
||||
import re
|
||||
|
||||
from ..i18n import _
|
||||
|
|
|
|||
|
|
@ -18,7 +18,8 @@
|
|||
# the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/
|
||||
# the whole pypy projet is under MIT licence
|
||||
# ____________________________________________________________
|
||||
"""PortOption"""
|
||||
"""PortOption
|
||||
"""
|
||||
from ..i18n import _
|
||||
from .stroption import StrOption
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,8 @@
|
|||
# the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/
|
||||
# the whole pypy projet is under MIT licence
|
||||
# ____________________________________________________________
|
||||
"""StrOption and RegexpOption"""
|
||||
"""StrOption and RegexpOption
|
||||
"""
|
||||
from typing import Any
|
||||
|
||||
from ..i18n import _
|
||||
|
|
|
|||
|
|
@ -18,7 +18,8 @@
|
|||
# the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/
|
||||
# the whole pypy projet is under MIT licence
|
||||
# ____________________________________________________________
|
||||
"""SymLinkOption link to an other option"""
|
||||
"""SymLinkOption link to an other option
|
||||
"""
|
||||
from typing import Any, Optional, Dict
|
||||
from .baseoption import BaseOption, valid_name
|
||||
from ..i18n import _
|
||||
|
|
|
|||
|
|
@ -18,7 +18,8 @@
|
|||
# the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/
|
||||
# the whole pypy projet is under MIT licence
|
||||
# ____________________________________________________________
|
||||
"""URLOption to check url value"""
|
||||
"""URLOption to check url value
|
||||
"""
|
||||
import re
|
||||
from typing import Any, Optional, List, Dict
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,8 @@
|
|||
# the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/
|
||||
# the whole pypy projet is under MIT licence
|
||||
# ____________________________________________________________
|
||||
"""UsernameOption or GroupnameOption to check unix username/group value"""
|
||||
"""UsernameOption or GroupnameOption to check unix username/group value
|
||||
"""
|
||||
import re
|
||||
|
||||
from ..i18n import _
|
||||
|
|
|
|||
|
|
@ -144,7 +144,8 @@ RW_REMOVE = frozenset(
|
|||
|
||||
|
||||
PROPERTIES_MAKE_SENSE = (
|
||||
"cache" "demoting_error_warning",
|
||||
"cache"
|
||||
"demoting_error_warning",
|
||||
"disabled",
|
||||
"empty",
|
||||
"everything_frozen",
|
||||
|
|
@ -377,7 +378,6 @@ forbidden_owners = (owners.default, owners.forced) # pylint: disable=no-member
|
|||
# ____________________________________________________________
|
||||
class Settings:
|
||||
"``config.Config()``'s configuration options settings"
|
||||
|
||||
__slots__ = (
|
||||
"_properties",
|
||||
"_permissives",
|
||||
|
|
|
|||
|
|
@ -163,7 +163,9 @@ class Values:
|
|||
msubconfig = self._get_modified_parent(subconfig)
|
||||
if msubconfig is not None:
|
||||
# retrieved value from parent config
|
||||
return msubconfig.config_bag.context.get_values().getowner(msubconfig)
|
||||
return msubconfig.config_bag.context.get_values().getowner(
|
||||
msubconfig
|
||||
)
|
||||
return owners.default
|
||||
|
||||
def get_default_value(
|
||||
|
|
@ -567,7 +569,10 @@ class Values:
|
|||
:returns: a `setting.owners.Owner` object
|
||||
"""
|
||||
self_properties = subconfig.properties
|
||||
if "frozen" in self_properties and "force_default_on_freeze" in self_properties:
|
||||
if (
|
||||
"frozen" in self_properties
|
||||
and "force_default_on_freeze" in self_properties
|
||||
):
|
||||
return owners.default
|
||||
setting_properties = subconfig.config_bag.properties
|
||||
if (
|
||||
|
|
|
|||
Loading…
Reference in a new issue