nutree


Namenutree JSON
Version 0.11.1 PyPI version JSON
download
home_pagehttps://github.com/mar10/nutree/
SummaryA Python library for tree data structures with an intuitive, yet powerful, API.
upload_time2024-11-08 15:53:27
maintainerMartin Wendt
docs_urlNone
authorMartin Wendt
requires_pythonNone
licenseMIT
keywords tree data structure digraph graph nodes hierarchy treelib
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # ![logo](https://raw.githubusercontent.com/mar10/nutree/main/docs/nutree_48x48.png) nutree

[![Latest Version](https://img.shields.io/pypi/v/nutree.svg)](https://pypi.python.org/pypi/nutree/)
[![Tests](https://github.com/mar10/nutree/actions/workflows/tests.yml/badge.svg)](https://github.com/mar10/nutree/actions/workflows/tests.yml)
[![codecov](https://codecov.io/github/mar10/nutree/branch/main/graph/badge.svg?token=9xmAFm8Icl)](https://codecov.io/github/mar10/nutree)
[![License](https://img.shields.io/pypi/l/nutree.svg)](https://github.com/mar10/nutree/blob/main/LICENSE.txt)
[![Documentation Status](https://readthedocs.org/projects/nutree/badge/?version=latest)](http://nutree.readthedocs.io/)
[![Released with: Yabs](https://img.shields.io/badge/released%20with-yabs-yellowgreen)](https://github.com/mar10/yabs)
[![StackOverflow: nutree](https://img.shields.io/badge/StackOverflow-nutree-blue.svg)](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>

**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/a5/6b/5fc5acbf494558094017594a71978eb05381b66a3a3032989ffd737effcc/nutree-0.11.1.tar.gz",
    "platform": null,
    "description": "# ![logo](https://raw.githubusercontent.com/mar10/nutree/main/docs/nutree_48x48.png) nutree\n\n[![Latest Version](https://img.shields.io/pypi/v/nutree.svg)](https://pypi.python.org/pypi/nutree/)\n[![Tests](https://github.com/mar10/nutree/actions/workflows/tests.yml/badge.svg)](https://github.com/mar10/nutree/actions/workflows/tests.yml)\n[![codecov](https://codecov.io/github/mar10/nutree/branch/main/graph/badge.svg?token=9xmAFm8Icl)](https://codecov.io/github/mar10/nutree)\n[![License](https://img.shields.io/pypi/l/nutree.svg)](https://github.com/mar10/nutree/blob/main/LICENSE.txt)\n[![Documentation Status](https://readthedocs.org/projects/nutree/badge/?version=latest)](http://nutree.readthedocs.io/)\n[![Released with: Yabs](https://img.shields.io/badge/released%20with-yabs-yellowgreen)](https://github.com/mar10/yabs)\n[![StackOverflow: nutree](https://img.shields.io/badge/StackOverflow-nutree-blue.svg)](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>\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": "0.11.1",
    "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": "4131bca11b9903065bfb723e1f3285fece066bd53e83b12a64cd316723ef8e30",
                "md5": "da629404eb6f79f23c7369787ed84422",
                "sha256": "9d5d240faa29d3ef8367b15ea69f047f40521122f9940360a12d1f70e9e5241b"
            },
            "downloads": -1,
            "filename": "nutree-0.11.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "da629404eb6f79f23c7369787ed84422",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 53988,
            "upload_time": "2024-11-08T15:53:30",
            "upload_time_iso_8601": "2024-11-08T15:53:30.354936Z",
            "url": "https://files.pythonhosted.org/packages/41/31/bca11b9903065bfb723e1f3285fece066bd53e83b12a64cd316723ef8e30/nutree-0.11.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a56b5fc5acbf494558094017594a71978eb05381b66a3a3032989ffd737effcc",
                "md5": "487859ab3534a8f9325eb1d3a84525eb",
                "sha256": "c29dacc977263d3d7ff18e24c1cab71fffe660a487d9283013d3cb9fe71d2d78"
            },
            "downloads": -1,
            "filename": "nutree-0.11.1.tar.gz",
            "has_sig": false,
            "md5_digest": "487859ab3534a8f9325eb1d3a84525eb",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 72195,
            "upload_time": "2024-11-08T15:53:27",
            "upload_time_iso_8601": "2024-11-08T15:53:27.883909Z",
            "url": "https://files.pythonhosted.org/packages/a5/6b/5fc5acbf494558094017594a71978eb05381b66a3a3032989ffd737effcc/nutree-0.11.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-08 15:53:27",
    "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"
}
        
Elapsed time: 0.45532s