separate config properties and properties in option + better properties check
This commit is contained in:
parent
fee8997f13
commit
a30eaacb1f
2 changed files with 24 additions and 12 deletions
|
@ -174,6 +174,19 @@ class _TiramisuOptionOptionDescription(CommonTiramisuOption):
|
|||
option = self._option_bag.option
|
||||
return option.impl_is_optiondescription()
|
||||
|
||||
def properties(self,
|
||||
only_raises=False):
|
||||
"""Get properties for an option"""
|
||||
settings = self._option_bag.config_bag.context.cfgimpl_get_settings()
|
||||
properties = settings.getproperties(self._option_bag,
|
||||
apply_requires=False)
|
||||
if not only_raises:
|
||||
return properties
|
||||
# do not check cache properties/permissives which are not save (unrestraint, ...)
|
||||
return settings.calc_raises_properties(properties,
|
||||
settings.get_context_properties(),
|
||||
settings.get_context_properties())
|
||||
|
||||
|
||||
class _TiramisuOptionOption(_TiramisuOptionOptionDescription):
|
||||
"""Manage option"""
|
||||
|
@ -293,21 +306,17 @@ class TiramisuOptionProperty(CommonTiramisuOption):
|
|||
self._settings = option_bag.config_bag.context.cfgimpl_get_settings()
|
||||
|
||||
def get(self,
|
||||
apply_requires=True,
|
||||
only_raises=False):
|
||||
"""Get properties for an option"""
|
||||
option = self._option_bag.option
|
||||
if apply_requires:
|
||||
self._test_slave_index()
|
||||
properties = self._option_bag.properties
|
||||
else:
|
||||
properties = self._settings.getproperties(self._option_bag,
|
||||
apply_requires=False)
|
||||
self._test_slave_index()
|
||||
properties = self._option_bag.properties
|
||||
if not only_raises:
|
||||
return properties
|
||||
# do not check cache properties/permissives which are not save (unrestraint, ...)
|
||||
return self._settings.calc_raises_properties(properties,
|
||||
self._option_bag.config_bag.properties,
|
||||
self._option_bag.config_bag.permissives)
|
||||
self._settings.get_context_properties(),
|
||||
self._settings.get_context_properties())
|
||||
|
||||
def add(self, prop):
|
||||
"""Add new property for an option"""
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
from typing import Any, Optional, Union, Callable, Dict, List
|
||||
|
||||
|
||||
from .error import PropertiesOptionError, ConfigError, SlaveError
|
||||
from .error import PropertiesOptionError, ConfigError, SlaveError, RequirementError
|
||||
from .i18n import _
|
||||
from .setting import undefined, ConfigBag, OptionBag, Undefined
|
||||
from .storage import get_default_values_storages, get_default_settings_storages
|
||||
|
@ -89,9 +89,12 @@ def manager_callback(callbk: Union[ParamOption, ParamValue],
|
|||
if with_index:
|
||||
return value[index]
|
||||
return value
|
||||
except PropertiesOptionError as err:
|
||||
except (PropertiesOptionError, RequirementError) as err:
|
||||
# raise because must not add value None in carry_out_calculation
|
||||
if callbk.notraisepropertyerror:
|
||||
raise err
|
||||
raise PropertiesOptionError(option_bag,
|
||||
None,
|
||||
None)
|
||||
raise ConfigError(_('unable to carry out a calculation for "{}"'
|
||||
', {}').format(option.impl_get_display_name(), err))
|
||||
|
||||
|
|
Loading…
Reference in a new issue