From 997f2cedda38ad8e5a804dbbab8336a1377f4349 Mon Sep 17 00:00:00 2001 From: Licini Date: Mon, 29 Apr 2024 18:14:12 +0200 Subject: [PATCH] use list --- src/compas/datastructures/tree/tree.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/compas/datastructures/tree/tree.py b/src/compas/datastructures/tree/tree.py index 4038f69d1c7..27fec5171e8 100644 --- a/src/compas/datastructures/tree/tree.py +++ b/src/compas/datastructures/tree/tree.py @@ -454,7 +454,7 @@ def hierarchy(self, max_depth=None): """ - hierarchy = {"string": ""} + hierarchy = [] def traverse(node, hierarchy, prefix="", last=True, depth=0): @@ -462,14 +462,14 @@ def traverse(node, hierarchy, prefix="", last=True, depth=0): return connector = "└── " if last else "├── " - hierarchy["string"] += "{}{}{}\n".format(prefix, connector, node) + hierarchy.append("{}{}{}".format(prefix, connector, node)) prefix += " " if last else "│ " for i, child in enumerate(node.children): traverse(child, hierarchy, prefix, i == len(node.children) - 1, depth + 1) traverse(self.root, hierarchy) - return hierarchy["string"] + return "\n".join(hierarchy) def to_graph(self, key_mapper=None): """Convert the tree to a graph.