caesar0301 / treelib

An efficient implementation of tree data structure in python 2/3.
http://treelib.readthedocs.io/en/latest/
Other
806 stars 185 forks source link

Unknown children created from node is created on subtree #56

Closed BebeSparkelSparkel closed 4 years ago

BebeSparkelSparkel commented 8 years ago

from treelib import Tree, Node

tree = Tree() tree.create_node(tag="first", data={}) sub0 = tree.subtree(tree.root)

root_id = sub0.root root_node = sub0.get_node(root_id)

sub0.create_node(tag='second', parent=root_id) sub0.create_node(tag='third', parent=root_id)

tree.show()

Error: /Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5 /Users/williamrusnack/Documents/nesting/test2.py Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/treelib/tree.py", line 109, in getitem return self._nodes[key] KeyError: '8eee35be-f09a-11e5-9ae0-34363b5dfe74'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/Users/williamrusnack/Documents/nesting/test2.py", line 13, in tree.show() File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/treelib/tree.py", line 615, in show key, reverse, line_type, func=write) File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/treelib/tree.py", line 187, in print_backend queue = [self[i] for i in self[nid].fpointer if filter(self[i])] File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/treelib/tree.py", line 187, in queue = [self[i] for i in self[nid].fpointer if filter(self[i])] File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/treelib/tree.py", line 111, in __getitem raise NodeIDAbsentError("Node '%s' is not in the tree" % key) treelib.tree.NodeIDAbsentError: Node '8eee35be-f09a-11e5-9ae0-34363b5dfe74' is not in the tree

Process finished with exit code 1

leonardbinet commented 4 years ago

fixed by https://github.com/caesar0301/treelib/issues/127