mandatory_warnings: PropertiesOptionError in optiondescription stop validate mandatory warnings for followers options

This commit is contained in:
Emmanuel Garette 2018-09-08 22:51:27 +02:00
parent aa9aef6e78
commit 7bfa6679e3
2 changed files with 10 additions and 8 deletions

View File

@ -12,6 +12,8 @@ from tiramisu.setting import groups
def make_description(): def make_description():
stro = StrOption('str', '')
subdescr = OptionDescription('sub', '', [stro], properties=('disabled',))
stroption = StrOption('str', 'Test string option', default="abc", stroption = StrOption('str', 'Test string option', default="abc",
properties=('mandatory', )) properties=('mandatory', ))
stroption1 = StrOption('str1', 'Test string option', stroption1 = StrOption('str1', 'Test string option',
@ -22,7 +24,7 @@ def make_description():
properties=('mandatory', )) properties=('mandatory', ))
stroption4 = StrOption('str4', 'Test string option', multi=True, stroption4 = StrOption('str4', 'Test string option', multi=True,
properties=('mandatory', ), allow_empty_list=True) properties=('mandatory', ), allow_empty_list=True)
descr = OptionDescription('tiram', '', [stroption, stroption1, stroption2, stroption3, stroption4]) descr = OptionDescription('tiram', '', [subdescr, stroption, stroption1, stroption2, stroption3, stroption4])
return descr return descr

View File

@ -537,7 +537,7 @@ class Values(object):
description, description,
currpath, currpath,
config, config,
od_setting_properties): od_config_bag):
settings = context.cfgimpl_get_settings() settings = context.cfgimpl_get_settings()
# for option in config.cfgimpl_get_children(self.config_bag): # for option in config.cfgimpl_get_children(self.config_bag):
for option in description.impl_getchildren(config_bag, context): for option in description.impl_getchildren(config_bag, context):
@ -545,26 +545,23 @@ class Values(object):
path = '.'.join(currpath + [name]) path = '.'.join(currpath + [name])
if option.impl_is_optiondescription(): if option.impl_is_optiondescription():
ori_setting_properties = config_bag.properties
config_bag.properties = od_setting_properties
try: try:
option_bag = OptionBag() option_bag = OptionBag()
option_bag.set_option(option, option_bag.set_option(option,
path, path,
None, None,
config_bag) od_config_bag)
subconfig = config.get_subconfig(name, subconfig = config.get_subconfig(name,
option_bag) option_bag)
except PropertiesOptionError as err: except PropertiesOptionError as err:
pass pass
else: else:
config_bag.properties = ori_setting_properties
for path in self._mandatory_warnings(context, for path in self._mandatory_warnings(context,
config_bag, config_bag,
option, option,
currpath + [name], currpath + [name],
subconfig, subconfig,
od_setting_properties): od_config_bag):
yield path yield path
elif not option.impl_is_symlinkoption(): elif not option.impl_is_symlinkoption():
# don't verifying symlink # don't verifying symlink
@ -610,6 +607,9 @@ class Values(object):
config_bag = ConfigBag(context=config_bag.context) config_bag = ConfigBag(context=config_bag.context)
config_bag.properties = frozenset(setting_properties) config_bag.properties = frozenset(setting_properties)
config_bag.set_permissive() config_bag.set_permissive()
od_config_bag = ConfigBag(context=config_bag.context)
od_config_bag.properties = frozenset(od_setting_properties)
od_config_bag.set_permissive()
descr = context.cfgimpl_get_description() descr = context.cfgimpl_get_description()
return self._mandatory_warnings(context, return self._mandatory_warnings(context,
@ -617,4 +617,4 @@ class Values(object):
descr, descr,
[], [],
context, context,
od_setting_properties) od_config_bag)