Compare commits
4 commits
897d4dd216
...
f4f5fb79e4
| Author | SHA1 | Date | |
|---|---|---|---|
| f4f5fb79e4 | |||
| c2e3bf86f1 | |||
| f2893aaacd | |||
| 4e1053bba9 |
42 changed files with 190 additions and 101 deletions
|
|
@ -864,7 +864,7 @@ def _test_value_normal(name, cfg, option, unrestraint, without_index):
|
|||
assert option.value.valid() is True
|
||||
# list
|
||||
if 'choice' in name:
|
||||
assert option.value.list() == ('val1', 'val2')
|
||||
assert option.value.list() == ['val1', 'val2']
|
||||
else:
|
||||
with pytest.raises(ConfigError):
|
||||
option.value.list()
|
||||
|
|
|
|||
|
|
@ -72,6 +72,7 @@ def test_choiceoption_function(config_type):
|
|||
assert cfg.option('choice').owner.isdefault()
|
||||
#
|
||||
assert value_list(cfg.option('choice').value.list()) == ('val1', 'val2')
|
||||
assert isinstance(cfg.option('choice').value.list(uncalculated=True), Calculation)
|
||||
# assert not list_sessions()
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -9,10 +9,14 @@ do_autopath()
|
|||
from .config import config_type, get_config, value_list, global_owner
|
||||
|
||||
import pytest
|
||||
from tiramisu import Config
|
||||
from tiramisu import Config, Calculation, Params, ParamSelfInformation, calc_value
|
||||
from tiramisu.i18n import _
|
||||
from tiramisu import Config, IntOption, FloatOption, ChoiceOption, \
|
||||
BoolOption, StrOption, SymLinkOption, OptionDescription, undefined
|
||||
BoolOption, StrOption, SymLinkOption, OptionDescription, undefined, \
|
||||
DomainnameOption, EmailOption, URLOption, RegexpOption, IPOption, \
|
||||
PortOption, NetworkOption, NetmaskOption, BroadcastOption, UsernameOption, \
|
||||
GroupnameOption, DateOption, FilenameOption, PasswordOption, MACOption, \
|
||||
PermissionsOption
|
||||
from tiramisu.error import ConflictError, ConfigError, PropertiesOptionError
|
||||
|
||||
|
||||
|
|
@ -129,6 +133,29 @@ def test_not_valid_properties():
|
|||
# assert not list_sessions()
|
||||
|
||||
|
||||
def test_information_load():
|
||||
ChoiceOption('a', '', ('a', 'b'), informations={'info': 'value'})
|
||||
BoolOption('a', '', informations={'info': 'value'})
|
||||
IntOption('a', '', informations={'info': 'value'})
|
||||
FloatOption('a', '', informations={'info': 'value'})
|
||||
StrOption('a', '', informations={'info': 'value'})
|
||||
RegexpOption('a', '', informations={'info': 'value'})
|
||||
IPOption('a', '', informations={'info': 'value'})
|
||||
PortOption('a', '', informations={'info': 'value'})
|
||||
NetworkOption('a', '', informations={'info': 'value'})
|
||||
NetmaskOption('a', '', informations={'info': 'value'})
|
||||
BroadcastOption('a', '', informations={'info': 'value'})
|
||||
DomainnameOption('a', '', informations={'info': 'value'})
|
||||
EmailOption('a', '', informations={'info': 'value'})
|
||||
URLOption('a', '', informations={'info': 'value'})
|
||||
UsernameOption('a', '', informations={'info': 'value'})
|
||||
GroupnameOption('a', '', informations={'info': 'value'})
|
||||
DateOption('a', '', informations={'info': 'value'})
|
||||
FilenameOption('a', '', informations={'info': 'value'})
|
||||
PasswordOption('a', '', informations={'info': 'value'})
|
||||
MACOption('a', '', informations={'info': 'value'})
|
||||
PermissionsOption('a', '', informations={'info': 'value'})
|
||||
|
||||
def test_information_config():
|
||||
od1 = make_description()
|
||||
cfg = Config(od1)
|
||||
|
|
@ -217,6 +244,17 @@ def test_information_option_2():
|
|||
# assert not list_sessions()
|
||||
|
||||
|
||||
def test_information_option_symlink():
|
||||
i1 = IntOption('test1', '', Calculation(calc_value, Params(ParamSelfInformation('info'))), informations={'info': 'value'})
|
||||
i2 = SymLinkOption('test2', i1)
|
||||
od1 = OptionDescription('test', '', [i2, i1])
|
||||
cfg = Config(od1)
|
||||
# it's tuples
|
||||
assert set(cfg.option('test1').information.list()) == {'info', 'doc'}
|
||||
assert set(cfg.option('test2').information.list()) == {'info', 'doc'}
|
||||
# assert not list_sessions()
|
||||
|
||||
|
||||
def test_information_optiondescription():
|
||||
od1 = make_description()
|
||||
cfg = Config(od1)
|
||||
|
|
|
|||
|
|
@ -77,6 +77,22 @@ def test_build_dyndescription():
|
|||
assert parse_od_get(cfg.value.get()) == {'dodval1.st': None, 'dodval2.st': None}
|
||||
assert cfg.option('dodval1').isdynamic()
|
||||
assert cfg.option('dodval1.st').isdynamic()
|
||||
assert cfg.option('dodval1').isdynamic(only_self=True)
|
||||
assert not cfg.option('dodval1.st').isdynamic(only_self=True)
|
||||
# assert not list_sessions()
|
||||
|
||||
|
||||
def test_dyndescription_suffixes():
|
||||
st1 = StrOption('st', '')
|
||||
dod = DynOptionDescription('dod', '', [st1], suffixes=Calculation(return_list))
|
||||
od1 = OptionDescription('od', '', [dod])
|
||||
cfg = Config(od1)
|
||||
assert parse_od_get(cfg.value.get()) == {'dodval1.st': None, 'dodval2.st': None}
|
||||
assert cfg.option('dodval1').suffixes() == ['val1']
|
||||
assert cfg.option('dodval1.st').suffixes() == ['val1']
|
||||
assert cfg.option('dodval1').suffixes(only_self=True) == ['val1', 'val2']
|
||||
with pytest.raises(ConfigError):
|
||||
cfg.option('dodval1.st').suffixes(only_self=True)
|
||||
# assert not list_sessions()
|
||||
|
||||
|
||||
|
|
@ -164,8 +180,10 @@ def test_getdoc_dyndescription():
|
|||
cfg = Config(od2)
|
||||
assert cfg.option('od.dodval1.st').name() == 'st'
|
||||
assert cfg.option('od.dodval2.st').name() == 'st'
|
||||
assert cfg.option('od.dodval1.st').name(uncalculated=True) == cfg.option('od.dodval2.st').name(uncalculated=True) == 'st'
|
||||
assert cfg.option('od.dodval1').name() == 'dodval1'
|
||||
assert cfg.option('od.dodval2').name() == 'dodval2'
|
||||
assert cfg.option('od.dodval1').name(uncalculated=True) == cfg.option('od.dodval2').name(uncalculated=True) == 'dod'
|
||||
assert cfg.option('od.dodval1.st').doc() == 'doc1'
|
||||
assert cfg.option('od.dodval2.st').doc() == 'doc1'
|
||||
assert cfg.option('od.dodval1').doc() == 'doc2'
|
||||
|
|
@ -173,6 +191,20 @@ def test_getdoc_dyndescription():
|
|||
# assert not list_sessions()
|
||||
|
||||
|
||||
def test_dyndescription_path():
|
||||
st1 = StrOption('st', 'doc1')
|
||||
dod = DynOptionDescription('dod', 'doc2', [st1], suffixes=Calculation(return_list))
|
||||
od1 = OptionDescription('od', '', [dod])
|
||||
od2 = OptionDescription('od', '', [od1])
|
||||
cfg = Config(od2)
|
||||
assert cfg.option('od.dodval1.st').path() == 'od.dodval1.st'
|
||||
assert cfg.option('od.dodval2.st').path() == 'od.dodval2.st'
|
||||
assert cfg.option('od.dodval1.st').path(uncalculated=True) == cfg.option('od.dodval2.st').path(uncalculated=True) == 'od.dod.st'
|
||||
assert cfg.option('od.dodval1').path() == 'od.dodval1'
|
||||
assert cfg.option('od.dodval2').path() == 'od.dodval2'
|
||||
assert cfg.option('od.dodval1').path(uncalculated=True) == cfg.option('od.dodval2').path(uncalculated=True) == 'od.dod'
|
||||
|
||||
|
||||
def test_mod_dyndescription():
|
||||
st = StrOption('st', '')
|
||||
dod = DynOptionDescription('dod', '', [st], suffixes=Calculation(return_list))
|
||||
|
|
|
|||
|
|
@ -289,6 +289,7 @@ def test_callback(config_type):
|
|||
cfg = Config(od1)
|
||||
cfg.property.read_write()
|
||||
cfg = get_config(cfg, config_type)
|
||||
assert isinstance(cfg.option('val1').value.get(uncalculated=True), Calculation)
|
||||
assert cfg.option('val1').value.get() == 'val'
|
||||
cfg.option('val1').value.set('new-val')
|
||||
assert cfg.option('val1').value.get() == 'new-val'
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright (C) 2012-2023 Team tiramisu (see AUTHORS for all contributors)
|
||||
# Copyright (C) 2012-2024 Team tiramisu (see AUTHORS for all contributors)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published by the
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2017-2023 Team tiramisu (see AUTHORS for all contributors)
|
||||
# Copyright (C) 2017-2024 Team tiramisu (see AUTHORS for all contributors)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published by the
|
||||
|
|
@ -199,9 +199,11 @@ class _TiramisuOptionWalk:
|
|||
def _list(self,
|
||||
subconfig: SubConfig,
|
||||
validate_properties: bool,
|
||||
*,
|
||||
uncalculated: bool=False,
|
||||
):
|
||||
options = []
|
||||
for sub_subconfig in subconfig.get_children(validate_properties=validate_properties):
|
||||
for sub_subconfig in subconfig.get_children(validate_properties, uncalculated=uncalculated):
|
||||
options.append(TiramisuOption(sub_subconfig.path,
|
||||
sub_subconfig.index,
|
||||
self._config_bag,
|
||||
|
|
@ -243,15 +245,23 @@ class _TiramisuOptionOptionDescription:
|
|||
)
|
||||
|
||||
@option_type(['optiondescription', 'option', 'symlink', 'with_or_without_index'])
|
||||
def name(self) -> str:
|
||||
def name(self,
|
||||
*,
|
||||
uncalculated: bool=False,
|
||||
) -> str:
|
||||
"""Get option name"""
|
||||
#FIXME impl_getname ?
|
||||
if uncalculated:
|
||||
return self._subconfig.option.impl_getname()
|
||||
return self._subconfig.true_path.rsplit('.', 1)[-1]
|
||||
|
||||
@option_type(['optiondescription', 'option', 'with_or_without_index', 'symlink'])
|
||||
def path(self,
|
||||
*,
|
||||
uncalculated: bool=False,
|
||||
) -> str:
|
||||
"""Get option path"""
|
||||
if uncalculated:
|
||||
return self._subconfig.option.impl_getpath()
|
||||
return self._subconfig.true_path
|
||||
|
||||
@option_type(['optiondescription', 'option', 'symlink', 'with_or_without_index'])
|
||||
|
|
@ -281,9 +291,14 @@ class _TiramisuOptionOptionDescription:
|
|||
return option.get_type()
|
||||
|
||||
@option_type(['option', 'optiondescription', 'symlink', 'with_or_without_index'])
|
||||
def isdynamic(self):
|
||||
def isdynamic(self,
|
||||
*,
|
||||
only_self: bool=False):
|
||||
"""Test if option is a dynamic optiondescription"""
|
||||
if not only_self:
|
||||
return self._subconfig.is_dynamic
|
||||
return self._subconfig.option.impl_is_optiondescription() and \
|
||||
self._subconfig.option.impl_is_dynoptiondescription()
|
||||
|
||||
@option_type(['option', 'leadership'])
|
||||
def leader(self):
|
||||
|
|
@ -304,9 +319,16 @@ class _TiramisuOptionOptionDescription:
|
|||
)
|
||||
|
||||
@option_type(['dynamic', 'with_or_without_index'])
|
||||
def suffixes(self):
|
||||
def suffixes(self,
|
||||
only_self: bool=False,
|
||||
):
|
||||
"""Get suffixes for dynamic option"""
|
||||
if not only_self:
|
||||
return self._subconfig.suffixes
|
||||
if not self._subconfig.option.impl_is_optiondescription() or \
|
||||
not self._subconfig.option.impl_is_dynoptiondescription():
|
||||
raise ConfigError(_(f'the option {self._subconfig.path} is not a dynamic option, cannot get suffixes with only_self parameter to True'))
|
||||
return self._subconfig.option.get_suffixes(self._subconfig.parent)
|
||||
|
||||
|
||||
class _TiramisuOptionOption(_TiramisuOptionOptionDescription):
|
||||
|
|
@ -447,6 +469,7 @@ class TiramisuOptionProperty(CommonTiramisuOption):
|
|||
|
||||
@option_type(['option', 'optiondescription', 'with_index', 'symlink'])
|
||||
def get(self,
|
||||
*,
|
||||
only_raises: bool=False,
|
||||
apply_requires: bool=True,
|
||||
uncalculated: bool=False,
|
||||
|
|
@ -591,7 +614,6 @@ class _TiramisuODGet():
|
|||
"""exports the whole config into a `dict`
|
||||
:returns: dict of Option's name (or path) and values
|
||||
"""
|
||||
#for self._subconfig, value in self._config_bag.context.walk(root_self._subconfig):
|
||||
def parse_od_get(values):
|
||||
ret_ = {}
|
||||
for subconfig, value in values.items():
|
||||
|
|
@ -604,19 +626,6 @@ class _TiramisuODGet():
|
|||
value = parse_od_get(value)
|
||||
ret_[option] = value
|
||||
return ret_
|
||||
# else:
|
||||
# leader_ret = []
|
||||
# leader = data['leader']
|
||||
# for idx, value in enumerate(self.get_value(leader,
|
||||
# need_help=False,
|
||||
# )):
|
||||
# leader_dict = {leader: value}
|
||||
# for follower in data.get(idx, []):
|
||||
# leader_dict[follower] = self.get_value(follower,
|
||||
# need_help=False,
|
||||
# )
|
||||
# leader_ret.append(leader_dict)
|
||||
# ret[leader] = leader_ret
|
||||
return parse_od_get(self._config_bag.context.walk(root_subconfig))
|
||||
|
||||
|
||||
|
|
@ -625,11 +634,18 @@ class TiramisuOptionValue(CommonTiramisuOption, _TiramisuODGet):
|
|||
_validate_properties = True
|
||||
|
||||
@option_type(['option', 'symlink', 'with_index', 'optiondescription'])
|
||||
def get(self):
|
||||
def get(self,
|
||||
*,
|
||||
uncalculated: bool=False,
|
||||
):
|
||||
"""Get value for an option or option and sub option with values with optiondescription"""
|
||||
if self._subconfig.option.impl_is_optiondescription():
|
||||
if uncalculated:
|
||||
raise ConfigError('uncalculated is not allowed for optiondescription')
|
||||
return self._od_get(self._subconfig)
|
||||
return self._get()
|
||||
if uncalculated:
|
||||
return self._subconfig.option.impl_getdefault()
|
||||
return self._get(uncalculated)
|
||||
|
||||
def _get(self,
|
||||
need_help: bool=True,
|
||||
|
|
@ -688,9 +704,14 @@ class TiramisuOptionValue(CommonTiramisuOption, _TiramisuODGet):
|
|||
return True
|
||||
|
||||
@option_type(['choice', 'with_index'])
|
||||
def list(self):
|
||||
def list(self,
|
||||
*,
|
||||
uncalculated: bool=False,
|
||||
):
|
||||
"""All values available for a ChoiceOption"""
|
||||
return self._subconfig.option.impl_get_values(self._subconfig)
|
||||
return self._subconfig.option.impl_get_values(self._subconfig,
|
||||
uncalculated,
|
||||
)
|
||||
|
||||
@option_type('leader')
|
||||
def pop(self,
|
||||
|
|
@ -811,11 +832,14 @@ class TiramisuOption(CommonTiramisu,
|
|||
|
||||
@option_type('optiondescription')
|
||||
def list(self,
|
||||
*,
|
||||
validate_properties: bool=True,
|
||||
uncalculated: bool=False,
|
||||
):
|
||||
"""List options inside an option description (by default list only option)"""
|
||||
return self._list(self._subconfig,
|
||||
validate_properties,
|
||||
uncalculated=uncalculated,
|
||||
)
|
||||
|
||||
def _load_dict(self,
|
||||
|
|
@ -1062,6 +1086,7 @@ class TiramisuContextProperty(TiramisuConfig, PropertyPermissive):
|
|||
self._set(frozenset(props))
|
||||
|
||||
def get(self,
|
||||
*,
|
||||
only_raises: bool=False,
|
||||
apply_requires: bool=True,
|
||||
uncalculated: bool=False,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright (C) 2012-2023 Team tiramisu (see AUTHORS for all contributors)
|
||||
# Copyright (C) 2012-2024 Team tiramisu (see AUTHORS for all contributors)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published by the
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"cache used by storage"
|
||||
# Copyright (C) 2013-2023 Team tiramisu (see AUTHORS for all contributors)
|
||||
# Copyright (C) 2013-2024 Team tiramisu (see AUTHORS for all contributors)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published by the
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2012-2023 Team tiramisu (see AUTHORS for all contributors)
|
||||
# Copyright (C) 2012-2024 Team tiramisu (see AUTHORS for all contributors)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published by the
|
||||
|
|
@ -296,12 +296,14 @@ class SubConfig:
|
|||
|
||||
def get_children(self,
|
||||
validate_properties,
|
||||
*,
|
||||
uncalculated: bool=False,
|
||||
):
|
||||
if self.option.impl_is_leadership():
|
||||
yield from self.get_leadership_children(validate_properties)
|
||||
else:
|
||||
for child in self.option.get_children():
|
||||
if child.impl_is_dynoptiondescription():
|
||||
if child.impl_is_dynoptiondescription() and not uncalculated:
|
||||
yield from self.dyn_to_subconfig(child,
|
||||
validate_properties,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2012-2023 Team tiramisu (see AUTHORS for all contributors)
|
||||
# Copyright (C) 2012-2024 Team tiramisu (see AUTHORS for all contributors)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published by the
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright (C) 2018-2023 Team tiramisu (see AUTHORS for all contributors)
|
||||
# Copyright (C) 2018-2024 Team tiramisu (see AUTHORS for all contributors)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published by the
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# -*- coding: UTF-8 -*-
|
||||
# Copyright (C) 2012-2023 Team tiramisu (see AUTHORS for all contributors)
|
||||
# Copyright (C) 2012-2024 Team tiramisu (see AUTHORS for all contributors)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published by the
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"logger for tiramisu"
|
||||
# Copyright (C) 2019-2023 Team tiramisu (see AUTHORS for all contributors)
|
||||
# Copyright (C) 2019-2024 Team tiramisu (see AUTHORS for all contributors)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published by the
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2014-2023 Team tiramisu (see AUTHORS for all contributors)
|
||||
# Copyright (C) 2014-2024 Team tiramisu (see AUTHORS for all contributors)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published by the
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2014-2023 Team tiramisu (see AUTHORS for all contributors)
|
||||
# Copyright (C) 2014-2024 Team tiramisu (see AUTHORS for all contributors)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published by the
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2017-2023 Team tiramisu (see AUTHORS for all contributors)
|
||||
# Copyright (C) 2017-2024 Team tiramisu (see AUTHORS for all contributors)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published by the
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2017-2023 Team tiramisu (see AUTHORS for all contributors)
|
||||
# Copyright (C) 2017-2024 Team tiramisu (see AUTHORS for all contributors)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published by the
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2017-2023 Team tiramisu (see AUTHORS for all contributors)
|
||||
# Copyright (C) 2017-2024 Team tiramisu (see AUTHORS for all contributors)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published by the
|
||||
|
|
@ -58,12 +58,15 @@ class ChoiceOption(Option):
|
|||
|
||||
def impl_get_values(self,
|
||||
subconfig: "SubConfig",
|
||||
uncalculated: bool=False,
|
||||
):
|
||||
"""get values allowed by option
|
||||
"""
|
||||
choices = self._choice_values
|
||||
if isinstance(choices, tuple):
|
||||
choices = list(choices)
|
||||
if uncalculated:
|
||||
return choices
|
||||
values = get_calculated_value(subconfig,
|
||||
choices,
|
||||
)[0]
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2017-2023 Team tiramisu (see AUTHORS for all contributors)
|
||||
# Copyright (C) 2017-2024 Team tiramisu (see AUTHORS for all contributors)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published by the
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2017-2023 Team tiramisu (see AUTHORS for all contributors)
|
||||
# Copyright (C) 2017-2024 Team tiramisu (see AUTHORS for all contributors)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published by the
|
||||
|
|
@ -45,17 +45,13 @@ class DomainnameOption(StrOption):
|
|||
def __init__(self,
|
||||
name: str,
|
||||
doc: str,
|
||||
default: Any=undefined,
|
||||
default_multi: Any=None,
|
||||
multi: bool=False,
|
||||
validators: Optional[List[Calculation]]=None,
|
||||
properties: Optional[List[str]]=None,
|
||||
warnings_only: bool=False,
|
||||
*args,
|
||||
allow_ip: bool=False,
|
||||
allow_cidr_network: bool=False,
|
||||
type: str='domainname',
|
||||
allow_without_dot: bool=False,
|
||||
allow_startswith_dot: bool=False,
|
||||
**kwargs,
|
||||
) -> None:
|
||||
# pylint: disable=too-many-branches,too-many-locals,too-many-arguments
|
||||
if type not in ['netbios', 'hostname', 'domainname']:
|
||||
|
|
@ -94,24 +90,23 @@ class DomainnameOption(StrOption):
|
|||
extra['_has_upper'] = re.compile('[A-Z]')
|
||||
if allow_ip:
|
||||
extra['_ip'] = IPOption(name,
|
||||
doc)
|
||||
doc,
|
||||
)
|
||||
extra['_allow_ip'] = allow_ip
|
||||
if allow_cidr_network:
|
||||
extra['_network'] = NetworkOption(name,
|
||||
doc,
|
||||
cidr=True)
|
||||
cidr=True,
|
||||
)
|
||||
extra['_allow_cidr_network'] = allow_cidr_network
|
||||
extra['_allow_startswith_dot'] = allow_startswith_dot
|
||||
|
||||
super().__init__(name,
|
||||
doc,
|
||||
default=default,
|
||||
default_multi=default_multi,
|
||||
multi=multi,
|
||||
validators=validators,
|
||||
properties=properties,
|
||||
warnings_only=warnings_only,
|
||||
extra=extra)
|
||||
*args,
|
||||
extra=extra,
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
def _get_len(self, type_):
|
||||
if type_ == 'netbios':
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2017-2023 Team tiramisu (see AUTHORS for all contributors)
|
||||
# Copyright (C) 2017-2024 Team tiramisu (see AUTHORS for all contributors)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published by the
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2017-2023 Team tiramisu (see AUTHORS for all contributors)
|
||||
# Copyright (C) 2017-2024 Team tiramisu (see AUTHORS for all contributors)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published by the
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2017-2023 Team tiramisu (see AUTHORS for all contributors)
|
||||
# Copyright (C) 2017-2024 Team tiramisu (see AUTHORS for all contributors)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published by the
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2017-2023 Team tiramisu (see AUTHORS for all contributors)
|
||||
# Copyright (C) 2017-2024 Team tiramisu (see AUTHORS for all contributors)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published by the
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2017-2023 Team tiramisu (see AUTHORS for all contributors)
|
||||
# Copyright (C) 2017-2024 Team tiramisu (see AUTHORS for all contributors)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published by the
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2017-2023 Team tiramisu (see AUTHORS for all contributors)
|
||||
# Copyright (C) 2017-2024 Team tiramisu (see AUTHORS for all contributors)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published by the
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"Leadership support"
|
||||
# Copyright (C) 2014-2023 Team tiramisu (see AUTHORS for all contributors)
|
||||
# Copyright (C) 2014-2024 Team tiramisu (see AUTHORS for all contributors)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published by the
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2020-2023 Team tiramisu (see AUTHORS for all contributors)
|
||||
# Copyright (C) 2020-2024 Team tiramisu (see AUTHORS for all contributors)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published by the
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2017-2023 Team tiramisu (see AUTHORS for all contributors)
|
||||
# Copyright (C) 2017-2024 Team tiramisu (see AUTHORS for all contributors)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published by the
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2017-2023 Team tiramisu (see AUTHORS for all contributors)
|
||||
# Copyright (C) 2017-2024 Team tiramisu (see AUTHORS for all contributors)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published by the
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"option types and option description"
|
||||
# Copyright (C) 2012-2023 Team tiramisu (see AUTHORS for all contributors)
|
||||
# Copyright (C) 2012-2024 Team tiramisu (see AUTHORS for all contributors)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published by the
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2014-2023 Team tiramisu (see AUTHORS for all contributors)
|
||||
# Copyright (C) 2014-2024 Team tiramisu (see AUTHORS for all contributors)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published by the
|
||||
|
|
@ -86,7 +86,7 @@ class CacheOptionDescription(BaseOption):
|
|||
force_store_values,
|
||||
dependencies_information,
|
||||
)
|
||||
else:
|
||||
elif not option.impl_is_symlinkoption():
|
||||
informations = option.get_dependencies_information()
|
||||
if informations:
|
||||
for param in informations.pop(None):
|
||||
|
|
@ -94,7 +94,6 @@ class CacheOptionDescription(BaseOption):
|
|||
for information, options in option.get_dependencies_information().items():
|
||||
if None in options:
|
||||
dependencies_information.setdefault(information, []).append(option)
|
||||
if not option.impl_is_symlinkoption():
|
||||
properties = option.impl_getproperties()
|
||||
if 'force_store_value' in properties:
|
||||
force_store_values.append(option)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2017-2023 Team tiramisu (see AUTHORS for all contributors)
|
||||
# Copyright (C) 2017-2024 Team tiramisu (see AUTHORS for all contributors)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published by the
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2023 Team tiramisu (see AUTHORS for all contributors)
|
||||
# Copyright (C) 2023-2024 Team tiramisu (see AUTHORS for all contributors)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published by the
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2017-2023 Team tiramisu (see AUTHORS for all contributors)
|
||||
# Copyright (C) 2017-2024 Team tiramisu (see AUTHORS for all contributors)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published by the
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2017-2023 Team tiramisu (see AUTHORS for all contributors)
|
||||
# Copyright (C) 2017-2024 Team tiramisu (see AUTHORS for all contributors)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published by the
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2017-2023 Team tiramisu (see AUTHORS for all contributors)
|
||||
# Copyright (C) 2017-2024 Team tiramisu (see AUTHORS for all contributors)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published by the
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2017-2023 Team tiramisu (see AUTHORS for all contributors)
|
||||
# Copyright (C) 2017-2024 Team tiramisu (see AUTHORS for all contributors)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published by the
|
||||
|
|
@ -41,13 +41,7 @@ class URLOption(StrOption):
|
|||
def __init__(self,
|
||||
name: str,
|
||||
doc: str,
|
||||
default: Any=undefined,
|
||||
default_multi: Any=None,
|
||||
multi: bool=False,
|
||||
validators: Optional[List[Calculation]]=None,
|
||||
properties: Optional[List[str]]=None,
|
||||
warnings_only: bool=False,
|
||||
extra: Optional[Dict]=None,
|
||||
*args,
|
||||
allow_ip: bool=False,
|
||||
type: str='domainname',
|
||||
allow_without_dot=False,
|
||||
|
|
@ -55,7 +49,9 @@ class URLOption(StrOption):
|
|||
allow_zero: bool=False,
|
||||
allow_wellknown: bool=True,
|
||||
allow_registred: bool=True,
|
||||
allow_private: bool=False) -> None:
|
||||
allow_private: bool=False,
|
||||
**kwargs,
|
||||
) -> None:
|
||||
# pylint: disable=too-many-arguments,too-many-locals,redefined-builtin
|
||||
extra = {'_domainname': DomainnameOption(name,
|
||||
doc,
|
||||
|
|
@ -71,13 +67,10 @@ class URLOption(StrOption):
|
|||
allow_private=allow_private)}
|
||||
super().__init__(name,
|
||||
doc,
|
||||
default=default,
|
||||
default_multi=default_multi,
|
||||
multi=multi,
|
||||
validators=validators,
|
||||
properties=properties,
|
||||
warnings_only=warnings_only,
|
||||
extra=extra)
|
||||
extra=extra,
|
||||
*args,
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
def _get_domain_port_files(self,
|
||||
value: str) -> (str, str):
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2017-2023 Team tiramisu (see AUTHORS for all contributors)
|
||||
# Copyright (C) 2017-2024 Team tiramisu (see AUTHORS for all contributors)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published by the
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"sets the options of the configuration objects Config object itself"
|
||||
# Copyright (C) 2012-2023 Team tiramisu (see AUTHORS for all contributors)
|
||||
# Copyright (C) 2012-2024 Team tiramisu (see AUTHORS for all contributors)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published by the
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"takes care of the option's values and multi values"
|
||||
# Copyright (C) 2013-2023 Team tiramisu (see AUTHORS for all contributors)
|
||||
# Copyright (C) 2013-2024 Team tiramisu (see AUTHORS for all contributors)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published by the
|
||||
|
|
|
|||
Loading…
Reference in a new issue