You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

159 lines
4.1 KiB

4 years ago
  1. Metadata-Version: 2.1
  2. Name: anytree
  3. Version: 2.4.3
  4. Summary: Powerful and Lightweight Python Tree Data Structure..
  5. Home-page: https://github.com/c0fec0de/anytree
  6. Author: c0fec0de
  7. Author-email: c0fec0de@gmail.com
  8. License: Apache 2.0
  9. Keywords: tree,tree data,treelib,tree walk,tree structure
  10. Platform: UNKNOWN
  11. Classifier: Development Status :: 5 - Production/Stable
  12. Classifier: Programming Language :: Python :: 2
  13. Classifier: Programming Language :: Python :: 2.6
  14. Classifier: Programming Language :: Python :: 2.7
  15. Classifier: Programming Language :: Python :: 3
  16. Classifier: Programming Language :: Python :: 3.4
  17. Classifier: Programming Language :: Python :: 3.5
  18. Classifier: Programming Language :: Python :: 3.6
  19. Requires-Dist: six (>=1.9.0)
  20. Provides-Extra: dev
  21. Requires-Dist: check-manifest ; extra == 'dev'
  22. Provides-Extra: test
  23. Requires-Dist: coverage ; extra == 'test'
  24. .. image:: https://badge.fury.io/py/anytree.svg
  25. :target: https://badge.fury.io/py/anytree
  26. .. image:: https://travis-ci.org/c0fec0de/anytree.svg?branch=master
  27. :target: https://travis-ci.org/c0fec0de/anytree
  28. .. image:: https://coveralls.io/repos/github/c0fec0de/anytree/badge.svg
  29. :target: https://coveralls.io/github/c0fec0de/anytree
  30. .. image:: https://readthedocs.org/projects/anytree/badge/?version=2.4.3
  31. :target: http://anytree.readthedocs.io/en/2.4.3/?badge=2.4.3
  32. .. image:: https://codeclimate.com/github/c0fec0de/anytree.png
  33. :target: https://codeclimate.com/github/c0fec0de/anytree
  34. .. image:: https://img.shields.io/pypi/pyversions/anytree.svg
  35. :target: https://pypi.python.org/pypi/anytree
  36. .. image:: https://landscape.io/github/c0fec0de/anytree/master/landscape.svg?style=flat
  37. :target: https://landscape.io/github/c0fec0de/anytree/master
  38. .. image:: https://img.shields.io/badge/code%20style-pep8-brightgreen.svg
  39. :target: https://www.python.org/dev/peps/pep-0008/
  40. .. image:: https://img.shields.io/badge/code%20style-pep257-brightgreen.svg
  41. :target: https://www.python.org/dev/peps/pep-0257/
  42. Documentation
  43. =============
  44. The Documentation_ is hosted on http://anytree.readthedocs.io/en/2.4.3/
  45. .. _Documentation: http://anytree.readthedocs.io/en/2.4.3/
  46. Getting started
  47. ===============
  48. .. _getting_started:
  49. Usage is simple.
  50. **Construction**
  51. >>> from anytree import Node, RenderTree
  52. >>> udo = Node("Udo")
  53. >>> marc = Node("Marc", parent=udo)
  54. >>> lian = Node("Lian", parent=marc)
  55. >>> dan = Node("Dan", parent=udo)
  56. >>> jet = Node("Jet", parent=dan)
  57. >>> jan = Node("Jan", parent=dan)
  58. >>> joe = Node("Joe", parent=dan)
  59. **Node**
  60. >>> print(udo)
  61. Node('/Udo')
  62. >>> print(joe)
  63. Node('/Udo/Dan/Joe')
  64. **Tree**
  65. >>> for pre, fill, node in RenderTree(udo):
  66. ... print("%s%s" % (pre, node.name))
  67. Udo
  68. ├── Marc
  69. │ └── Lian
  70. └── Dan
  71. ├── Jet
  72. ├── Jan
  73. └── Joe
  74. >>> from anytree.exporter import DotExporter
  75. >>> # graphviz needs to be installed for the next line!
  76. >>> DotExporter(udo).to_picture("udo.png")
  77. .. image:: http://anytree.readthedocs.io/en/latest/_images/udo.png
  78. **Manipulation**
  79. A second tree:
  80. >>> mary = Node("Mary")
  81. >>> urs = Node("Urs", parent=mary)
  82. >>> chris = Node("Chris", parent=mary)
  83. >>> marta = Node("Marta", parent=mary)
  84. >>> print(RenderTree(mary))
  85. Node('/Mary')
  86. ├── Node('/Mary/Urs')
  87. ├── Node('/Mary/Chris')
  88. └── Node('/Mary/Marta')
  89. Append:
  90. >>> udo.parent = mary
  91. >>> print(RenderTree(mary))
  92. Node('/Mary')
  93. ├── Node('/Mary/Urs')
  94. ├── Node('/Mary/Chris')
  95. ├── Node('/Mary/Marta')
  96. └── Node('/Mary/Udo')
  97. ├── Node('/Mary/Udo/Marc')
  98. │ └── Node('/Mary/Udo/Marc/Lian')
  99. └── Node('/Mary/Udo/Dan')
  100. ├── Node('/Mary/Udo/Dan/Jet')
  101. ├── Node('/Mary/Udo/Dan/Jan')
  102. └── Node('/Mary/Udo/Dan/Joe')
  103. Subtree rendering:
  104. >>> print(RenderTree(marc))
  105. Node('/Mary/Udo/Marc')
  106. └── Node('/Mary/Udo/Marc/Lian')
  107. Cut:
  108. >>> dan.parent = None
  109. >>> print(RenderTree(dan))
  110. Node('/Dan')
  111. ├── Node('/Dan/Jet')
  112. ├── Node('/Dan/Jan')
  113. └── Node('/Dan/Joe')
  114. Installation
  115. ============
  116. To install the `anytree` module run::
  117. pip install anytree
  118. If you do not have write-permissions to the python installation, try::
  119. pip install anytree --user