Package: zish-antlr
A Python library for theZish formatformat,
released under theMIT-0 licence.Table of ContentsInstallationQuickstartContributingMaking A New ReleaseRelease NotesVersion 0.0.14 (2022-10-30)Version 0.0.13 (2021-04-04)Version 0.0.12 (2017-09-07)Version 0.0.11 (2017-09-07)Version 0.0.10 (2017-09-07)Version 0.0.9 (2017-08-24)Version 0.0.8 (2017-08-24)Version 0.0.7 (2017-08-22)Version 0.0.6 (2017-08-22)Version 0.0.5 (2017-08-18)Version 0.0.4 (2017-08-15)Version 0.0.3 (2017-08-09)Version 0.0.2 (2017-08-05)Version 0.0.1 (2017-08-03)Version 0.0.0 (2017-08-01)InstallationCreate a virtual environment:python3-mvenv venvActivate the virtual environment:source venv/bin/activateInstall:pip install zish_antlrQuickstartTo go from a Python object to an Zish string usezish.dumps. To go from a Zish
string to a Python object usezish.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 TimePython To Zish Type MappingPython TypeZish Typeboolboolintintegerstrstringdatetime.datetimetimestampdictmapdecimal.DecimaldecimalfloatdecimalbytearraybytesbytesbyteslistlisttuplelistContributingUseful link:ANTLR JavaDocsTo run the tests:Change to thezish_python_antlrdirectory:cd zish_python_antlrCreate a virtual environment:python3-mvenv venvActivate the virtual environment:source venv/bin/activateInstall tox:pip install toxRun tox:toxThe core parser is created usingANTLRfrom the
Zish grammar. To create the parser files, go to thezish/antlrdirectory and
download the ANTLR jar and then run the following command:java-jarantlr-4.11.1-complete.jar-Dlanguage=Python3Zish.g4Making A New ReleaseRuntoxto make sure all tests passUpdate theRelease Notessection.Ensurebuildandtwineare installed:pip install wheel twineThen do:git tag -a x.y.z -m "version x.y.z"
rm -r dist
python -m build
twine upload --sign dist/*Release NotesVersion 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 tozish_antlrto distinguish it fromzish.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 whereintwas being parsed asDecimal.Make bytes type return abytesrather than abytearray.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 wheredumpsfails for atuple.Version 0.0.4 (2017-08-15)Simplify integer types.Version 0.0.3 (2017-08-09)Fixed bug where interpreter couldn’t find thezish.antlrpackage 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.