Tree model markup builder.
Project description
Pure pythonic tree structure model builder.
Enter tree nodes with python’s contextmanagers.
Cast the tree to given markup (basically it’s suited for XML).
Enjoy 1:1 translation from python to given markup.
Example
from xplant.xml import XmlPlant x = XmlPlant() with x.node("section_a", attribute_1=1): with x.node("nested_1", empty=True): pass with x.node("nested_2"): x.comment("Can handle also comments.") for number in range(3): x.leaf("a number {:02}".format(number), num=number) print(x)
Will give:
<?xml version="1.0" encoding="utf-8"?> <section_a attribute_1="1"> <nested_1 empty="true"></nested_1> <nested_2> <!-- Can handle also comments. --> <a number 00 num="0" /> <a number 01 num="1" /> <a number 02 num="2" /> </nested_2> </section_a>
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
xplant-0.2.1-py2.py3-none-any.whl
(13.9 kB
view hashes)
Close
Hashes for xplant-0.2.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 65a6e6846ff0a59ae41e8bd71b7107f39ac43e83f122d6ec75a6d94b67fda14d |
|
MD5 | d6b83dd4531301211188c914a9f11e4e |
|
BLAKE2b-256 | 72cdaba124ac953808e225dcade8182a9571085100a81163749350a0b9b59abb |