do not get value for an dynoptiondescript
This commit is contained in:
parent
d6f1564744
commit
49ba56b6ec
3 changed files with 43 additions and 21 deletions
|
@ -133,6 +133,8 @@ async def test_unknown_dyndescription():
|
|||
await cfg.option('od.dodval1.novalue').value.get()
|
||||
with pytest.raises(AttributeError):
|
||||
await cfg.option('od.dodval1.stnoval1').value.get()
|
||||
with pytest.raises(AttributeError):
|
||||
await cfg.option('od.dod.st').value.get()
|
||||
assert not await list_sessions()
|
||||
|
||||
|
||||
|
|
|
@ -95,7 +95,8 @@ class SubConfig:
|
|||
context = self.cfgimpl_get_context()
|
||||
path = option_bag.option.impl_getopt().impl_getpath()
|
||||
subconfig, _ = await context.cfgimpl_get_home_by_path(path,
|
||||
option_bag.config_bag)
|
||||
option_bag.config_bag,
|
||||
)
|
||||
return subconfig.cfgimpl_get_length()
|
||||
else:
|
||||
return self.cfgimpl_get_length()
|
||||
|
@ -200,20 +201,24 @@ class SubConfig:
|
|||
async def cfgimpl_get_home_by_path(self,
|
||||
path: str,
|
||||
config_bag: ConfigBag,
|
||||
validate_properties=True) -> ('Subconfig', str):
|
||||
validate_properties=True,
|
||||
) -> ('Subconfig', str):
|
||||
""":returns: tuple (config, name)"""
|
||||
path = path.split('.')
|
||||
for step in path[:-1]:
|
||||
option_bag = OptionBag()
|
||||
option = await self.cfgimpl_get_description().get_child(step,
|
||||
config_bag,
|
||||
self.cfgimpl_get_path())
|
||||
self.cfgimpl_get_path(),
|
||||
)
|
||||
option_bag.set_option(option,
|
||||
None,
|
||||
config_bag)
|
||||
config_bag,
|
||||
)
|
||||
option_bag.properties = await self.cfgimpl_get_settings().getproperties(option_bag)
|
||||
self = await self.get_subconfig(option_bag,
|
||||
validate_properties)
|
||||
validate_properties,
|
||||
)
|
||||
assert isinstance(self, SubConfig), _('unknown option {}').format(path[-1])
|
||||
return self, path[-1]
|
||||
|
||||
|
@ -286,7 +291,8 @@ class SubConfig:
|
|||
config_bag = option_bag.config_bag
|
||||
if '.' in name:
|
||||
self, name = await self.cfgimpl_get_home_by_path(name,
|
||||
config_bag)
|
||||
config_bag,
|
||||
)
|
||||
|
||||
option = option_bag.option
|
||||
if option.impl_is_symlinkoption():
|
||||
|
@ -392,7 +398,8 @@ class SubConfig:
|
|||
try:
|
||||
if '.' in path:
|
||||
subconfig, subpath = await context.cfgimpl_get_home_by_path(path,
|
||||
config_bag)
|
||||
config_bag,
|
||||
)
|
||||
else:
|
||||
subconfig = self
|
||||
subpath = path
|
||||
|
@ -891,7 +898,8 @@ class KernelGroupConfig(_CommonConfig):
|
|||
cconfig_bag.permissives = permissives
|
||||
try:
|
||||
subconfig, name = await child.cfgimpl_get_home_by_path(path,
|
||||
cconfig_bag)
|
||||
cconfig_bag,
|
||||
)
|
||||
option = await subconfig.cfgimpl_get_description().get_child(name,
|
||||
cconfig_bag,
|
||||
child.cfgimpl_get_path())
|
||||
|
@ -988,7 +996,8 @@ class KernelGroupConfig(_CommonConfig):
|
|||
config_bag.connection = connection
|
||||
config_bag.remove_validation()
|
||||
subconfig, name = await child.cfgimpl_get_home_by_path(path,
|
||||
config_bag)
|
||||
config_bag,
|
||||
)
|
||||
option = await subconfig.cfgimpl_get_description().get_child(name,
|
||||
config_bag,
|
||||
subconfig.cfgimpl_get_path())
|
||||
|
@ -1079,7 +1088,8 @@ class KernelMixConfig(KernelGroupConfig):
|
|||
only_config=only_config)
|
||||
ret = []
|
||||
subconfig, name = await self.cfgimpl_get_home_by_path(path,
|
||||
config_bag)
|
||||
config_bag,
|
||||
)
|
||||
option = await subconfig.cfgimpl_get_description().get_child(name,
|
||||
config_bag,
|
||||
self.cfgimpl_get_path())
|
||||
|
@ -1103,7 +1113,8 @@ class KernelMixConfig(KernelGroupConfig):
|
|||
cconfig_bag.permissives = permissives
|
||||
try:
|
||||
subconfig2, name = await child.cfgimpl_get_home_by_path(path,
|
||||
cconfig_bag)
|
||||
cconfig_bag,
|
||||
)
|
||||
if self.impl_type == 'meta':
|
||||
moption_bag = option_bag.copy()
|
||||
del moption_bag.properties
|
||||
|
@ -1169,7 +1180,8 @@ class KernelMixConfig(KernelGroupConfig):
|
|||
rconfig_bag.remove_validation()
|
||||
if self.impl_type == 'meta':
|
||||
subconfig, name = await self.cfgimpl_get_home_by_path(path,
|
||||
config_bag)
|
||||
config_bag,
|
||||
)
|
||||
option = await subconfig.cfgimpl_get_description().get_child(name,
|
||||
config_bag,
|
||||
subconfig.cfgimpl_get_path())
|
||||
|
@ -1181,7 +1193,8 @@ class KernelMixConfig(KernelGroupConfig):
|
|||
elif not only_children:
|
||||
try:
|
||||
subconfig, name = await self.cfgimpl_get_home_by_path(path,
|
||||
config_bag)
|
||||
config_bag,
|
||||
)
|
||||
option = await subconfig.cfgimpl_get_description().get_child(name,
|
||||
config_bag,
|
||||
subconfig.cfgimpl_get_path())
|
||||
|
@ -1200,7 +1213,8 @@ class KernelMixConfig(KernelGroupConfig):
|
|||
moption_bag.config_bag = rconfig_bag
|
||||
else:
|
||||
subconfig, name = await child.cfgimpl_get_home_by_path(path,
|
||||
rconfig_bag)
|
||||
rconfig_bag,
|
||||
)
|
||||
option = await subconfig.cfgimpl_get_description().get_child(name,
|
||||
rconfig_bag,
|
||||
child.cfgimpl_get_path())
|
||||
|
|
|
@ -178,10 +178,16 @@ class OptionDescriptionWalk(CacheOptionDescription):
|
|||
async def get_child(self,
|
||||
name: str,
|
||||
config_bag: ConfigBag,
|
||||
subpath: str) -> Union[BaseOption, SynDynOptionDescription]:
|
||||
subpath: str,
|
||||
) -> Union[BaseOption, SynDynOptionDescription]:
|
||||
# if not dyn
|
||||
if name in self._children[0]:
|
||||
return self._children[1][self._children[0].index(name)]
|
||||
option = self._children[1][self._children[0].index(name)]
|
||||
if option.issubdyn():
|
||||
raise AttributeError(_(f'unknown option "{name}" '
|
||||
"in root optiondescription (it's a dynamic option)"
|
||||
))
|
||||
return option
|
||||
# if dyn
|
||||
for child in self._children[1]:
|
||||
if child.impl_is_dynoptiondescription():
|
||||
|
@ -193,13 +199,13 @@ class OptionDescriptionWalk(CacheOptionDescription):
|
|||
suffix,
|
||||
child)
|
||||
if self.impl_get_group_type() == groups.root:
|
||||
raise AttributeError(_('unknown option "{0}" '
|
||||
raise AttributeError(_(f'unknown option "{name}" '
|
||||
'in root optiondescription'
|
||||
'').format(name))
|
||||
))
|
||||
else:
|
||||
raise AttributeError(_('unknown option "{0}" '
|
||||
'in optiondescription "{1}"'
|
||||
'').format(name, self.impl_get_display_name()))
|
||||
raise AttributeError(_(f'unknown option "{name}" '
|
||||
f'in optiondescription "{self.impl_get_display_name()}"'
|
||||
))
|
||||
|
||||
async def get_children(self,
|
||||
config_bag: Union[ConfigBag, Undefined],
|
||||
|
|
Loading…
Reference in a new issue