StringTree.__getitem__(): Return value child

StringTree.__getitem__() returned the node, now return its value
child instead. That's nicer and closer to the expected behaviour, as
it supports StringTree usage as a key-value store for configuration
or so. It breaks the existing API, but I think I have fixed the only
pace where it was used: jw-grammar/grammar.py.

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2020-04-05 14:23:59 +02:00
commit fb6b205440

View file

@ -113,7 +113,7 @@ class StringTree: # export
r = self.get(path) r = self.get(path)
if r is None: if r is None:
raise KeyError(path) raise KeyError(path)
return r return r.value()
def __setitem__(self, key, value): def __setitem__(self, key, value):
return self.__set(key, value) return self.__set(key, value)