any-tree


Nameany-tree JSON
Version 0.0.2 PyPI version JSON
download
home_pagehttp://any-tree.readthedocs.io
SummaryAny Python Tree Data
upload_time2016-08-26 23:47:57
maintainer
docs_urlNone
authorc0fec0de
requires_python
licenseGPL
keywords tree data treelib
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            Getting started
===============

.. _getting_started:

Construction
~~~~~~~~~~~~

>>> from tree import Node, RenderTree
>>> udo = Node("Udo")
>>> marc = Node("Marc", parent=udo)
>>> lian = Node("Lian", parent=marc)
>>> dan = Node("Dan", parent=udo)
>>> jet = Node("Jet", parent=dan)
>>> jan = Node("Jan", parent=dan)
>>> joe = Node("Joe", parent=dan)

Node
~~~~

>>> print(udo)
Node('Udo')
>>> print(joe)
Node('Udo/Dan/Joe')

Tree
~~~~

>>> for pre, node in RenderTree(udo):
...     print("%s%s" % (pre, node.name))
Udo
├── Marc
│   └── Lian
└── Dan
    ├── Jet
    ├── Jan
    └── Joe

Manipulation
~~~~~~~~~~~~

A second tree:

>>> mary = Node("Mary")
>>> urs = Node("Urs", parent=mary)
>>> chris = Node("Chris", parent=mary)
>>> marta = Node("Marta", parent=mary)
>>> print(RenderTree(mary))
Node('Mary')
├── Node('Mary/Urs')
├── Node('Mary/Chris')
└── Node('Mary/Marta')

Append:

>>> udo.parent = mary
>>> print(RenderTree(mary))
Node('Mary')
├── Node('Mary/Urs')
├── Node('Mary/Chris')
├── Node('Mary/Marta')
└── Node('Mary/Udo')
    ├── Node('Mary/Udo/Marc')
    │   └── Node('Mary/Udo/Marc/Lian')
    └── Node('Mary/Udo/Dan')
        ├── Node('Mary/Udo/Dan/Jet')
        ├── Node('Mary/Udo/Dan/Jan')
        └── Node('Mary/Udo/Dan/Joe')

Subtree rendering:

>>> print(RenderTree(marc))
Node('Mary/Udo/Marc')
└── Node('Mary/Udo/Marc/Lian')

Cut:

>>> dan.parent = None
>>> print(RenderTree(dan))
Node('Dan')
├── Node('Dan/Jet')
├── Node('Dan/Jan')
└── Node('Dan/Joe')

.. _Tree: https://en.wikipedia.org/wiki/Tree_(data_structure)

Installation
============

To install the `tree` module run:

    pip install any-tree

If you do not have write-permissions to the python installation, try:

    pip install any-tree --user
            

Raw data

            {
    "_id": null,
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "cheesecake_code_kwalitee_id": null,
    "keywords": "tree data,treelib,",
    "upload_time": "2016-08-26 23:47:57",
    "author": "c0fec0de",
    "home_page": "http://any-tree.readthedocs.io",
    "download_url": "https://pypi.python.org/packages/d2/9a/19132cf0ac7ea70b584775296bf32b7525cb04a6d5d94ff584c8dd530299/any-tree-0.0.2.tar.gz",
    "platform": "UNKNOWN",
    "version": "0.0.2",
    "cheesecake_documentation_id": null,
    "description": "Getting started\n===============\n\n.. _getting_started:\n\nConstruction\n~~~~~~~~~~~~\n\n>>> from tree import Node, RenderTree\n>>> udo = Node(\"Udo\")\n>>> marc = Node(\"Marc\", parent=udo)\n>>> lian = Node(\"Lian\", parent=marc)\n>>> dan = Node(\"Dan\", parent=udo)\n>>> jet = Node(\"Jet\", parent=dan)\n>>> jan = Node(\"Jan\", parent=dan)\n>>> joe = Node(\"Joe\", parent=dan)\n\nNode\n~~~~\n\n>>> print(udo)\nNode('Udo')\n>>> print(joe)\nNode('Udo/Dan/Joe')\n\nTree\n~~~~\n\n>>> for pre, node in RenderTree(udo):\n...     print(\"%s%s\" % (pre, node.name))\nUdo\n\u251c\u2500\u2500 Marc\n\u2502   \u2514\u2500\u2500 Lian\n\u2514\u2500\u2500 Dan\n    \u251c\u2500\u2500 Jet\n    \u251c\u2500\u2500 Jan\n    \u2514\u2500\u2500 Joe\n\nManipulation\n~~~~~~~~~~~~\n\nA second tree:\n\n>>> mary = Node(\"Mary\")\n>>> urs = Node(\"Urs\", parent=mary)\n>>> chris = Node(\"Chris\", parent=mary)\n>>> marta = Node(\"Marta\", parent=mary)\n>>> print(RenderTree(mary))\nNode('Mary')\n\u251c\u2500\u2500 Node('Mary/Urs')\n\u251c\u2500\u2500 Node('Mary/Chris')\n\u2514\u2500\u2500 Node('Mary/Marta')\n\nAppend:\n\n>>> udo.parent = mary\n>>> print(RenderTree(mary))\nNode('Mary')\n\u251c\u2500\u2500 Node('Mary/Urs')\n\u251c\u2500\u2500 Node('Mary/Chris')\n\u251c\u2500\u2500 Node('Mary/Marta')\n\u2514\u2500\u2500 Node('Mary/Udo')\n    \u251c\u2500\u2500 Node('Mary/Udo/Marc')\n    \u2502   \u2514\u2500\u2500 Node('Mary/Udo/Marc/Lian')\n    \u2514\u2500\u2500 Node('Mary/Udo/Dan')\n        \u251c\u2500\u2500 Node('Mary/Udo/Dan/Jet')\n        \u251c\u2500\u2500 Node('Mary/Udo/Dan/Jan')\n        \u2514\u2500\u2500 Node('Mary/Udo/Dan/Joe')\n\nSubtree rendering:\n\n>>> print(RenderTree(marc))\nNode('Mary/Udo/Marc')\n\u2514\u2500\u2500 Node('Mary/Udo/Marc/Lian')\n\nCut:\n\n>>> dan.parent = None\n>>> print(RenderTree(dan))\nNode('Dan')\n\u251c\u2500\u2500 Node('Dan/Jet')\n\u251c\u2500\u2500 Node('Dan/Jan')\n\u2514\u2500\u2500 Node('Dan/Joe')\n\n.. _Tree: https://en.wikipedia.org/wiki/Tree_(data_structure)\n\nInstallation\n============\n\nTo install the `tree` module run:\n\n    pip install any-tree\n\nIf you do not have write-permissions to the python installation, try:\n\n    pip install any-tree --user",
    "lcname": "any-tree",
    "name": "any-tree",
    "github": false,
    "bugtrack_url": null,
    "license": "GPL",
    "summary": "Any Python Tree Data",
    "split_keywords": [
        "tree data",
        "treelib",
        ""
    ],
    "author_email": "c0fec0de@gmail.com",
    "urls": [
        {
            "has_sig": false,
            "upload_time": "2016-08-26T23:47:57",
            "comment_text": "",
            "python_version": "source",
            "url": "https://pypi.python.org/packages/d2/9a/19132cf0ac7ea70b584775296bf32b7525cb04a6d5d94ff584c8dd530299/any-tree-0.0.2.tar.gz",
            "md5_digest": "57d74cbc19ef3856acf3d0369556df6e",
            "downloads": 0,
            "filename": "any-tree-0.0.2.tar.gz",
            "packagetype": "sdist",
            "path": "d2/9a/19132cf0ac7ea70b584775296bf32b7525cb04a6d5d94ff584c8dd530299/any-tree-0.0.2.tar.gz",
            "size": 5916
        }
    ],
    "cheesecake_installability_id": null
}
        
Elapsed time: 0.02965s