nutree


Namenutree JSON
Version 0.6.0 PyPI version JSON
download
home_pagehttps://github.com/mar10/nutree/
SummaryA Python library for tree data structures with an intuitive, yet powerful, API.
upload_time2023-10-31 08:44:09
maintainerMartin Wendt
docs_urlNone
authorMartin Wendt
requires_python
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

[![Tests](https://github.com/mar10/nutree/actions/workflows/tests.yml/badge.svg)](https://github.com/mar10/nutree/actions/workflows/tests.yml)
[![Latest Version](https://img.shields.io/pypi/v/nutree.svg)](https://pypi.python.org/pypi/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/)
[![codecov](https://codecov.io/github/mar10/nutree/branch/main/graph/badge.svg?token=9xmAFm8Icl)](https://codecov.io/github/mar10/nutree)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)
[![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>
Unobtrusive handling of arbitrary objects <br>
Compare two trees and calculate patches <br>
Save as DOT file and graphwiz diagram <br>
Nodes can be plain strings or objects <br>
Different traversal methods <br>
(De)Serialize to JSON <br>
Fully type annotated <br>
Convert to RDF graph <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": "",
    "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/e0/44/d7e8acb7c3c20dd020a1004cb172bd7ac89bf65c73de2a7e653c37ea0e48/nutree-0.6.0.tar.gz",
    "platform": null,
    "description": "# ![logo](https://raw.githubusercontent.com/mar10/nutree/main/docs/nutree_48x48.png) nutree\n\n[![Tests](https://github.com/mar10/nutree/actions/workflows/tests.yml/badge.svg)](https://github.com/mar10/nutree/actions/workflows/tests.yml)\n[![Latest Version](https://img.shields.io/pypi/v/nutree.svg)](https://pypi.python.org/pypi/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[![codecov](https://codecov.io/github/mar10/nutree/branch/main/graph/badge.svg?token=9xmAFm8Icl)](https://codecov.io/github/mar10/nutree)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)\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,\nyet powerful, API.\n\n**Nutree Facts**\n\nHandle multiple references of single objects ('clones') <br>\nSearch by name pattern, id, or object reference <br>\nUnobtrusive handling of arbitrary objects <br>\nCompare two trees and calculate patches <br>\nSave as DOT file and graphwiz diagram <br>\nNodes can be plain strings or objects <br>\nDifferent traversal methods <br>\n(De)Serialize to JSON <br>\nFully type annotated <br>\nConvert to RDF graph <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.6.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": "57131cc576757459823d4d956cf4bea234449b703986746d1d218bd5342f552a",
                "md5": "9eb8532adce94f77f9581d48d6a38429",
                "sha256": "d155585e97210ae4ce7faedfd9f6a2717c7548583f76f7b91fc12838c55c5fcc"
            },
            "downloads": -1,
            "filename": "nutree-0.6.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9eb8532adce94f77f9581d48d6a38429",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 38570,
            "upload_time": "2023-10-31T08:44:07",
            "upload_time_iso_8601": "2023-10-31T08:44:07.783828Z",
            "url": "https://files.pythonhosted.org/packages/57/13/1cc576757459823d4d956cf4bea234449b703986746d1d218bd5342f552a/nutree-0.6.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e044d7e8acb7c3c20dd020a1004cb172bd7ac89bf65c73de2a7e653c37ea0e48",
                "md5": "4f022e88877ccbc5a3a212665f4f4ba3",
                "sha256": "59ce815fded85be28d48d27e22a3230fd9771b45da8935cf5bc338c2cf3c08d8"
            },
            "downloads": -1,
            "filename": "nutree-0.6.0.tar.gz",
            "has_sig": false,
            "md5_digest": "4f022e88877ccbc5a3a212665f4f4ba3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 45823,
            "upload_time": "2023-10-31T08:44:09",
            "upload_time_iso_8601": "2023-10-31T08:44:09.785613Z",
            "url": "https://files.pythonhosted.org/packages/e0/44/d7e8acb7c3c20dd020a1004cb172bd7ac89bf65c73de2a7e653c37ea0e48/nutree-0.6.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-10-31 08:44:09",
    "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.20113s