From 74902349b6c013139a73fac5b75fa2c377d5c6f3 Mon Sep 17 00:00:00 2001 From: Jan Lindemann Date: Sat, 15 Feb 2025 08:20:53 +0100 Subject: [PATCH] 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 --- tools/python/jwutils/Config.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/python/jwutils/Config.py b/tools/python/jwutils/Config.py index a204d58..64cceb6 100644 --- a/tools/python/jwutils/Config.py +++ b/tools/python/jwutils/Config.py @@ -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)