mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-python
synced 2026-01-15 09:53:32 +01:00
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:
parent
381514ab2c
commit
57ff96608b
1 changed files with 3 additions and 1 deletions
|
|
@ -171,10 +171,12 @@ class StringTree: # export
|
||||||
relpath = '.'.join(components[1:])
|
relpath = '.'.join(components[1:])
|
||||||
return self.children[name].get(relpath)
|
return self.children[name].get(relpath)
|
||||||
|
|
||||||
def value(self, path = None) -> Optional[str]:
|
def value(self, path = None, default=None) -> Optional[str]:
|
||||||
if path:
|
if path:
|
||||||
child = self.get(path)
|
child = self.get(path)
|
||||||
if child is None:
|
if child is None:
|
||||||
|
if default:
|
||||||
|
return default
|
||||||
return None
|
return None
|
||||||
return child.value()
|
return child.value()
|
||||||
if len(self.children) == 0:
|
if len(self.children) == 0:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue