Skip to content

potc-dev/potc-treevalue

Repository files navigation

potc-treevalue

PyPI PyPI - Python Version Loc Comments

Code Test Badge Creation Package Release codecov

GitHub stars GitHub forks GitHub commit activity GitHub issues GitHub pulls Contributors GitHub license

Potc support for treevalue module.

Installation

You can simply install it with pip command line from the official PyPI site.

pip install potc-treevalue

Quick Start

After potc-treevalue is installed, you can convert the treevalue objects into executable source code without any additional operations.

We can create a python script which is named test_simple.py

from potc import transvars
from treevalue import FastTreeValue, raw

r = raw({'a': 1, 'b': 2, 'c': [3, 4]})
t = FastTreeValue({
    'a': 1, 'b': 'this is a string',
    'c': [], 'd': {
        'x': raw({'a': 1, 'b': (None, Ellipsis)}),
        'y': {3, 4, 5}
    }
})
st = t._detach()
if __name__ == '__main__':
    _code = transvars(
        {'t': t, 'st': t._detach(), 'r': r},
        reformat='pep8'
    )
    print(_code)

The output result should be like this

from treevalue import FastTreeValue, raw
from treevalue.tree.common import create_storage

__all__ = ['r', 'st', 't']
r = raw({'a': 1, 'b': 2, 'c': [3, 4]})
st = create_storage({
    'a': 1,
    'b': 'this is a string',
    'c': [],
    'd': {
        'x': raw({
            'a': 1,
            'b': (None, ...)
        }),
        'y': {3, 4, 5}
    }
})
t = FastTreeValue({
    'a': 1,
    'b': 'this is a string',
    'c': [],
    'd': {
        'x': raw({
            'a': 1,
            'b': (None, ...)
        }),
        'y': {3, 4, 5}
    }
})

And, you can use the following CLI command to get the same output results as above.

potc export -v 'test_simple.t' -v 'test_simple.st' -v 'test_simple.r'

Contributing

We appreciate all contributions to improve potc and potc-treevalue, both logic and system designs. Please refer to CONTRIBUTING.md for more guides.

License

potc-treevalue released under the Apache 2.0 license.