demoting_error_warning is not more mandatory in option.dict()

RequirementError returns proptype
better submulti support for valid_mandatory
This commit is contained in:
Emmanuel Garette 2019-04-17 19:13:40 +02:00
parent 829247e79f
commit 6d0d233d9b
3 changed files with 13 additions and 12 deletions

View File

@ -579,12 +579,14 @@ class Settings(object):
prop_msg = _('property') prop_msg = _('property')
else: else:
prop_msg = _('properties') 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}' 'required option "{1}" has {2} {3}'
'').format(option_bag.option.impl_get_display_name(), '').format(option_bag.option.impl_get_display_name(),
option.impl_get_display_name(), option.impl_get_display_name(),
prop_msg, prop_msg,
display_list(list(properties), add_quote=True))) display_list(list(properties), add_quote=True)))
err.proptype = properties
raise err
# transitive action, add action # transitive action, add action
if operator != 'and': if operator != 'and':
if readable: if readable:
@ -778,12 +780,11 @@ class Settings(object):
if 'mandatory' in option_bag.config_bag.properties: if 'mandatory' in option_bag.config_bag.properties:
values = option_bag.config_bag.context.cfgimpl_get_values() values = option_bag.config_bag.context.cfgimpl_get_values()
is_mandatory = False is_mandatory = False
if ('permissive' in option_bag.config_bag.properties) and \ if not ('permissive' in option_bag.config_bag.properties and
'mandatory' in option_bag.config_bag.permissives: 'mandatory' in option_bag.config_bag.permissives) and \
pass 'mandatory' in option_bag.properties and values.isempty(option_bag.option,
elif 'mandatory' in option_bag.properties and values.isempty(option_bag.option, value,
value, index=option_bag.index):
index=option_bag.index):
is_mandatory = True is_mandatory = True
if 'empty' in option_bag.properties and values.isempty(option_bag.option, if 'empty' in option_bag.properties and values.isempty(option_bag.option,
value, value,

View File

@ -319,8 +319,6 @@ class TiramisuDict:
root=None, root=None,
clearable="all", clearable="all",
remotable="minimum"): remotable="minimum"):
if 'demoting_error_warning' not in config.property.get():
raise ValueError('demoting_error_warning property is mandatory')
self.config = config self.config = config
self.root = root self.root = root
self.requires = None self.requires = None
@ -390,7 +388,7 @@ class TiramisuDict:
schema, schema,
'force_store_value' in props_no_requires) 'force_store_value' in props_no_requires)
childapi_option = childapi.option 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, self.gen_model(model,
childapi, childapi,
path, path,

View File

@ -17,7 +17,7 @@
# ____________________________________________________________ # ____________________________________________________________
import weakref import weakref
from typing import Optional, Any, Callable 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 .setting import owners, undefined, forbidden_owners, OptionBag, ConfigBag
from .autolib import carry_out_calculation from .autolib import carry_out_calculation
from .function import Params from .function import Params
@ -251,7 +251,7 @@ class Values(object):
isempty = value is None or (not allow_empty_list and value == []) or \ isempty = value is None or (not allow_empty_list and value == []) or \
None in value or empty in value None in value or empty in value
else: else:
isempty = value is None or value == empty isempty = value is None or value == empty or (opt.impl_is_submulti() and value == [])
return isempty return isempty
#______________________________________________________________________ #______________________________________________________________________
@ -602,6 +602,8 @@ class Values(object):
except PropertiesOptionError as err: except PropertiesOptionError as err:
if err.proptype == ['mandatory']: if err.proptype == ['mandatory']:
yield path yield path
except RequirementError:
pass
except ConfigError as err: except ConfigError as err:
#assume that uncalculated value is an empty value #assume that uncalculated value is an empty value
yield path yield path