fix: black

This commit is contained in:
egarette@silique.fr 2026-06-21 17:09:16 +02:00
parent 0c9c1e2224
commit 7c88f7a139
33 changed files with 244 additions and 169 deletions

View file

@ -12,8 +12,7 @@
# #
# You should have received a copy of the GNU Lesser General Public License # 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/>. # 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 ( from .function import (
calc_value, calc_value,
calc_value_property_help, calc_value_property_help,

View file

@ -141,19 +141,22 @@ class CommonTiramisu(TiramisuHelp):
raise ConfigError(str(err)) raise ConfigError(str(err))
if id(self._subconfig.config_bag) != id(self._config_bag): if id(self._subconfig.config_bag) != id(self._config_bag):
subconfig = self._subconfig subconfig = self._subconfig
self._subconfig = subconfig.__class__(option=subconfig.option, self._subconfig = subconfig.__class__(
index=subconfig.index, option=subconfig.option,
path=subconfig.path, index=subconfig.index,
config_bag=self._config_bag, path=subconfig.path,
parent=subconfig.parent, config_bag=self._config_bag,
identifiers=subconfig.identifiers, parent=subconfig.parent,
identifier=None, identifiers=subconfig.identifiers,
true_path=subconfig.true_path, identifier=None,
properties=subconfig.properties, true_path=subconfig.true_path,
validate_properties=False, properties=subconfig.properties,
check_dynamic_without_identifiers=False, 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: else:
self._subconfig._length = None self._subconfig._length = None
if not self._subconfig: if not self._subconfig:
@ -189,7 +192,11 @@ def option_type(types):
return func(self, options_bag, *args[1:], **kwargs) return func(self, options_bag, *args[1:], **kwargs)
self._set_subconfig() self._set_subconfig()
if ( 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: ) and self._subconfig.is_dynamic_without_identifiers:
raise AttributeOptionError(self._subconfig.path, "option-dynamic") raise AttributeOptionError(self._subconfig.path, "option-dynamic")
@ -237,7 +244,13 @@ def option_type(types):
self.__class__.__name__, func.__name__ self.__class__.__name__, func.__name__
) )
raise ConfigError(msg) 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 = _( msg = _(
"please specify index with a follower option ({0}.{1})" "please specify index with a follower option ({0}.{1})"
).format(self.__class__.__name__, func.__name__) ).format(self.__class__.__name__, func.__name__)
@ -280,7 +293,7 @@ class CommonTiramisuOption(CommonTiramisu):
path: str, path: str,
index: Optional[int], index: Optional[int],
config_bag: ConfigBag, config_bag: ConfigBag,
subconfig: Optional[SubConfig]=None, subconfig: Optional[SubConfig] = None,
) -> None: ) -> None:
self._path = path self._path = path
self._index = index self._index = index
@ -458,7 +471,11 @@ class _TiramisuOptionOptionDescription:
): ):
if subconfig.properties is None: if subconfig.properties is None:
subconfig.properties = undefined 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 continue
options.append( options.append(
TiramisuOption( TiramisuOption(
@ -471,7 +488,11 @@ class _TiramisuOptionOptionDescription:
for subconfig in context.get_dynamic_from_dyn_option( for subconfig in context.get_dynamic_from_dyn_option(
self._subconfig, 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 continue
options.append( options.append(
TiramisuOption( TiramisuOption(
@ -495,17 +516,21 @@ class _TiramisuOptionOptionDescription:
current_indexes = [None] current_indexes = [None]
for current_index in current_indexes: for current_index in current_indexes:
t_option = TiramisuOption( t_option = TiramisuOption(
option.impl_getpath(), option.impl_getpath(),
current_index, current_index,
self._config_bag, self._config_bag,
allow_dynoption=uncalculated, allow_dynoption=uncalculated,
) )
t_option._set_subconfig() t_option._set_subconfig()
subconfig = t_option._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 continue
options.append( options.append(
t_option, t_option,
) )
return options return options
@ -630,7 +655,10 @@ class _TiramisuOptionOptionDescription:
dynconfig = None dynconfig = None
_subconfig = subconfig _subconfig = subconfig
while not dynconfig: 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 dynconfig = _subconfig
else: else:
_subconfig = _subconfig.parent _subconfig = _subconfig.parent
@ -649,18 +677,30 @@ class _TiramisuOptionOptionDescription:
""" """
identifiers = [] identifiers = []
while True: 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: if not subconfig.is_self_dynamic_without_identifiers:
new_identifiers = [subconfig.identifiers[-1]] new_identifiers = [subconfig.identifiers[-1]]
else: 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 isinstance(new_identifiers, Calculation):
if identifiers: if identifiers:
identifiers = [[new_identifiers] + old_identifiers for old_identifiers in identifiers] identifiers = [
[new_identifiers] + old_identifiers
for old_identifiers in identifiers
]
else: else:
identifiers = [new_identifiers] identifiers = [new_identifiers]
elif 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: else:
identifiers = [[identifier] for identifier in new_identifiers] identifiers = [[identifier] for identifier in new_identifiers]
subconfig = subconfig.parent subconfig = subconfig.parent
@ -682,7 +722,10 @@ class _TiramisuOptionOptionDescription:
dynconfig = None dynconfig = None
_subconfig = subconfig _subconfig = subconfig
while not dynconfig: 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 dynconfig = _subconfig
_subconfig = _subconfig.parent _subconfig = _subconfig.parent
return dynconfig.option.get_identifiers( return dynconfig.option.get_identifiers(
@ -809,10 +852,7 @@ class TiramisuOptionOwner(CommonTiramisuOption):
"""Is option has defaut value""" """Is option has defaut value"""
subconfig = self._subconfig subconfig = self._subconfig
s_properties = subconfig.properties s_properties = subconfig.properties
if ( if "frozen" in s_properties and "force_default_on_freeze" in s_properties:
"frozen" in s_properties
and "force_default_on_freeze" in s_properties
):
return True return True
context = self._config_bag.context context = self._config_bag.context
subconfig = context._get( subconfig = context._get(
@ -844,7 +884,13 @@ class TiramisuOptionProperty(CommonTiramisuOption):
_validate_properties = False _validate_properties = False
@option_type( @option_type(
["option", "optiondescription", "with_index_or_uncalculated", "symlink", "allow_dynoption"] [
"option",
"optiondescription",
"with_index_or_uncalculated",
"symlink",
"allow_dynoption",
]
) )
def get( def get(
self, self,
@ -1065,7 +1111,15 @@ class TiramisuOptionValue(CommonTiramisuOption, _TiramisuODGet):
_validate_properties = True _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( def get(
self, self,
*, *,
@ -1129,7 +1183,13 @@ class TiramisuOptionValue(CommonTiramisuOption, _TiramisuODGet):
values.reset(self._subconfig) values.reset(self._subconfig)
@option_type( @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( def default(
self, self,
@ -1338,7 +1398,7 @@ class TiramisuOption(
if subfunc in ["forcepermissive", "unrestraint", "nowarnings"]: if subfunc in ["forcepermissive", "unrestraint", "nowarnings"]:
if subfunc == "unrestraint" and self._config_bag.is_unrestraint: if subfunc == "unrestraint" and self._config_bag.is_unrestraint:
return self return self
#if self._orig_config_bags: # if self._orig_config_bags:
# msg = _( # msg = _(
# "do not use unrestraint, nowarnings or forcepermissive together" # "do not use unrestraint, nowarnings or forcepermissive together"
# ) # )
@ -1428,6 +1488,8 @@ class TiramisuOption(
if self._tiramisu_dict is None: # pragma: no cover if self._tiramisu_dict is None: # pragma: no cover
self._load_dict() self._load_dict()
return self._tiramisu_dict.set_updates(body) return self._tiramisu_dict.set_updates(body)
# #
# def forcepermissive(self): # def forcepermissive(self):
# self._set_subconfig() # self._set_subconfig()
@ -1502,20 +1564,25 @@ class TiramisuContextValue(TiramisuConfig, _TiramisuODGet):
only_mandatory=True, only_mandatory=True,
): ):
if id(subconfig.config_bag) != id(config_bag): if id(subconfig.config_bag) != id(config_bag):
old_is_dynamic_without_identifiers = subconfig.is_self_dynamic_without_identifiers old_is_dynamic_without_identifiers = (
subconfig = subconfig.__class__(option=subconfig.option, subconfig.is_self_dynamic_without_identifiers
index=subconfig.index, )
path=subconfig.path, subconfig = subconfig.__class__(
config_bag=config_bag, option=subconfig.option,
parent=subconfig.parent, index=subconfig.index,
identifiers=subconfig.identifiers, path=subconfig.path,
identifier=None, config_bag=config_bag,
true_path=subconfig.true_path, parent=subconfig.parent,
properties=subconfig.properties, identifiers=subconfig.identifiers,
validate_properties=False, identifier=None,
check_dynamic_without_identifiers=False, true_path=subconfig.true_path,
) properties=subconfig.properties,
subconfig.is_self_dynamic_without_identifiers = old_is_dynamic_without_identifiers validate_properties=False,
check_dynamic_without_identifiers=False,
)
subconfig.is_self_dynamic_without_identifiers = (
old_is_dynamic_without_identifiers
)
else: else:
subconfig._length = None subconfig._length = None
options.append( options.append(
@ -2229,6 +2296,7 @@ class TiramisuAPI(TiramisuHelp):
class ConfigProp(TiramisuAPI, TiramisuContextOption): class ConfigProp(TiramisuAPI, TiramisuContextOption):
pass pass
class Config(TiramisuAPI, TiramisuContextOption): class Config(TiramisuAPI, TiramisuContextOption):
"""Root config object that enables us to handle the configuration options""" """Root config object that enables us to handle the configuration options"""
@ -2255,6 +2323,8 @@ class Config(TiramisuAPI, TiramisuContextOption):
permissives=permissives, permissives=permissives,
) )
super().__init__(config_bag) super().__init__(config_bag)
# #
# def __del__(self): # def __del__(self):
# try: # try:

View file

@ -157,9 +157,9 @@ class ParamDynOption(ParamOption):
) )
if not isinstance(identifiers, (list, Calculation)): if not isinstance(identifiers, (list, Calculation)):
raise Exception( 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): if not isinstance(optional, bool):
raise Exception( raise Exception(
@ -628,21 +628,26 @@ def manager_callback(
properties = config_bag.context.get_settings().getproperties( properties = config_bag.context.get_settings().getproperties(
subconfig, subconfig,
uncalculated=True, uncalculated=True,
) - {'validator', 'mandatory', 'empty'} ) - {"validator", "mandatory", "empty"}
for subconfig_ in subconfigs: for subconfig_ in subconfigs:
if subconfig.path == subconfig_.path: if subconfig.path == subconfig_.path:
values.append(orig_value) values.append(orig_value)
else: else:
subconfig_.properties = properties subconfig_.properties = properties
values.append(get_value( values.append(
config_bag, get_value(
subconfig_, config_bag,
param, subconfig_,
True, param,
)) True,
)
)
if callback.__name__ not in FUNCTION_WAITING_FOR_DICT: if callback.__name__ not in FUNCTION_WAITING_FOR_DICT:
return values 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: else:
value = calc_self( value = calc_self(
param, param,
@ -779,7 +784,9 @@ def manager_callback(
or param.raisepropertyerror or param.raisepropertyerror
): ):
raise err from err raise err from err
raise ConfigError(str(err), subconfig=subconfig) from err raise ConfigError(
str(err), subconfig=subconfig
) from err
parents = new_parents parents = new_parents
if subconfigs_is_a_list: if subconfigs_is_a_list:
subconfigs = parents subconfigs = parents
@ -882,18 +889,19 @@ def carry_out_calculation(
config_bag = config_bag.copy() config_bag = config_bag.copy()
config_bag.set_permissive() config_bag.set_permissive()
old_is_dynamic_without_identifiers = subconfig.is_dynamic_without_identifiers old_is_dynamic_without_identifiers = subconfig.is_dynamic_without_identifiers
subconfig = subconfig.__class__(option=subconfig.option, subconfig = subconfig.__class__(
index=subconfig.index, option=subconfig.option,
path=subconfig.path, index=subconfig.index,
config_bag=config_bag, path=subconfig.path,
parent=subconfig.parent, config_bag=config_bag,
identifiers=subconfig.identifiers, parent=subconfig.parent,
identifier=None, identifiers=subconfig.identifiers,
true_path=subconfig.true_path, identifier=None,
properties=subconfig.properties, true_path=subconfig.true_path,
validate_properties=False, properties=subconfig.properties,
check_dynamic_without_identifiers=False, validate_properties=False,
) check_dynamic_without_identifiers=False,
)
subconfig.is_dynamic_without_identifiers = old_is_dynamic_without_identifiers subconfig.is_dynamic_without_identifiers = old_is_dynamic_without_identifiers
if callback_params: if callback_params:
for key, param in chain( for key, param in chain(

View file

@ -18,8 +18,7 @@
# the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/ # the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/
# the whole pypy projet is under MIT licence # the whole pypy projet is under MIT licence
# ____________________________________________________________ # ____________________________________________________________
"""options handler global entry point """options handler global entry point"""
"""
import weakref import weakref
from copy import copy, deepcopy from copy import copy, deepcopy
from typing import Optional, List, Any, Union from typing import Optional, List, Any, Union
@ -49,7 +48,7 @@ def get_common_path(path1, path2):
if common_path in all_paths: if common_path in all_paths:
# od.st is not the common_path of od.st_in # od.st is not the common_path of od.st_in
all_paths.remove(common_path) all_paths.remove(common_path)
if all_paths[0].startswith(common_path + '.'): if all_paths[0].startswith(common_path + "."):
return common_path return common_path
if common_path.endswith("."): if common_path.endswith("."):
return common_path[:-1] return common_path[:-1]
@ -103,9 +102,11 @@ class CCache:
resetted_opts.append(subconfig.path) resetted_opts.append(subconfig.path)
config_bag = subconfig.config_bag config_bag = subconfig.config_bag
if not force: if not force:
# if is_default and config_bag.context.get_owner(subconfig) != owners.default: # if is_default and config_bag.context.get_owner(subconfig) != owners.default:
# return # 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() option = woption()
if option.issubdyn(): if option.issubdyn():
# it's an option in dynoptiondescription, remove cache for all generated option # it's an option in dynoptiondescription, remove cache for all generated option
@ -343,7 +344,13 @@ class SubConfig:
self.config_bag.context.get_settings().validate_properties(self) self.config_bag.context.get_settings().validate_properties(self)
self._properties = undefined self._properties = undefined
self.config_bag.context.get_settings().validate_properties(self) 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() settings = config_bag.context.get_settings()
self.transitive_properties = settings.calc_transitive_properties( self.transitive_properties = settings.calc_transitive_properties(
self, self,
@ -526,7 +533,10 @@ class SubConfig:
) )
if check_index and index is not None: if check_index and index is not None:
if option.impl_is_optiondescription() or not option.impl_is_follower(): 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() length = self.get_length_leadership()
if index >= length: if index >= length:
raise LeadershipError( raise LeadershipError(
@ -567,9 +577,11 @@ class SubConfig:
None, None,
validate_properties=False, validate_properties=False,
) )
subconfig.is_self_dynamic_without_identifiers = self.is_self_dynamic_without_identifiers subconfig.is_self_dynamic_without_identifiers = (
#FIXME self.is_self_dynamic_without_identifiers
#self._length = len(cconfig_bag.context.get_value(subconfig)) )
# FIXME
# self._length = len(cconfig_bag.context.get_value(subconfig))
length = len(cconfig_bag.context.get_value(subconfig)) length = len(cconfig_bag.context.get_value(subconfig))
return length return length
@ -681,7 +693,9 @@ class SubConfig:
true_path=self.true_path, true_path=self.true_path,
validate_properties=False, 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 return subconfig
@ -1073,6 +1087,7 @@ class _Config(CCache):
class _CommonConfig(_Config): class _CommonConfig(_Config):
"abstract base class for the Config, KernelGroupConfig and the KernelMetaConfig" "abstract base class for the Config, KernelGroupConfig and the KernelMetaConfig"
__slots__ = ( __slots__ = (
"_impl_values", "_impl_values",
"_impl_values_cache", "_impl_values_cache",
@ -1905,9 +1920,7 @@ class KernelMetaConfig(KernelMixConfig):
if descr is None: if descr is None:
descr = child.get_description() descr = child.get_description()
if child.impl_getname() is None: if child.impl_getname() is None:
raise ConfigError( raise ConfigError(_("children in MetaConfig must have name"))
_("children in MetaConfig must have name")
)
elif descr is not child.get_description(): elif descr is not child.get_description():
raise ValueError( raise ValueError(
_( _(

View file

@ -39,9 +39,9 @@ TiramisuErrorCode = Literal[
def display_list( def display_list(
lst, lst,
*, *,
separator: str="and", separator: str = "and",
add_quote: bool=False, add_quote: bool = False,
sort: bool=True, sort: bool = True,
) -> str(): ) -> str():
if not lst: if not lst:
return '""' return '""'
@ -212,7 +212,7 @@ class ConfigError(Exception):
exp, exp,
*, *,
prefix: Optional[str] = None, prefix: Optional[str] = None,
subconfig: Optional["Subconfig"]=None, subconfig: Optional["Subconfig"] = None,
): ):
super().__init__(exp) super().__init__(exp)
self.err_msg = exp self.err_msg = exp
@ -230,6 +230,7 @@ class ConfigError(Exception):
class ConflictError(Exception): class ConflictError(Exception):
"duplicate options are present in a single config" "duplicate options are present in a single config"
pass pass
@ -308,6 +309,7 @@ class LeadershipError(Exception):
class ConstError(TypeError): class ConstError(TypeError):
"no uniq value in _NameSpace" "no uniq value in _NameSpace"
pass pass
@ -426,7 +428,8 @@ class Errors:
display_name = option.impl_get_display_name(subconfig, with_quote=True) display_name = option.impl_get_display_name(subconfig, with_quote=True)
if original_error: if original_error:
raise ConfigError( 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 ) from original_error
raise ConfigError(message.format(display_name, extra_keys), subconfig=subconfig) raise ConfigError(message.format(display_name, extra_keys), subconfig=subconfig)

View file

@ -12,8 +12,7 @@
# #
# You should have received a copy of the GNU Lesser General Public License # 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/>. # 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 typing import Any, List, Optional
from operator import add, mul, sub, truediv from operator import add, mul, sub, truediv
from ipaddress import ip_address, ip_interface, ip_network from ipaddress import ip_address, ip_interface, ip_network

View file

@ -18,8 +18,7 @@
# the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/ # the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/
# the whole pypy projet is under MIT licence # the whole pypy projet is under MIT licence
# ____________________________________________________________ # ____________________________________________________________
"""all official option """all official option"""
"""
from .optiondescription import OptionDescription from .optiondescription import OptionDescription
from .dynoptiondescription import DynOptionDescription from .dynoptiondescription import DynOptionDescription
from .leadership import Leadership from .leadership import Leadership

View file

@ -18,8 +18,7 @@
# the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/ # the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/
# the whole pypy projet is under MIT licence # the whole pypy projet is under MIT licence
# ____________________________________________________________ # ____________________________________________________________
"""base option """base option"""
"""
from typing import FrozenSet, Set, Any, List, Optional, Dict from typing import FrozenSet, Set, Any, List, Optional, Dict
import weakref import weakref
from itertools import chain from itertools import chain
@ -27,7 +26,13 @@ from itertools import chain
from ..i18n import _ from ..i18n import _
from ..setting import undefined from ..setting import undefined
from ..autolib import Calculation, ParamOption, ParamSelfOption, ParamInformation, ParamSelfInformation from ..autolib import (
Calculation,
ParamOption,
ParamSelfOption,
ParamInformation,
ParamSelfInformation,
)
STATIC_TUPLE = frozenset() STATIC_TUPLE = frozenset()
@ -390,10 +395,7 @@ class BaseOption(Base):
self.value_dependency(value, is_identifier) self.value_dependency(value, is_identifier)
def value_dependency( def value_dependency(
self, self, value: Any, is_identifier: bool = False, type_: str = "default"
value: Any,
is_identifier: bool = False,
type_: str = 'default'
) -> Any: ) -> Any:
if not isinstance(is_identifier, bool): if not isinstance(is_identifier, bool):
raise Exception() raise Exception()

View file

@ -18,8 +18,7 @@
# the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/ # the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/
# the whole pypy projet is under MIT licence # the whole pypy projet is under MIT licence
# ____________________________________________________________ # ____________________________________________________________
"""BoolOption """BoolOption"""
"""
from ..i18n import _ from ..i18n import _
from .option import Option from .option import Option

View file

@ -18,8 +18,7 @@
# the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/ # the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/
# the whole pypy projet is under MIT licence # the whole pypy projet is under MIT licence
# ____________________________________________________________ # ____________________________________________________________
"""BroadcastOption """BroadcastOption"""
"""
from ipaddress import ip_address from ipaddress import ip_address
from ..i18n import _ from ..i18n import _

View file

@ -18,8 +18,7 @@
# the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/ # the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/
# the whole pypy projet is under MIT licence # the whole pypy projet is under MIT licence
# ____________________________________________________________ # ____________________________________________________________
"""ChoiceOption """ChoiceOption"""
"""
from typing import Any from typing import Any
from itertools import chain from itertools import chain

View file

@ -18,8 +18,7 @@
# the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/ # the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/
# the whole pypy projet is under MIT licence # the whole pypy projet is under MIT licence
# ____________________________________________________________ # ____________________________________________________________
"""DateOption """DateOption"""
"""
from datetime import datetime from datetime import datetime
from ..i18n import _ from ..i18n import _

View file

@ -18,8 +18,7 @@
# the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/ # the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/
# the whole pypy projet is under MIT licence # the whole pypy projet is under MIT licence
# ____________________________________________________________ # ____________________________________________________________
"""DomainnameOption """DomainnameOption"""
"""
import re import re
import socket import socket
from ipaddress import ip_interface from ipaddress import ip_interface

View file

@ -18,8 +18,7 @@
# the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/ # the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/
# the whole pypy projet is under MIT licence # the whole pypy projet is under MIT licence
# ____________________________________________________________ # ____________________________________________________________
"""DynOptionDescription """DynOptionDescription"""
"""
import re import re
import weakref import weakref
from typing import List, Any, Optional, Dict from typing import List, Any, Optional, Dict

View file

@ -18,8 +18,7 @@
# the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/ # the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/
# the whole pypy projet is under MIT licence # the whole pypy projet is under MIT licence
# ____________________________________________________________ # ____________________________________________________________
"""EmailOption """EmailOption"""
"""
import re import re
from ..i18n import _ from ..i18n import _

View file

@ -18,8 +18,7 @@
# the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/ # the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/
# the whole pypy projet is under MIT licence # the whole pypy projet is under MIT licence
# ____________________________________________________________ # ____________________________________________________________
"""FilenameOption """FilenameOption"""
"""
from pathlib import Path from pathlib import Path
from ..i18n import _ from ..i18n import _

View file

@ -18,8 +18,7 @@
# the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/ # the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/
# the whole pypy projet is under MIT licence # the whole pypy projet is under MIT licence
# ____________________________________________________________ # ____________________________________________________________
"""FloatOption """FloatOption"""
"""
from ..i18n import _ from ..i18n import _
from .option import Option from .option import Option

View file

@ -18,8 +18,7 @@
# the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/ # the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/
# the whole pypy projet is under MIT licence # the whole pypy projet is under MIT licence
# ____________________________________________________________ # ____________________________________________________________
"""IntOption """IntOption"""
"""
from ..i18n import _ from ..i18n import _
from .option import Option from .option import Option
@ -27,6 +26,7 @@ from .option import Option
class IntOption(Option): class IntOption(Option):
"represents a choice of an integer" "represents a choice of an integer"
__slots__ = tuple() __slots__ = tuple()
_type = "integer" _type = "integer"
_t_type = _("integer") _t_type = _("integer")

View file

@ -18,8 +18,7 @@
# the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/ # the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/
# the whole pypy projet is under MIT licence # the whole pypy projet is under MIT licence
# ____________________________________________________________ # ____________________________________________________________
"""IPOption """IPOption"""
"""
from ipaddress import ip_address, ip_interface from ipaddress import ip_address, ip_interface
from ..i18n import _ from ..i18n import _

View file

@ -74,7 +74,9 @@ class Leadership(OptionDescription):
self._check_default_value(child) self._check_default_value(child)
# remove empty property for follower # remove empty property for follower
if not child.impl_is_submulti(): if not child.impl_is_submulti():
child._properties = frozenset(child._properties - {"empty", "unique"}) child._properties = frozenset(
child._properties - {"empty", "unique"}
)
followers.append(child) followers.append(child)
child._add_dependency(self, "leadership") child._add_dependency(self, "leadership")
child._leadership = weakref.ref(self) child._leadership = weakref.ref(self)

View file

@ -18,8 +18,7 @@
# the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/ # the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/
# the whole pypy projet is under MIT licence # the whole pypy projet is under MIT licence
# ____________________________________________________________ # ____________________________________________________________
"""MACOption """MACOption"""
"""
import re import re
from ..i18n import _ from ..i18n import _

View file

@ -18,8 +18,7 @@
# the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/ # the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/
# the whole pypy projet is under MIT licence # the whole pypy projet is under MIT licence
# ____________________________________________________________ # ____________________________________________________________
"""NetmaskOption """NetmaskOption"""
"""
from ipaddress import ip_network from ipaddress import ip_network
from ..i18n import _ from ..i18n import _
from .stroption import StrOption from .stroption import StrOption

View file

@ -18,8 +18,7 @@
# the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/ # the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/
# the whole pypy projet is under MIT licence # the whole pypy projet is under MIT licence
# ____________________________________________________________ # ____________________________________________________________
"""NetworkOption """NetworkOption"""
"""
from ipaddress import ip_network from ipaddress import ip_network
from ..i18n import _ from ..i18n import _
@ -29,6 +28,7 @@ from .stroption import StrOption
class NetworkOption(IPOption): class NetworkOption(IPOption):
"represents the choice of a network" "represents the choice of a network"
__slots__ = tuple() __slots__ = tuple()
_type = "network address" _type = "network address"
_t_type = _("network address") _t_type = _("network address")

View file

@ -18,8 +18,7 @@
# the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/ # the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/
# the whole pypy projet is under MIT licence # the whole pypy projet is under MIT licence
# ____________________________________________________________ # ____________________________________________________________
"""OptionDescription """OptionDescription"""
"""
import weakref import weakref
from typing import Optional, Iterator, Union, List, Dict from typing import Optional, Iterator, Union, List, Dict
@ -29,7 +28,12 @@ from ..setting import ConfigBag, groups, undefined, owners, Undefined
from .baseoption import BaseOption from .baseoption import BaseOption
# from .syndynoption import SubDynOptionDescription, SynDynOptionDescription # from .syndynoption import SubDynOptionDescription, SynDynOptionDescription
from ..error import ConfigError, ConflictError, AttributeOptionError, PropertiesOptionError from ..error import (
ConfigError,
ConflictError,
AttributeOptionError,
PropertiesOptionError,
)
class CacheOptionDescription(BaseOption): class CacheOptionDescription(BaseOption):

View file

@ -18,8 +18,7 @@
# the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/ # the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/
# the whole pypy projet is under MIT licence # the whole pypy projet is under MIT licence
# ____________________________________________________________ # ____________________________________________________________
"""PasswordOption """PasswordOption"""
"""
from ..i18n import _ from ..i18n import _
from ..error import display_list from ..error import display_list

View file

@ -18,8 +18,7 @@
# the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/ # the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/
# the whole pypy projet is under MIT licence # the whole pypy projet is under MIT licence
# ____________________________________________________________ # ____________________________________________________________
"""PermissionsOption """PermissionsOption"""
"""
import re import re
from ..i18n import _ from ..i18n import _

View file

@ -18,8 +18,7 @@
# the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/ # the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/
# the whole pypy projet is under MIT licence # the whole pypy projet is under MIT licence
# ____________________________________________________________ # ____________________________________________________________
"""PortOption """PortOption"""
"""
from ..i18n import _ from ..i18n import _
from .stroption import StrOption from .stroption import StrOption

View file

@ -18,8 +18,7 @@
# the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/ # the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/
# the whole pypy projet is under MIT licence # the whole pypy projet is under MIT licence
# ____________________________________________________________ # ____________________________________________________________
"""StrOption and RegexpOption """StrOption and RegexpOption"""
"""
from typing import Any from typing import Any
from ..i18n import _ from ..i18n import _

View file

@ -18,8 +18,7 @@
# the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/ # the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/
# the whole pypy projet is under MIT licence # 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 typing import Any, Optional, Dict
from .baseoption import BaseOption, valid_name from .baseoption import BaseOption, valid_name
from ..i18n import _ from ..i18n import _

View file

@ -18,8 +18,7 @@
# the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/ # the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/
# the whole pypy projet is under MIT licence # the whole pypy projet is under MIT licence
# ____________________________________________________________ # ____________________________________________________________
"""URLOption to check url value """URLOption to check url value"""
"""
import re import re
from typing import Any, Optional, List, Dict from typing import Any, Optional, List, Dict

View file

@ -18,8 +18,7 @@
# the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/ # the rough pypy's guys: http://codespeak.net/svn/pypy/dist/pypy/config/
# the whole pypy projet is under MIT licence # 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 import re
from ..i18n import _ from ..i18n import _

View file

@ -144,8 +144,7 @@ RW_REMOVE = frozenset(
PROPERTIES_MAKE_SENSE = ( PROPERTIES_MAKE_SENSE = (
"cache" "cache" "demoting_error_warning",
"demoting_error_warning",
"disabled", "disabled",
"empty", "empty",
"everything_frozen", "everything_frozen",
@ -378,6 +377,7 @@ forbidden_owners = (owners.default, owners.forced) # pylint: disable=no-member
# ____________________________________________________________ # ____________________________________________________________
class Settings: class Settings:
"``config.Config()``'s configuration options settings" "``config.Config()``'s configuration options settings"
__slots__ = ( __slots__ = (
"_properties", "_properties",
"_permissives", "_permissives",

View file

@ -122,8 +122,8 @@ class Values:
# get it # get it
value = self.get_default_value(subconfig) value = self.get_default_value(subconfig)
if owner == owners.default: if owner == owners.default:
if( if (
"force_store_value" in subconfig.config_bag.properties "force_store_value" in subconfig.config_bag.properties
and "force_store_value" in self_properties and "force_store_value" in self_properties
): ):
value = self.get_default_value(subconfig) value = self.get_default_value(subconfig)
@ -163,9 +163,7 @@ class Values:
msubconfig = self._get_modified_parent(subconfig) msubconfig = self._get_modified_parent(subconfig)
if msubconfig is not None: if msubconfig is not None:
# retrieved value from parent config # retrieved value from parent config
return msubconfig.config_bag.context.get_values().getowner( return msubconfig.config_bag.context.get_values().getowner(msubconfig)
msubconfig
)
return owners.default return owners.default
def get_default_value( def get_default_value(
@ -342,7 +340,7 @@ class Values:
subconfig, subconfig,
value, value,
) )
# parent._length = len(value) # parent._length = len(value)
leader.follower_force_store_value( leader.follower_force_store_value(
value, value,
parent, parent,
@ -569,14 +567,11 @@ class Values:
:returns: a `setting.owners.Owner` object :returns: a `setting.owners.Owner` object
""" """
self_properties = subconfig.properties self_properties = subconfig.properties
if ( if "frozen" in self_properties and "force_default_on_freeze" in self_properties:
"frozen" in self_properties
and "force_default_on_freeze" in self_properties
):
return owners.default return owners.default
setting_properties = subconfig.config_bag.properties setting_properties = subconfig.config_bag.properties
if ( if (
"force_store_value" in setting_properties "force_store_value" in setting_properties
and "force_store_value" in self_properties and "force_store_value" in self_properties
): ):
self.set_force_store_value(subconfig) self.set_force_store_value(subconfig)