#  nutree
[](https://pypi.python.org/pypi/nutree/)
[](https://github.com/mar10/nutree/actions/workflows/tests.yml)
[](https://codecov.io/github/mar10/nutree)
[](https://github.com/mar10/nutree/blob/main/LICENSE.txt)
[](http://nutree.readthedocs.io/)
[](https://github.com/mar10/yabs)
[](https://stackoverflow.com/questions/tagged/nutree)
> _Nutree_ is a Python library for tree data structures with an intuitive,
> yet powerful, API.
**Nutree Facts**
Handle multiple references of single objects ('clones') <br>
Search by name pattern, id, or object reference <br>
Compare two trees and calculate patches <br>
Unobtrusive handling of arbitrary objects <br>
Save as DOT file and graphwiz diagram <br>
Nodes can be plain strings or objects <br>
(De)Serialize to (compressed) JSON <br>
Save as Mermaid flow diagram <br>
Different traversal methods <br>
Generate random trees <br>
Convert to RDF graph <br>
Fully type annotated <br>
Typed child nodes <br>
Pretty print <br>
Navigation <br>
Filtering <br>
Fast <br>
**Example**
A simple tree, with text nodes
```py
from nutree import Tree, Node
tree = Tree("Store")
n = tree.add("Records")
n.add("Let It Be")
n.add("Get Yer Ya-Ya's Out!")
n = tree.add("Books")
n.add("The Little Prince")
tree.print()
```
```ascii
Tree<'Store'>
├─── 'Records'
│ ├─── 'Let It Be'
│ ╰─── "Get Yer Ya-Ya's Out!"
╰─── 'Books'
╰─── 'The Little Prince'
```
Tree nodes wrap the data and also expose methods for navigation, searching,
iteration, ...
```py
records_node = tree["Records"]
assert isinstance(records_node, Node)
assert records_node.name == "Records"
print(records_node.first_child())
```
```ascii
Node<'Let It Be', data_id=510268653885439170>
```
Nodes may be strings or arbitrary objects:
```py
alice = Person("Alice", age=23, guid="{123-456}")
tree.add(alice)
# Lookup nodes by object, data_id, name pattern, ...
assert isinstance(tree[alice].data, Person)
del tree[alice]
```
[Read the Docs](https://nutree.readthedocs.io/) for more.
Raw data
{
"_id": null,
"home_page": "https://github.com/mar10/nutree/",
"name": "nutree",
"maintainer": "Martin Wendt",
"docs_url": null,
"requires_python": null,
"maintainer_email": "nutree@wwwendt.de",
"keywords": "tree, data structure, digraph, graph, nodes, hierarchy, treelib",
"author": "Martin Wendt",
"author_email": "nutree@wwwendt.de",
"download_url": "https://files.pythonhosted.org/packages/83/87/07875cd330ff1ce165858ec61ff68607d86dfcb7825c932f60045fa79a23/nutree-1.1.0.tar.gz",
"platform": null,
"description": "#  nutree\n\n[](https://pypi.python.org/pypi/nutree/)\n[](https://github.com/mar10/nutree/actions/workflows/tests.yml)\n[](https://codecov.io/github/mar10/nutree)\n[](https://github.com/mar10/nutree/blob/main/LICENSE.txt)\n[](http://nutree.readthedocs.io/)\n[](https://github.com/mar10/yabs)\n[](https://stackoverflow.com/questions/tagged/nutree)\n\n> _Nutree_ is a Python library for tree data structures with an intuitive,\n> yet powerful, API.\n\n**Nutree Facts**\n\nHandle multiple references of single objects ('clones') <br>\nSearch by name pattern, id, or object reference <br>\nCompare two trees and calculate patches <br>\nUnobtrusive handling of arbitrary objects <br>\nSave as DOT file and graphwiz diagram <br>\nNodes can be plain strings or objects <br>\n(De)Serialize to (compressed) JSON <br>\nSave as Mermaid flow diagram <br>\nDifferent traversal methods <br>\nGenerate random trees <br>\nConvert to RDF graph <br>\nFully type annotated <br>\nTyped child nodes <br>\nPretty print <br>\nNavigation <br>\nFiltering <br>\nFast <br>\n\n**Example**\n\nA simple tree, with text nodes\n\n```py\nfrom nutree import Tree, Node\n\ntree = Tree(\"Store\")\n\nn = tree.add(\"Records\")\n\nn.add(\"Let It Be\")\nn.add(\"Get Yer Ya-Ya's Out!\")\n\nn = tree.add(\"Books\")\nn.add(\"The Little Prince\")\n\ntree.print()\n```\n\n```ascii\nTree<'Store'>\n\u251c\u2500\u2500\u2500 'Records'\n\u2502 \u251c\u2500\u2500\u2500 'Let It Be'\n\u2502 \u2570\u2500\u2500\u2500 \"Get Yer Ya-Ya's Out!\"\n\u2570\u2500\u2500\u2500 'Books'\n \u2570\u2500\u2500\u2500 'The Little Prince'\n```\n\nTree nodes wrap the data and also expose methods for navigation, searching,\niteration, ...\n\n```py\nrecords_node = tree[\"Records\"]\nassert isinstance(records_node, Node)\nassert records_node.name == \"Records\"\n\nprint(records_node.first_child())\n```\n\n```ascii\nNode<'Let It Be', data_id=510268653885439170>\n```\n\nNodes may be strings or arbitrary objects:\n\n```py\nalice = Person(\"Alice\", age=23, guid=\"{123-456}\")\ntree.add(alice)\n\n# Lookup nodes by object, data_id, name pattern, ...\nassert isinstance(tree[alice].data, Person)\n\ndel tree[alice]\n```\n\n[Read the Docs](https://nutree.readthedocs.io/) for more.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A Python library for tree data structures with an intuitive, yet powerful, API.",
"version": "1.1.0",
"project_urls": {
"Bug Tracker": "https://github.com/mar10/nutree/issues",
"Documentation": "https://nutree.readthedocs.io/",
"Download": "https://github.com/mar10/nutree/releases/latest",
"Homepage": "https://github.com/mar10/nutree/",
"Source Code": "https://github.com/mar10/nutree"
},
"split_keywords": [
"tree",
" data structure",
" digraph",
" graph",
" nodes",
" hierarchy",
" treelib"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "dd107b0114ea12291ceb7d4eed77914cc43351e847e3b014f337deb65049c89d",
"md5": "e0d21ff803de2743bf7e8a2adaba8b4e",
"sha256": "66d2333439bc003d89a8d2f4a84ab628f964c17da72dfa25222eea9f50effa7c"
},
"downloads": -1,
"filename": "nutree-1.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e0d21ff803de2743bf7e8a2adaba8b4e",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 54497,
"upload_time": "2025-02-09T17:08:14",
"upload_time_iso_8601": "2025-02-09T17:08:14.392916Z",
"url": "https://files.pythonhosted.org/packages/dd/10/7b0114ea12291ceb7d4eed77914cc43351e847e3b014f337deb65049c89d/nutree-1.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "838707875cd330ff1ce165858ec61ff68607d86dfcb7825c932f60045fa79a23",
"md5": "c140fc51dce8372b309c804a6efa06ed",
"sha256": "98182a5f744235977e6ab4aa290c660bb3c2dafc37d3bc2da1cfd84872a8483d"
},
"downloads": -1,
"filename": "nutree-1.1.0.tar.gz",
"has_sig": false,
"md5_digest": "c140fc51dce8372b309c804a6efa06ed",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 72906,
"upload_time": "2025-02-09T17:08:12",
"upload_time_iso_8601": "2025-02-09T17:08:12.494870Z",
"url": "https://files.pythonhosted.org/packages/83/87/07875cd330ff1ce165858ec61ff68607d86dfcb7825c932f60045fa79a23/nutree-1.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-02-09 17:08:12",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "mar10",
"github_project": "nutree",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "nutree"
}