Skip to main content

A fluent tree builder, useful to create multi-level, nested JSON configurations.

Project description

easytree

PyPI version Documentation Status Downloads count Code style: black

A fluent tree builder, useful to create multi-level, nested JSON configurations.

Documentation

Documentation is hosted on read the docs

Installation

pip install easytree

Quickstart

>>> import easytree

#let's create a chart configuration
>>> chart = easytree.Tree()
>>> chart.chart.type = "bar"
>>> chart.title.text = "France Olympic Medals"
>>> chart.xAxis.categories = ["Gold", "Silver", "Bronze"]
>>> chart.yAxis.title.text = "Count"
>>> chart.series.append(name="2016", data=[10, 18, 14])
>>> chart.series.append({"name":"2012"}) #list items recursively become nodes
>>> chart.series[1].data = [11, 11, 13]  #... as such, you can attach attributes

>>> chart.serialize()
{
    "chart": {
        "type": "bar"
    },
    "title": {
        "text": "France Olympic Medals"
    },
    "xAxis": {
        "categories": [
            "Gold",
            "Silver",
            "Bronze"
        ]
    },
    "yAxis": {
        "title": {
            "text": "Count"
        }
    },
    "series": [
        {
            "name": "2016",
            "data": [
                10,
                18,
                14
            ]
        },
        {
            "name": "2012",
            "data": [
                11,
                11,
                13
            ]
        }
    ]
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

easytree-0.1.8.tar.gz (7.5 kB view hashes)

Uploaded Source

Built Distribution

easytree-0.1.8-py3-none-any.whl (8.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page