feat: option.type can return the symlink type

This commit is contained in:
egarette@silique.fr 2025-01-04 17:36:44 +01:00
parent 0c993eddb0
commit 42471d42b7
2 changed files with 5 additions and 1 deletions

View file

@ -28,6 +28,8 @@ def test_symlink_option(config_type):
assert cfg.option('c').issymlinkoption() assert cfg.option('c').issymlinkoption()
assert cfg.option('s1.b').type() == 'boolean' assert cfg.option('s1.b').type() == 'boolean'
assert cfg.option('c').type() == 'boolean' assert cfg.option('c').type() == 'boolean'
assert cfg.option('s1.b').type(only_self=True) == 'boolean'
assert cfg.option('c').type(only_self=True) == 'symlink'
assert cfg.option('s1.b').value.get() is False assert cfg.option('s1.b').value.get() is False
cfg.option("s1.b").value.set(True) cfg.option("s1.b").value.set(True)
cfg.option("s1.b").value.set(False) cfg.option("s1.b").value.set(False)

View file

@ -348,11 +348,13 @@ class _TiramisuOptionOptionDescription:
return options return options
@option_type(["option", "optiondescription", "symlink", "with_or_without_index"]) @option_type(["option", "optiondescription", "symlink", "with_or_without_index"])
def type(self): def type(self, only_self=False):
"""Get de option type""" """Get de option type"""
option = self._subconfig.option option = self._subconfig.option
if option.impl_is_optiondescription(): if option.impl_is_optiondescription():
return "optiondescription" return "optiondescription"
if only_self and option.impl_is_symlinkoption():
return 'symlink'
return option.get_type() return option.get_type()
@option_type(["option", "symlink", "with_or_without_index"]) @option_type(["option", "symlink", "with_or_without_index"])