Config: Add method entries()

Config has no way to tell if a given path has children, so add the
entries() method.

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2025-02-15 08:20:53 +01:00
commit 74902349b6

View file

@ -107,6 +107,12 @@ class Config(): # export
return item.value()
return default
def entries(self, key: str) -> list[str]:
item = self.__conf.get(key)
if item is None:
return []
return [name for name, child in item.children.items()]
# This is an alias for get()
def value(self, key: str, default = None) -> Optional[str]:
return self.get(key, default)