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')
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,

View file

@ -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,

View file

@ -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