diff --git a/tiramisu/__init__.py b/tiramisu/__init__.py index 1e0fec4..0034f2a 100644 --- a/tiramisu/__init__.py +++ b/tiramisu/__init__.py @@ -16,7 +16,7 @@ """ from .function import calc_value, calc_value_property_help, valid_ip_netmask, \ valid_network_netmask, valid_in_network, valid_broadcast, \ - valid_not_equal, function_waiting_for_dict + valid_not_equal, function_waiting_for_dict, function_waiting_for_error from .autolib import Calculation, Params, ParamOption, ParamDynOption, ParamSelfOption, \ ParamValue, ParamIndex, ParamIdentifier, ParamInformation, ParamSelfInformation from .option import * @@ -51,6 +51,7 @@ allfuncs = ['Calculation', 'valid_in_network', 'valid_broadcast', 'function_waiting_for_dict', + 'function_waiting_for_error', ] allfuncs.extend(all_options) del(all_options) diff --git a/tiramisu/autolib.py b/tiramisu/autolib.py index d8118cb..3f1cf6e 100644 --- a/tiramisu/autolib.py +++ b/tiramisu/autolib.py @@ -25,7 +25,7 @@ import weakref from .error import PropertiesOptionError, ConfigError, LeadershipError, ValueWarning from .i18n import _ from .setting import undefined, ConfigBag -from .function import FUNCTION_WAITING_FOR_DICT +from .function import FUNCTION_WAITING_FOR_DICT, FUNCTION_WAITING_FOR_ERROR # ____________________________________________________________ @@ -662,6 +662,11 @@ def carry_out_calculation(subconfig: 'SubConfig', args.append({'propertyerror': str(err), 'name': option.impl_get_display_name(subconfig)}) else: 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, callback, allow_value_error, diff --git a/tiramisu/function.py b/tiramisu/function.py index 1d487f0..3741b55 100644 --- a/tiramisu/function.py +++ b/tiramisu/function.py @@ -23,6 +23,7 @@ from .error import display_list FUNCTION_WAITING_FOR_DICT = [] +FUNCTION_WAITING_FOR_ERROR = [] def function_waiting_for_dict(function): @@ -36,6 +37,16 @@ def function_waiting_for_dict(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 def valid_network_netmask(network: dict, netmask: dict,