mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-python
synced 2026-01-15 01:52:56 +01:00
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:
parent
79a3696eaa
commit
74902349b6
1 changed files with 6 additions and 0 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue