Zish Python ANTLR
A Python library for the Zish format format, released under the MIT-0 licence.
Installation
Create a virtual environment: python3 -m venv venv
Activate the virtual environment: source venv/bin/activate
Install: pip install zish_antlr
Quickstart
To go from a Python object to an Zish string use zish.dumps. To go from a Zish string to a Python object use zish.loads. Eg.
>>> from zish import loads, dumps
>>> from datetime import datetime, timezone
>>> from decimal import Decimal
>>>
>>> # Take a Python object
>>> book = {
... 'title': 'A Hero of Our Time',
... 'read_date': datetime(2017, 7, 16, 14, 5, tzinfo=timezone.utc),
... 'would_recommend': True,
... 'description': None,
... 'number_of_novellas': 5,
... 'price': Decimal('7.99'),
... 'weight': 6.88,
... 'key': b'kshhgrl',
... 'tags': [
... 'russian',
... 'novel',
... '19th century',
... ],
... }
>>>
>>> # Output it as an Zish string
>>> zish_str = dumps(book)
>>> print(zish_str)
{
"description": null,
"key": 'a3NoaGdybA==',
"number_of_novellas": 5,
"price": 7.99,
"read_date": 2017-07-16T14:05:00Z,
"tags": [
"russian",
"novel",
"19th century",
],
"title": "A Hero of Our Time",
"weight": 6.88,
"would_recommend": true,
}
>>>
>>> # Load the Zish string, to give us back the Python object
>>> reloaded_book = loads(zish_str)
>>>
>>> # Print the title
>>> print(reloaded_book['title'])
A Hero of Our Time
Python Type |
Zish Type |
|---|---|
bool |
bool |
int |
integer |
str |
string |
datetime.datetime |
timestamp |
dict |
map |
decimal.Decimal |
decimal |
float |
decimal |
bytearray |
bytes |
bytes |
bytes |
list |
list |
tuple |
list |
Contributing
Useful link:
To run the tests:
Change to the zish_python_antlr directory: cd zish_python_antlr
Create a virtual environment: python3 -m venv venv
Activate the virtual environment: source venv/bin/activate
Install tox: pip install tox
Run tox: tox
The core parser is created using ANTLR from the Zish grammar. To create the parser files, go to the zish/antlr directory and download the ANTLR jar and then run the following command:
java -jar antlr-4.11.1-complete.jar -Dlanguage=Python3 Zish.g4
Making A New Release
Run tox to make sure all tests pass
Update the Release Notes section.
Ensure build and twine are installed: pip install wheel twine
Then do:
git tag -a x.y.z -m "version x.y.z" rm -r dist python -m build twine upload --sign dist/*
Release Notes
Version 0.0.14 (2022-10-30)
The U+00A0 NO-BREAK SPACE is now treated as whitespace.
Version 0.0.13 (2021-04-04)
Trailing commas in list and maps are now allowed.
Version 0.0.12 (2017-09-07)
Rename to zish_antlr to distinguish it from zish.
Version 0.0.11 (2017-09-07)
Upload to PyPI failed for previous release.
Version 0.0.10 (2017-09-07)
Allow lists and sets as keys to maps.
Version 0.0.9 (2017-08-24)
Fix bug where int was being parsed as Decimal.
Make bytes type return a bytes rather than a bytearray.
Version 0.0.8 (2017-08-24)
Container types aren’t allowed as map keys.
Performance improvements.
Version 0.0.7 (2017-08-22)
Fix bug with UTC timestamp formatting.
Version 0.0.6 (2017-08-22)
Fix bug in timestamp formatting.
Add note about comments.
Version 0.0.5 (2017-08-18)
Fix bug where dumps fails for a tuple.
Version 0.0.4 (2017-08-15)
Simplify integer types.
Version 0.0.3 (2017-08-09)
Fixed bug where interpreter couldn’t find the zish.antlr package in eggs.
Removed a few superfluous escape sequences.
Version 0.0.2 (2017-08-05)
Now uses RFC3339 for timestamps.
Version 0.0.1 (2017-08-03)
Fix bug where an EOF could cause an infinite loop.
Version 0.0.0 (2017-08-01)
First public release. Passes all the tests.
Metadata
Release files for zish-antlr 0.0.14
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| zish_antlr-0.0.14.tar.gz | 18.8 kB | Without provenance | Details for zish_antlr-0.0.14.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| zish_antlr-0.0.14-py3-none-any.whl | Python 3 | none | any | Details for zish_antlr-0.0.14-py3-none-any.whl |
Total release size: 33.2 kB
Release files / zish_antlr-0.0.14.tar.gz
| Download URL | zish_antlr-0.0.14.tar.gz |
|---|---|
| Size | 18.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4121b241d704a221ca25a509649c309336bc5eac99dcff203aeb324ec967aa5e
|
|
BLAKE2b-256 checksum How to use checksums |
85d73d33020f9ef7bcdc917c2c03c5868b3c0d9857fa10a6fca38e3b993af443
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.6
|
Release files / zish_antlr-0.0.14-py3-none-any.whl
| Download URL | zish_antlr-0.0.14-py3-none-any.whl |
|---|---|
| Size | 14.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
65719f2b847b8304cb9431727d2ce29f1238ec3d94aca77fc20425dfc399af9c
|
|
BLAKE2b-256 checksum How to use checksums |
5e592ecda5e78a99e15aa60a5d7cc39a1787bf64752c350af19d6cdcb5d5cccd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.6
|
Security for zish-antlr 0.0.14
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.