better display function support
This commit is contained in:
parent
90564d4983
commit
de9485b74e
4 changed files with 16 additions and 43 deletions
|
@ -286,39 +286,19 @@ class BaseOption(Base):
|
||||||
raise AttributeError(_(f'"{self.impl_get_display_name()}" not part of any Config')) \
|
raise AttributeError(_(f'"{self.impl_get_display_name()}" not part of any Config')) \
|
||||||
from err
|
from err
|
||||||
|
|
||||||
def _impl_get_display_name(self,
|
def impl_get_display_name(self,
|
||||||
dyn_name: Base=None,
|
dynopt=None,
|
||||||
suffix: str=None,
|
|
||||||
) -> str:
|
) -> str:
|
||||||
name = self.impl_get_information('doc', None)
|
|
||||||
if name is None or name == '':
|
|
||||||
if dyn_name is not None:
|
|
||||||
name = dyn_name
|
|
||||||
else:
|
|
||||||
name = self.impl_getname()
|
|
||||||
elif suffix:
|
|
||||||
name += suffix
|
|
||||||
return name
|
|
||||||
|
|
||||||
def _get_display_name(self,
|
|
||||||
dyn_name,
|
|
||||||
suffix,
|
|
||||||
):
|
|
||||||
if hasattr(self, '_display_name_function'):
|
|
||||||
return self._display_name_function(self,
|
|
||||||
dyn_name,
|
|
||||||
suffix,
|
|
||||||
)
|
|
||||||
return self._impl_get_display_name(dyn_name,
|
|
||||||
suffix,
|
|
||||||
)
|
|
||||||
|
|
||||||
def impl_get_display_name(self) -> str:
|
|
||||||
"""get display name
|
"""get display name
|
||||||
"""
|
"""
|
||||||
return self._get_display_name(None,
|
if dynopt is None:
|
||||||
None,
|
dynopt = self
|
||||||
)
|
if hasattr(self, '_display_name_function'):
|
||||||
|
return self._display_name_function(dynopt)
|
||||||
|
name = self.impl_get_information('doc', None)
|
||||||
|
if name is None or name == '':
|
||||||
|
name = dynopt.impl_getname()
|
||||||
|
return name
|
||||||
|
|
||||||
def reset_cache(self,
|
def reset_cache(self,
|
||||||
path: str,
|
path: str,
|
||||||
|
|
|
@ -225,13 +225,10 @@ class OptionDescriptionWalk(CacheOptionDescription):
|
||||||
for child in self._children[1]: # pylint: disable=no-member
|
for child in self._children[1]: # pylint: disable=no-member
|
||||||
if not child.impl_is_dynoptiondescription():
|
if not child.impl_is_dynoptiondescription():
|
||||||
continue
|
continue
|
||||||
cname = child.impl_getname()
|
|
||||||
if not name.startswith(cname):
|
|
||||||
continue
|
|
||||||
for suffix in child.get_suffixes(config_bag,
|
for suffix in child.get_suffixes(config_bag,
|
||||||
dynoption,
|
dynoption,
|
||||||
):
|
):
|
||||||
if name != cname + child.convert_suffix_to_path(suffix):
|
if name != child.impl_getname(suffix):
|
||||||
continue
|
continue
|
||||||
return child.to_dynoption(subpath,
|
return child.to_dynoption(subpath,
|
||||||
suffix,
|
suffix,
|
||||||
|
@ -242,7 +239,7 @@ class OptionDescriptionWalk(CacheOptionDescription):
|
||||||
'in root optiondescription'
|
'in root optiondescription'
|
||||||
))
|
))
|
||||||
raise AttributeError(_(f'unknown option "{name}" '
|
raise AttributeError(_(f'unknown option "{name}" '
|
||||||
f'in optiondescription "{self.impl_get_display_name()}"'
|
f'in optiondescription "{self_opt.impl_get_display_name()}"'
|
||||||
))
|
))
|
||||||
|
|
||||||
def get_children(self,
|
def get_children(self,
|
||||||
|
|
|
@ -58,10 +58,7 @@ class SynDynOption:
|
||||||
def impl_get_display_name(self) -> str:
|
def impl_get_display_name(self) -> str:
|
||||||
"""get option display name
|
"""get option display name
|
||||||
"""
|
"""
|
||||||
suffix = self.dyn_parent.getsubdyn().convert_suffix_to_path(self.suffix)
|
return self.opt.impl_get_display_name(self)
|
||||||
return self.opt._get_display_name(dyn_name=self.impl_getname(), # pylint: disable=protected-access
|
|
||||||
suffix=suffix,
|
|
||||||
)
|
|
||||||
|
|
||||||
def impl_getsuffix(self) -> str:
|
def impl_getsuffix(self) -> str:
|
||||||
"""get suffix
|
"""get suffix
|
||||||
|
|
|
@ -81,7 +81,7 @@ class SubDynOptionDescription:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def impl_get_display_name(self) -> str:
|
def impl_get_display_name(self) -> str:
|
||||||
return self.opt.impl_get_display_name()
|
return self.opt.impl_get_display_name(self)
|
||||||
|
|
||||||
def impl_is_dynoptiondescription(self) -> bool:
|
def impl_is_dynoptiondescription(self) -> bool:
|
||||||
return True
|
return True
|
||||||
|
@ -131,8 +131,7 @@ class SynDynOptionDescription:
|
||||||
def impl_get_display_name(self) -> str:
|
def impl_get_display_name(self) -> str:
|
||||||
"""get display name
|
"""get display name
|
||||||
"""
|
"""
|
||||||
if self.opt.impl_is_dynoptiondescription():
|
return self.opt.impl_get_display_name(self)
|
||||||
return self.opt.impl_get_display_name() + str(self._suffix)
|
|
||||||
|
|
||||||
def get_children(self,
|
def get_children(self,
|
||||||
config_bag: ConfigBag,
|
config_bag: ConfigBag,
|
||||||
|
|
Loading…
Reference in a new issue