From dead9d956106295b17e2065b1b6348658d7661e1 Mon Sep 17 00:00:00 2001 From: Jan Lindemann Date: Sat, 4 Apr 2020 11:31:25 +0200 Subject: [PATCH] StringTree: add child_list() Signed-off-by: Jan Lindemann --- tools/python/jwutils/stree/StringTree.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/python/jwutils/stree/StringTree.py b/tools/python/jwutils/stree/StringTree.py index 72a9da4..afb391d 100644 --- a/tools/python/jwutils/stree/StringTree.py +++ b/tools/python/jwutils/stree/StringTree.py @@ -149,6 +149,14 @@ class StringTree: # export return None return self.children[next(reversed(self.children))].content + def child_list(self, depth_first=True): + if depth_first == False: + raise Exception("tried to retrieve child list with breadth-first search, not yet implemented") + r = [] + for c in self.children: + r.append(c) + r.extend(c.to_list()) + def dump(self, prio, *args, **kwargs): caller = kwargs['caller'] if 'caller' in kwargs.keys() else get_caller_pos(1) msg = ''