diff --git a/tiramisu/api.py b/tiramisu/api.py index c085be1..306e888 100644 --- a/tiramisu/api.py +++ b/tiramisu/api.py @@ -26,7 +26,7 @@ from .i18n import _ from .setting import ConfigBag, OptionBag, owners, groups, undefined, \ FORBIDDEN_SET_PROPERTIES, SPECIAL_PROPERTIES from .config import KernelConfig, KernelGroupConfig, KernelMetaConfig, KernelMixConfig -from .option import RegexpOption, OptionDescription, ChoiceOption +from .option import RegexpOption, OptionDescription, ChoiceOption, Leadership from .todict import TiramisuDict from .autolib import Calculation @@ -129,6 +129,7 @@ def option_type(typ): options_bag = self._get_options_bag('with_index' not in types) option = options_bag[-1].option if option.impl_is_optiondescription() and 'optiondescription' in types or \ + option.impl_is_optiondescription() and option.impl_is_leadership() and 'leadership' in types or \ not option.impl_is_optiondescription() and ( option.impl_is_symlinkoption() and 'symlink' in types or \ not option.impl_is_symlinkoption() and ( @@ -377,10 +378,14 @@ class _TiramisuOptionOption(_TiramisuOptionOptionDescription): #FIXME only from 0.0.0.0 to 255.255.255.255 return r'^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$' - @option_type('option') + @option_type(['option', 'leadership']) def leader(self, options_bag: List[OptionBag]): """Get the leader option for a follower option""" - path = options_bag[-1].option.impl_get_leadership().get_leader().impl_getpath() + option = options_bag[-1].option + leadership = options_bag[-1].option + if not isinstance(option, Leadership): + leadership = leadership.impl_get_leadership() + path = leadership.get_leader().impl_getpath() return TiramisuOption(path, None, self._config_bag,