{ "info": { "author": "Perceval Wajsburt", "author_email": "perceval.wajsburt@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Programming Language :: C", "Programming Language :: Python :: 2.4", "Programming Language :: Python :: 2.5", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.2" ], "description": "Tree printer\n============\n\nThis library provides a tree printer class for easy tree displaying\n\n## Installation \n``` sh\n$ pip install treeprinter\n```\n\n## Basic usage\n\n### Printer instance\n``` python\nfrom treeprinter import TreePrinter\n\nclass Tree(object):\n def __init__(self, tag, children=None):\n self.children = children or []\n self.tag = tag\n\ntree = Tree(\"animal\", [\n Tree(\"cat\"),\n Tree(\"dog\", [Tree(\"chihuahua\"), Tree(\"dalmatian\")]),\n Tree(\"wolf\")])\n\nprinter = TreePrinter('children', 'tag')\nprinter.pprint(tree)\n```\n```\n animal \n | \n --------------------------- \n | | | \n cat dog wolf \n | \n ---------- \n | | \n chihuahua dalmatian \n```\n\n### Printer decorator\nYou could also get the same result by decorating your class like so to implement the \\_\\_str\\_\\_ method\n``` python\n@TreePrinter('children', 'tag')\nclass Tree(object):\n def __init__(self, tag, children=None):\n self.children = children or []\n self.tag = tag\n\nprint(tree)\n```\n\n\n## Extensions\nYou can extend the library by implementing the base displayer\n(see printers/json_printer.py)\n\n``` python\nfrom treeprinter import JsonPrinter\n\nprinter = JsonPrinter()\njson = {\n \"fruits\": [\"Apple\", \"Banana\", \"Pear\"],\n \"presidents\": {\n \"France\": [\"Sarkozy\", \"Hollande\"],\n \"USA\": [\"Trump\", \"Obama\"]\n },\n \"star\": \"Sun\"\n}\nprinter.pprint(json)\n```\n\n```\n {} \n | \n -------------------------------------- \n | | | \n {presidents} [fruits] star \n | | | \n ---------------- -------------- Sun \n | | | | | \n [France] [USA] Apple Banana Pear \n | | \n --------- ------ \n | | | | \n Sarkozy Hollande Trump Obama \n```", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/percevalw/treeprinter", "keywords": null, "license": "MIT License", "maintainer": null, "maintainer_email": null, "name": "treeprinter", "package_url": "https://pypi.org/project/treeprinter/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/treeprinter/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/percevalw/treeprinter" }, "release_url": "https://pypi.org/project/treeprinter/0.0.2/", "requires_dist": null, "requires_python": null, "summary": "Python library for easy tree displaying", "version": "0.0.2" }, "last_serial": 2458427, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "803db9dca53a41c88d080a5c61682edf", "sha256": "35bfcc931d0d267963ea933de368242cb2e19d848da553f912be53e900601643" }, "downloads": -1, "filename": "treeprinter-0.0.1.tar.gz", "has_sig": false, "md5_digest": "803db9dca53a41c88d080a5c61682edf", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6839, "upload_time": "2016-11-13T22:09:01", "url": "https://files.pythonhosted.org/packages/29/da/9c8ce8e9febe30d4d5a2406766df9d4a4f4dc57b123b5cc8562abc822d5e/treeprinter-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "09a1dbe1285f1b254424c68bc9513b43", "sha256": "28c80ab15176ad79a64c9a87641fbe25bc991628bc722f8934ba845b74a422c3" }, "downloads": -1, "filename": "treeprinter-0.0.2.tar.gz", "has_sig": false, "md5_digest": "09a1dbe1285f1b254424c68bc9513b43", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7127, "upload_time": "2016-11-13T22:54:25", "url": "https://files.pythonhosted.org/packages/23/ac/af9d2a7e6f21923ffed0d3d9377dbdb1af4ff5b60fc95451046778767826/treeprinter-0.0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "09a1dbe1285f1b254424c68bc9513b43", "sha256": "28c80ab15176ad79a64c9a87641fbe25bc991628bc722f8934ba845b74a422c3" }, "downloads": -1, "filename": "treeprinter-0.0.2.tar.gz", "has_sig": false, "md5_digest": "09a1dbe1285f1b254424c68bc9513b43", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7127, "upload_time": "2016-11-13T22:54:25", "url": "https://files.pythonhosted.org/packages/23/ac/af9d2a7e6f21923ffed0d3d9377dbdb1af4ff5b60fc95451046778767826/treeprinter-0.0.2.tar.gz" } ] }