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')) \
|
||||
from err
|
||||
|
||||
def _impl_get_display_name(self,
|
||||
dyn_name: Base=None,
|
||||
suffix: str=None,
|
||||
def impl_get_display_name(self,
|
||||
dynopt=None,
|
||||
) -> 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
|
||||
"""
|
||||
return self._get_display_name(None,
|
||||
None,
|
||||
)
|
||||
if dynopt is 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,
|
||||
path: str,
|
||||
|
|
|
@ -225,13 +225,10 @@ class OptionDescriptionWalk(CacheOptionDescription):
|
|||
for child in self._children[1]: # pylint: disable=no-member
|
||||
if not child.impl_is_dynoptiondescription():
|
||||
continue
|
||||
cname = child.impl_getname()
|
||||
if not name.startswith(cname):
|
||||
continue
|
||||
for suffix in child.get_suffixes(config_bag,
|
||||
dynoption,
|
||||
):
|
||||
if name != cname + child.convert_suffix_to_path(suffix):
|
||||
if name != child.impl_getname(suffix):
|
||||
continue
|
||||
return child.to_dynoption(subpath,
|
||||
suffix,
|
||||
|
@ -242,7 +239,7 @@ class OptionDescriptionWalk(CacheOptionDescription):
|
|||
'in root optiondescription'
|
||||
))
|
||||
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,
|
||||
|
|
|
@ -58,10 +58,7 @@ class SynDynOption:
|
|||
def impl_get_display_name(self) -> str:
|
||||
"""get option display name
|
||||
"""
|
||||
suffix = self.dyn_parent.getsubdyn().convert_suffix_to_path(self.suffix)
|
||||
return self.opt._get_display_name(dyn_name=self.impl_getname(), # pylint: disable=protected-access
|
||||
suffix=suffix,
|
||||
)
|
||||
return self.opt.impl_get_display_name(self)
|
||||
|
||||
def impl_getsuffix(self) -> str:
|
||||
"""get suffix
|
||||
|
|
|
@ -81,7 +81,7 @@ class SubDynOptionDescription:
|
|||
return True
|
||||
|
||||
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:
|
||||
return True
|
||||
|
@ -131,8 +131,7 @@ class SynDynOptionDescription:
|
|||
def impl_get_display_name(self) -> str:
|
||||
"""get display name
|
||||
"""
|
||||
if self.opt.impl_is_dynoptiondescription():
|
||||
return self.opt.impl_get_display_name() + str(self._suffix)
|
||||
return self.opt.impl_get_display_name(self)
|
||||
|
||||
def get_children(self,
|
||||
config_bag: ConfigBag,
|
||||
|
|
Loading…
Reference in a new issue