StringTree.value(): Add keyword-argument default

Add argument default to StringTree.value(), defaulting to None, doing
the obvious.

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2025-01-16 10:53:09 +01:00
commit 57ff96608b

View file

@ -171,10 +171,12 @@ class StringTree: # export
relpath = '.'.join(components[1:])
return self.children[name].get(relpath)
def value(self, path = None) -> Optional[str]:
def value(self, path = None, default=None) -> Optional[str]:
if path:
child = self.get(path)
if child is None:
if default:
return default
return None
return child.value()
if len(self.children) == 0: