Compare commits
No commits in common. "b5d477a4394bc01558f5e5e293b6c757dc35da09" and "be8b1e7e4f26fde4555f560704588b45fab5f328" have entirely different histories.
b5d477a439
...
be8b1e7e4f
4 changed files with 2 additions and 42 deletions
|
|
@ -1,23 +0,0 @@
|
||||||
""" RegexpOption
|
|
||||||
"""
|
|
||||||
from .autopath import do_autopath
|
|
||||||
do_autopath()
|
|
||||||
|
|
||||||
import pytest
|
|
||||||
from tiramisu import RegexpOption, OptionDescription, Config
|
|
||||||
import re
|
|
||||||
|
|
||||||
|
|
||||||
class ColorOption(RegexpOption):
|
|
||||||
__slots__ = tuple()
|
|
||||||
_type = 'Color'
|
|
||||||
_regexp = re.compile(r"^#(?:[0-9a-f]{3}){1,2}$")
|
|
||||||
|
|
||||||
|
|
||||||
def test_regexp_option():
|
|
||||||
r = ColorOption('test', 'test')
|
|
||||||
od = OptionDescription('od', 'od', [r])
|
|
||||||
cfg = Config(od)
|
|
||||||
cfg.option('test').value.set('#ff0000')
|
|
||||||
with pytest.raises(ValueError):
|
|
||||||
cfg.option('test').value.set('not a color')
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
"""
|
"""
|
||||||
from .function import calc_value, calc_value_property_help, valid_ip_netmask, \
|
from .function import calc_value, calc_value_property_help, valid_ip_netmask, \
|
||||||
valid_network_netmask, valid_in_network, valid_broadcast, \
|
valid_network_netmask, valid_in_network, valid_broadcast, \
|
||||||
valid_not_equal, function_waiting_for_dict, function_waiting_for_error
|
valid_not_equal, function_waiting_for_dict
|
||||||
from .autolib import Calculation, Params, ParamOption, ParamDynOption, ParamSelfOption, \
|
from .autolib import Calculation, Params, ParamOption, ParamDynOption, ParamSelfOption, \
|
||||||
ParamValue, ParamIndex, ParamIdentifier, ParamInformation, ParamSelfInformation
|
ParamValue, ParamIndex, ParamIdentifier, ParamInformation, ParamSelfInformation
|
||||||
from .option import *
|
from .option import *
|
||||||
|
|
@ -51,7 +51,6 @@ allfuncs = ['Calculation',
|
||||||
'valid_in_network',
|
'valid_in_network',
|
||||||
'valid_broadcast',
|
'valid_broadcast',
|
||||||
'function_waiting_for_dict',
|
'function_waiting_for_dict',
|
||||||
'function_waiting_for_error',
|
|
||||||
]
|
]
|
||||||
allfuncs.extend(all_options)
|
allfuncs.extend(all_options)
|
||||||
del(all_options)
|
del(all_options)
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ import weakref
|
||||||
from .error import PropertiesOptionError, ConfigError, LeadershipError, ValueWarning
|
from .error import PropertiesOptionError, ConfigError, LeadershipError, ValueWarning
|
||||||
from .i18n import _
|
from .i18n import _
|
||||||
from .setting import undefined, ConfigBag
|
from .setting import undefined, ConfigBag
|
||||||
from .function import FUNCTION_WAITING_FOR_DICT, FUNCTION_WAITING_FOR_ERROR
|
from .function import FUNCTION_WAITING_FOR_DICT
|
||||||
# ____________________________________________________________
|
# ____________________________________________________________
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -662,11 +662,6 @@ def carry_out_calculation(subconfig: 'SubConfig',
|
||||||
args.append({'propertyerror': str(err), 'name': option.impl_get_display_name(subconfig)})
|
args.append({'propertyerror': str(err), 'name': option.impl_get_display_name(subconfig)})
|
||||||
else:
|
else:
|
||||||
kwargs[key] = {'propertyerror': str(err), 'name': option.impl_get_display_name(subconfig)}
|
kwargs[key] = {'propertyerror': str(err), 'name': option.impl_get_display_name(subconfig)}
|
||||||
if callback.__name__ in FUNCTION_WAITING_FOR_ERROR:
|
|
||||||
if key is None:
|
|
||||||
args.append(err)
|
|
||||||
else:
|
|
||||||
kwargs[key] = err
|
|
||||||
ret = calculate(subconfig,
|
ret = calculate(subconfig,
|
||||||
callback,
|
callback,
|
||||||
allow_value_error,
|
allow_value_error,
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@ from .error import display_list
|
||||||
|
|
||||||
|
|
||||||
FUNCTION_WAITING_FOR_DICT = []
|
FUNCTION_WAITING_FOR_DICT = []
|
||||||
FUNCTION_WAITING_FOR_ERROR = []
|
|
||||||
|
|
||||||
|
|
||||||
def function_waiting_for_dict(function):
|
def function_waiting_for_dict(function):
|
||||||
|
|
@ -37,16 +36,6 @@ def function_waiting_for_dict(function):
|
||||||
return function
|
return function
|
||||||
|
|
||||||
|
|
||||||
def function_waiting_for_error(function):
|
|
||||||
"""functions (calculation or validation) receive by default only the value of other options
|
|
||||||
set PropertyError too
|
|
||||||
"""
|
|
||||||
name = function.__name__
|
|
||||||
if name not in FUNCTION_WAITING_FOR_ERROR:
|
|
||||||
FUNCTION_WAITING_FOR_ERROR.append(name)
|
|
||||||
return function
|
|
||||||
|
|
||||||
|
|
||||||
@function_waiting_for_dict
|
@function_waiting_for_dict
|
||||||
def valid_network_netmask(network: dict,
|
def valid_network_netmask(network: dict,
|
||||||
netmask: dict,
|
netmask: dict,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue