diff --git a/tools/python/jwutils/stree/StringTree.py b/tools/python/jwutils/stree/StringTree.py index c7625fb..66321af 100644 --- a/tools/python/jwutils/stree/StringTree.py +++ b/tools/python/jwutils/stree/StringTree.py @@ -115,7 +115,7 @@ class StringTree: # export r = self.get(path) if r is None: raise KeyError(path) - return r.value() + return r.value() # type: ignore def __setitem__(self, key, value): return self.__set(key, value) @@ -170,7 +170,12 @@ class StringTree: # export relpath = '.'.join(components[1:]) return self.children[name].get(relpath) - def value(self) -> str: + def value(self, path = None) -> Optional[str]: + if path: + child = self.get(path) + if child is None: + return None + return child.value() if len(self.children) == 0: raise Exception('tried to get value from leave "{}"'.format(self.content)) return self.children[next(reversed(self.children))].content # type: ignore