# rjsonnet-py
![CI](https://github.com/messense/rjsonnet-py/workflows/CI/badge.svg)
[![PyPI](https://img.shields.io/pypi/v/rjsonnet.svg)](https://pypi.org/project/rjsonnet)
Python bindings to Rust [jrsonnet](https://github.com/CertainLach/jrsonnet) crates (Rust implementation of Jsonnet language).
## Installation
```bash
pip install rjsonnet
```
## Usage
This module provides two functions:
1. `def evaluate_file(filename: str) -> str: ...`
2. `def evaluate_snippet(filename: str, src: str) -> str: ...`
In the latter case, the parameter `filename` is used in stack traces,
because all errors are given with the "filename" containing the code.
Keyword arguments to these functions are used to control the virtual machine. They are:
* `max_stack` (number)
* `gc_min_objects` (number, ignored)
* `gc_growth_trigger` (number, ignored)
* `ext_vars` (dict, string to string)
* `ext_codes` (dict, string to string)
* `tla_vars` (dict, string to string)
* `tla_codes` (dict, string to string)
* `max_trace` (number)
* `import_callback` (see example in [tests/](./tests/))
* `native_callbacks` (see example in [tests/](./tests/))
* `preserve_order` (bool, preserve object field order during manifestification)
The argument `import_callback` can be used to pass a callable, to trap the Jsonnet `import` and `importstr` constructs.
This allows, e.g., reading files out of archives or implementing library search paths.
The argument `native_callbacks` is used to allow execution of arbitrary Python code via `std.native(...)`.
This is useful so Jsonnet code can access pure functions in the Python ecosystem, such as compression, encryption, encoding, etc.
If an error is raised during the evaluation of the Jsonnet code, it is formed into a stack trace and thrown as a python `RuntimeError`.
```python
import rjsonnet
# evaluate a jsonnet file
rjsonnet.evaluate_file("filename.jsonnet")
# evalute a jsonnet code snippet
rjsonnet.evaluate_snippet('filename', 'jsonnet code snippet')
```
## License
This work is released under the MIT license. A copy of the license is provided in the [LICENSE](./LICENSE) file.
Raw data
{
"_id": null,
"home_page": "https://github.com/messense/rjsonnet-py",
"name": "rjsonnet",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "",
"author": "messense <messense@icloud.com>",
"author_email": "messense <messense@icloud.com>",
"download_url": "https://files.pythonhosted.org/packages/0a/18/c60658127971b5f67f5a391f4f062123599fb0b276d1a51485fb086c40a9/rjsonnet-0.5.3.tar.gz",
"platform": null,
"description": "# rjsonnet-py\n\n![CI](https://github.com/messense/rjsonnet-py/workflows/CI/badge.svg)\n[![PyPI](https://img.shields.io/pypi/v/rjsonnet.svg)](https://pypi.org/project/rjsonnet)\n\nPython bindings to Rust [jrsonnet](https://github.com/CertainLach/jrsonnet) crates (Rust implementation of Jsonnet language).\n\n## Installation\n\n```bash\npip install rjsonnet\n```\n\n## Usage\n\nThis module provides two functions:\n\n1. `def evaluate_file(filename: str) -> str: ...`\n2. `def evaluate_snippet(filename: str, src: str) -> str: ...`\n\nIn the latter case, the parameter `filename` is used in stack traces,\nbecause all errors are given with the \"filename\" containing the code.\n\nKeyword arguments to these functions are used to control the virtual machine. They are:\n\n* `max_stack` (number)\n* `gc_min_objects` (number, ignored)\n* `gc_growth_trigger` (number, ignored)\n* `ext_vars` (dict, string to string)\n* `ext_codes` (dict, string to string)\n* `tla_vars` (dict, string to string)\n* `tla_codes` (dict, string to string)\n* `max_trace` (number)\n* `import_callback` (see example in [tests/](./tests/))\n* `native_callbacks` (see example in [tests/](./tests/))\n* `preserve_order` (bool, preserve object field order during manifestification)\n\nThe argument `import_callback` can be used to pass a callable, to trap the Jsonnet `import` and `importstr` constructs.\nThis allows, e.g., reading files out of archives or implementing library search paths.\n\nThe argument `native_callbacks` is used to allow execution of arbitrary Python code via `std.native(...)`.\nThis is useful so Jsonnet code can access pure functions in the Python ecosystem, such as compression, encryption, encoding, etc.\n\nIf an error is raised during the evaluation of the Jsonnet code, it is formed into a stack trace and thrown as a python `RuntimeError`.\n\n```python\nimport rjsonnet\n\n# evaluate a jsonnet file\nrjsonnet.evaluate_file(\"filename.jsonnet\")\n\n# evalute a jsonnet code snippet\nrjsonnet.evaluate_snippet('filename', 'jsonnet code snippet')\n```\n\n## License\n\nThis work is released under the MIT license. A copy of the license is provided in the [LICENSE](./LICENSE) file.\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Python bindings to Rust jrsonnet crate",
"version": "0.5.3",
"project_urls": {
"Homepage": "https://github.com/messense/rjsonnet-py",
"Source Code": "https://github.com/messense/rjsonnet-py.git"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "c0ac50e27089099276b5b058a45e504f47b0e394fc09051a317915a454758138",
"md5": "1ee017c07c3f45df607e6450b17aa023",
"sha256": "11210f2458d5bf271aaab36b990b1914f3aa2fe54c8451dae1789473e5103adf"
},
"downloads": -1,
"filename": "rjsonnet-0.5.3-cp37-abi3-macosx_10_7_x86_64.whl",
"has_sig": false,
"md5_digest": "1ee017c07c3f45df607e6450b17aa023",
"packagetype": "bdist_wheel",
"python_version": "cp37",
"requires_python": null,
"size": 1216972,
"upload_time": "2023-09-02T05:34:39",
"upload_time_iso_8601": "2023-09-02T05:34:39.843188Z",
"url": "https://files.pythonhosted.org/packages/c0/ac/50e27089099276b5b058a45e504f47b0e394fc09051a317915a454758138/rjsonnet-0.5.3-cp37-abi3-macosx_10_7_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "957b7ee59f9f7356ad288f36a9617850b916a289383b384907e395a9f3955ec7",
"md5": "8c98bfdaf8171e12bb2ff7ad1625ad92",
"sha256": "20fc24d75fbd68f31423cbd7bbf0b9f52d3c27583d243fabac0ea1407a747ad7"
},
"downloads": -1,
"filename": "rjsonnet-0.5.3-cp37-abi3-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl",
"has_sig": false,
"md5_digest": "8c98bfdaf8171e12bb2ff7ad1625ad92",
"packagetype": "bdist_wheel",
"python_version": "cp37",
"requires_python": null,
"size": 2374594,
"upload_time": "2023-09-02T05:34:42",
"upload_time_iso_8601": "2023-09-02T05:34:42.219210Z",
"url": "https://files.pythonhosted.org/packages/95/7b/7ee59f9f7356ad288f36a9617850b916a289383b384907e395a9f3955ec7/rjsonnet-0.5.3-cp37-abi3-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "cdf841c3249f439a24faa03f0ef710e6bfe122221c091ff509fa4cb5a48fe03d",
"md5": "477aed94d546dce701f070759abeba99",
"sha256": "41421804f54321a0c53a9c7755357a15c9e3115fefcc59eca5ba62133ff0467e"
},
"downloads": -1,
"filename": "rjsonnet-0.5.3-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
"has_sig": false,
"md5_digest": "477aed94d546dce701f070759abeba99",
"packagetype": "bdist_wheel",
"python_version": "cp37",
"requires_python": null,
"size": 2361282,
"upload_time": "2023-09-02T05:34:44",
"upload_time_iso_8601": "2023-09-02T05:34:44.628150Z",
"url": "https://files.pythonhosted.org/packages/cd/f8/41c3249f439a24faa03f0ef710e6bfe122221c091ff509fa4cb5a48fe03d/rjsonnet-0.5.3-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "f603028b957279b6bd113a589f740bea12d09606c0a806ecf10740d61b921412",
"md5": "61417e6eb8ba62d581e41e0481d8875e",
"sha256": "53d7868607574d9fda73370b9b190ade6734f3dc47aa0c27125ebc5137f96ed4"
},
"downloads": -1,
"filename": "rjsonnet-0.5.3-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl",
"has_sig": false,
"md5_digest": "61417e6eb8ba62d581e41e0481d8875e",
"packagetype": "bdist_wheel",
"python_version": "cp37",
"requires_python": null,
"size": 2166261,
"upload_time": "2023-09-02T05:34:46",
"upload_time_iso_8601": "2023-09-02T05:34:46.070938Z",
"url": "https://files.pythonhosted.org/packages/f6/03/028b957279b6bd113a589f740bea12d09606c0a806ecf10740d61b921412/rjsonnet-0.5.3-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "1fa916c5d8513167bab6a66407c8cacfc4d4513bf99af7833fde872950bf3ca2",
"md5": "1fd6a3ed748949a516750264b7a37b59",
"sha256": "ad4b24615dfe8384ca238554d984f07d7599d90658be759985aafab9fd60b85e"
},
"downloads": -1,
"filename": "rjsonnet-0.5.3-cp37-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl",
"has_sig": false,
"md5_digest": "1fd6a3ed748949a516750264b7a37b59",
"packagetype": "bdist_wheel",
"python_version": "cp37",
"requires_python": null,
"size": 2743588,
"upload_time": "2023-09-02T05:34:47",
"upload_time_iso_8601": "2023-09-02T05:34:47.603791Z",
"url": "https://files.pythonhosted.org/packages/1f/a9/16c5d8513167bab6a66407c8cacfc4d4513bf99af7833fde872950bf3ca2/rjsonnet-0.5.3-cp37-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "4e87728c15fff9485cf5de3d9fd1aa3c0320f512d81275629a15ae1e16d536d8",
"md5": "b5385f3c79a6d34e13aec36971a1a936",
"sha256": "e215e0598f678e2dd401fdd5fb7253adc9eb9e470f764b213625304910ca51fa"
},
"downloads": -1,
"filename": "rjsonnet-0.5.3-cp37-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl",
"has_sig": false,
"md5_digest": "b5385f3c79a6d34e13aec36971a1a936",
"packagetype": "bdist_wheel",
"python_version": "cp37",
"requires_python": null,
"size": 2805164,
"upload_time": "2023-09-02T05:34:50",
"upload_time_iso_8601": "2023-09-02T05:34:50.089031Z",
"url": "https://files.pythonhosted.org/packages/4e/87/728c15fff9485cf5de3d9fd1aa3c0320f512d81275629a15ae1e16d536d8/rjsonnet-0.5.3-cp37-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "782c6af12a4737ef4ca4c77d2fc62b81c3b78035c03fa05128fccc4f8c6ec274",
"md5": "9246b73159c788463a3421b2b6bd7cf1",
"sha256": "4c422e99f03507625d0a481c55baf698da4e39be14a93849b79c7f857d33effc"
},
"downloads": -1,
"filename": "rjsonnet-0.5.3-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"has_sig": false,
"md5_digest": "9246b73159c788463a3421b2b6bd7cf1",
"packagetype": "bdist_wheel",
"python_version": "cp37",
"requires_python": null,
"size": 2362424,
"upload_time": "2023-09-02T05:34:52",
"upload_time_iso_8601": "2023-09-02T05:34:52.249286Z",
"url": "https://files.pythonhosted.org/packages/78/2c/6af12a4737ef4ca4c77d2fc62b81c3b78035c03fa05128fccc4f8c6ec274/rjsonnet-0.5.3-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "ed062b47f95a3e4e7e1bac5f0b12204a868e74392397e6bc42241d679ca190fa",
"md5": "fb471b5773e5f57cc01aecf91640a8e1",
"sha256": "bbcf9a99149c8b72d391cd69e8c2b586ad43451ce85487baec752311e2b18abf"
},
"downloads": -1,
"filename": "rjsonnet-0.5.3-cp37-abi3-manylinux_2_5_i686.manylinux1_i686.whl",
"has_sig": false,
"md5_digest": "fb471b5773e5f57cc01aecf91640a8e1",
"packagetype": "bdist_wheel",
"python_version": "cp37",
"requires_python": null,
"size": 2463578,
"upload_time": "2023-09-02T05:34:55",
"upload_time_iso_8601": "2023-09-02T05:34:55.119177Z",
"url": "https://files.pythonhosted.org/packages/ed/06/2b47f95a3e4e7e1bac5f0b12204a868e74392397e6bc42241d679ca190fa/rjsonnet-0.5.3-cp37-abi3-manylinux_2_5_i686.manylinux1_i686.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "51ec00aa95b234fe7435ee2e4ca5e3cc6fa4f6f8e1884078b1e0b87ca09a36e8",
"md5": "4355dad90156d4063e1bf7b19eb376a9",
"sha256": "8bf7a5c5a99b28951816f631ab8427035b4d54c86c566f07cc56ff418741a70c"
},
"downloads": -1,
"filename": "rjsonnet-0.5.3-cp37-abi3-musllinux_1_2_aarch64.whl",
"has_sig": false,
"md5_digest": "4355dad90156d4063e1bf7b19eb376a9",
"packagetype": "bdist_wheel",
"python_version": "cp37",
"requires_python": null,
"size": 2531826,
"upload_time": "2023-09-02T05:34:58",
"upload_time_iso_8601": "2023-09-02T05:34:58.015013Z",
"url": "https://files.pythonhosted.org/packages/51/ec/00aa95b234fe7435ee2e4ca5e3cc6fa4f6f8e1884078b1e0b87ca09a36e8/rjsonnet-0.5.3-cp37-abi3-musllinux_1_2_aarch64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "de46093c454bffaf4afade72bb442f5ce103b1008a64c9b39a2ccf11f40212cd",
"md5": "a5b3af4db2e396bc8cf15e636796bf87",
"sha256": "b23f11e85fe398e491dc70f0e68ada5cc4a53a83b5986944a5764e5fb22f5805"
},
"downloads": -1,
"filename": "rjsonnet-0.5.3-cp37-abi3-musllinux_1_2_armv7l.whl",
"has_sig": false,
"md5_digest": "a5b3af4db2e396bc8cf15e636796bf87",
"packagetype": "bdist_wheel",
"python_version": "cp37",
"requires_python": null,
"size": 2425272,
"upload_time": "2023-09-02T05:35:00",
"upload_time_iso_8601": "2023-09-02T05:35:00.747902Z",
"url": "https://files.pythonhosted.org/packages/de/46/093c454bffaf4afade72bb442f5ce103b1008a64c9b39a2ccf11f40212cd/rjsonnet-0.5.3-cp37-abi3-musllinux_1_2_armv7l.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "524e20c6c4d00aea948178d6158f980ea32124c24f99bcb9aec13daf3b5a2c46",
"md5": "f27d9d2a853a8ebf7c804a9650798f87",
"sha256": "ed17d35d85334dbab4d3cfd3c324add6145c1f1b3617f4d5ca74671af8c5609f"
},
"downloads": -1,
"filename": "rjsonnet-0.5.3-cp37-abi3-musllinux_1_2_i686.whl",
"has_sig": false,
"md5_digest": "f27d9d2a853a8ebf7c804a9650798f87",
"packagetype": "bdist_wheel",
"python_version": "cp37",
"requires_python": null,
"size": 2580826,
"upload_time": "2023-09-02T05:35:03",
"upload_time_iso_8601": "2023-09-02T05:35:03.296546Z",
"url": "https://files.pythonhosted.org/packages/52/4e/20c6c4d00aea948178d6158f980ea32124c24f99bcb9aec13daf3b5a2c46/rjsonnet-0.5.3-cp37-abi3-musllinux_1_2_i686.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "42414b42246896595afb362870fe37ea517cc09892155fda2ff2aa3cd0e63956",
"md5": "80cbcae368087685621aefc3a94c3c39",
"sha256": "33e8b1412e25c0cb79f3587f5ead9287a31812b63780cfbf4e1800ee26f2cc9d"
},
"downloads": -1,
"filename": "rjsonnet-0.5.3-cp37-abi3-musllinux_1_2_x86_64.whl",
"has_sig": false,
"md5_digest": "80cbcae368087685621aefc3a94c3c39",
"packagetype": "bdist_wheel",
"python_version": "cp37",
"requires_python": null,
"size": 2527191,
"upload_time": "2023-09-02T05:35:05",
"upload_time_iso_8601": "2023-09-02T05:35:05.702795Z",
"url": "https://files.pythonhosted.org/packages/42/41/4b42246896595afb362870fe37ea517cc09892155fda2ff2aa3cd0e63956/rjsonnet-0.5.3-cp37-abi3-musllinux_1_2_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "86e5a01226fc9f3eef1083bbe9b92f454348e568c8a19ba99c1842dd572d37f8",
"md5": "c58cecf5838193f5a4cb5353ee64132d",
"sha256": "0c84bff33cdb160fadc1fc1a57e6a4050a38ccba4d85820ec26778fc0c7bd638"
},
"downloads": -1,
"filename": "rjsonnet-0.5.3-cp37-abi3-win32.whl",
"has_sig": false,
"md5_digest": "c58cecf5838193f5a4cb5353ee64132d",
"packagetype": "bdist_wheel",
"python_version": "cp37",
"requires_python": null,
"size": 900294,
"upload_time": "2023-09-02T05:35:07",
"upload_time_iso_8601": "2023-09-02T05:35:07.570753Z",
"url": "https://files.pythonhosted.org/packages/86/e5/a01226fc9f3eef1083bbe9b92f454348e568c8a19ba99c1842dd572d37f8/rjsonnet-0.5.3-cp37-abi3-win32.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "1e624a233d0bef1616ef040ee94eb41c30baa241a2faf76718c3c77cd993f707",
"md5": "8a33450076aba0b831df799691ef4047",
"sha256": "51126688f5a49e089749ae377f2094025b28d5211e8d8fdc27dc37a6300e3cb7"
},
"downloads": -1,
"filename": "rjsonnet-0.5.3-cp37-abi3-win_amd64.whl",
"has_sig": false,
"md5_digest": "8a33450076aba0b831df799691ef4047",
"packagetype": "bdist_wheel",
"python_version": "cp37",
"requires_python": null,
"size": 974865,
"upload_time": "2023-09-02T05:35:09",
"upload_time_iso_8601": "2023-09-02T05:35:09.181067Z",
"url": "https://files.pythonhosted.org/packages/1e/62/4a233d0bef1616ef040ee94eb41c30baa241a2faf76718c3c77cd993f707/rjsonnet-0.5.3-cp37-abi3-win_amd64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "0a18c60658127971b5f67f5a391f4f062123599fb0b276d1a51485fb086c40a9",
"md5": "b03b7cc9bce0a5fb67aaa689927f704b",
"sha256": "acdb7499064f1bfbe99bd75551bea1ba9d818149164ad6801206102ac565e5f7"
},
"downloads": -1,
"filename": "rjsonnet-0.5.3.tar.gz",
"has_sig": false,
"md5_digest": "b03b7cc9bce0a5fb67aaa689927f704b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 15320,
"upload_time": "2023-09-02T05:35:10",
"upload_time_iso_8601": "2023-09-02T05:35:10.492176Z",
"url": "https://files.pythonhosted.org/packages/0a/18/c60658127971b5f67f5a391f4f062123599fb0b276d1a51485fb086c40a9/rjsonnet-0.5.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-09-02 05:35:10",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "messense",
"github_project": "rjsonnet-py",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "rjsonnet"
}