From 6d0d233d9be5c6a5d88532b928588ceb7faa417d Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Wed, 17 Apr 2019 19:13:40 +0200 Subject: [PATCH] demoting_error_warning is not more mandatory in option.dict() RequirementError returns proptype better submulti support for valid_mandatory --- tiramisu/setting.py | 15 ++++++++------- tiramisu/todict.py | 4 +--- tiramisu/value.py | 6 ++++-- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/tiramisu/setting.py b/tiramisu/setting.py index 6e674ea..6e8a438 100644 --- a/tiramisu/setting.py +++ b/tiramisu/setting.py @@ -579,12 +579,14 @@ class Settings(object): prop_msg = _('property') else: prop_msg = _('properties') - raise RequirementError(_('cannot access to option "{0}" because ' + err = RequirementError(_('cannot access to option "{0}" because ' 'required option "{1}" has {2} {3}' '').format(option_bag.option.impl_get_display_name(), option.impl_get_display_name(), prop_msg, display_list(list(properties), add_quote=True))) + err.proptype = properties + raise err # transitive action, add action if operator != 'and': if readable: @@ -778,12 +780,11 @@ class Settings(object): if 'mandatory' in option_bag.config_bag.properties: values = option_bag.config_bag.context.cfgimpl_get_values() is_mandatory = False - if ('permissive' in option_bag.config_bag.properties) and \ - 'mandatory' in option_bag.config_bag.permissives: - pass - elif 'mandatory' in option_bag.properties and values.isempty(option_bag.option, - value, - index=option_bag.index): + if not ('permissive' in option_bag.config_bag.properties and + 'mandatory' in option_bag.config_bag.permissives) and \ + 'mandatory' in option_bag.properties and values.isempty(option_bag.option, + value, + index=option_bag.index): is_mandatory = True if 'empty' in option_bag.properties and values.isempty(option_bag.option, value, diff --git a/tiramisu/todict.py b/tiramisu/todict.py index 2c2c7e0..2a92619 100644 --- a/tiramisu/todict.py +++ b/tiramisu/todict.py @@ -319,8 +319,6 @@ class TiramisuDict: root=None, clearable="all", remotable="minimum"): - if 'demoting_error_warning' not in config.property.get(): - raise ValueError('demoting_error_warning property is mandatory') self.config = config self.root = root self.requires = None @@ -390,7 +388,7 @@ class TiramisuDict: schema, 'force_store_value' in props_no_requires) childapi_option = childapi.option - if model is not None: + if model is not None and childapi.option.isoptiondescription() or not childapi_option.issymlinkoption(): self.gen_model(model, childapi, path, diff --git a/tiramisu/value.py b/tiramisu/value.py index 08f974d..04e369c 100644 --- a/tiramisu/value.py +++ b/tiramisu/value.py @@ -17,7 +17,7 @@ # ____________________________________________________________ import weakref from typing import Optional, Any, Callable -from .error import ConfigError, PropertiesOptionError +from .error import ConfigError, PropertiesOptionError, RequirementError from .setting import owners, undefined, forbidden_owners, OptionBag, ConfigBag from .autolib import carry_out_calculation from .function import Params @@ -251,7 +251,7 @@ class Values(object): isempty = value is None or (not allow_empty_list and value == []) or \ None in value or empty in value else: - isempty = value is None or value == empty + isempty = value is None or value == empty or (opt.impl_is_submulti() and value == []) return isempty #______________________________________________________________________ @@ -602,6 +602,8 @@ class Values(object): except PropertiesOptionError as err: if err.proptype == ['mandatory']: yield path + except RequirementError: + pass except ConfigError as err: #assume that uncalculated value is an empty value yield path