Name | zish JSON |
Version |
0.1.11
JSON |
| download |
home_page | |
Summary | A Python library for the Zish format. |
upload_time | 2023-10-09 19:32:42 |
maintainer | |
docs_url | None |
author | |
requires_python | >=3.8 |
license | MIT No Attribution |
keywords |
zish
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
====
Zish
====
A Python library for the `Zish format <https://github.com/tlocke/zish>`_, released under
the `MIT-0 licence <https://choosealicense.com/licenses/mit-0/>`_.
.. image:: https://github.com/tlocke/zish_python/workflows/zish_python/badge.svg
:alt: Build Status
.. contents:: Table of Contents
:depth: 2
:local:
Installation
------------
- Create a virtual environment: ``python3 -m venv venv``
- Activate the virtual environment: ``source venv/bin/activate``
- Install: ``pip install zish``
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
.. table:: Python To Zish Type Mapping
+-----------------------+-----------------------------------------------------------+
| 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 |
+-----------------------+-----------------------------------------------------------+
Running The Tests
-----------------
- Change to the ``zish`` directory: ``cd zish``
- Create a virtual environment: ``python3 -m venv venv``
- Activate the virtual environment: ``source venv/bin/activate``
- Install tox: ``pip install tox``
- Run tox: ``tox``
README.rst
----------
This file is written in the `reStructuredText
<https://docutils.sourceforge.io/docs/user/rst/quickref.html>`_ format. To generate an
HTML page from it, do:
- Activate the virtual environment: ``source venv/bin/activate``
- Install ``Sphinx``: ``pip install Sphinx``
- Run ``rst2html.py``: ``rst2html.py README.rst README.html``
Making A New Release
--------------------
Run ``tox`` to make sure all tests pass, then update the 'Release Notes' section 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.1.11 (2023-10-09)
```````````````````````````
- Fix bug where ``dump()`` didn't escape ``"`` and ``\\`` properly.
- Remove support for Python 3.7 and add support for Python 3.11.
Version 0.1.10 (2022-10-29)
```````````````````````````
- Switch to MIT-0 licence.
- Make the U+00A0 NO-BREAK SPACE character whitespace
- Better error message when ``dump()`` encounters an unrecognised type.
Version 0.1.9 (2021-04-05)
``````````````````````````
- Allow trailing commas in maps and lists.
Version 0.1.8 (2020-06-25)
``````````````````````````
- Make `dumps` sort the `set` type before outputing as a list.
Version 0.1.7 (2020-02-11)
``````````````````````````
- Use 1-based line and character numbers, rather than zero-based.
- Arrow time library upgraded.
- Line and character numbers now available in errors
Version 0.1.6 (2018-11-12)
``````````````````````````
- Better error message when parsing an empty string.
Version 0.1.5 (2018-10-30)
``````````````````````````
- Fix new Flake8 errors.
Version 0.1.4 (2018-10-30)
``````````````````````````
- Better error message if there's a duplicate key in a map.
Version 0.1.3 (2018-10-30)
``````````````````````````
- An exception is thrown if there's a duplicate key in a map.
Version 0.1.2 (2018-09-04)
``````````````````````````
- Change formatting for map and list in dumps. The trailing } and ] are now on a line
down and at the original index.
Version 0.1.1 (2018-03-13)
``````````````````````````
- A decimal with an uppercase 'E' in the exponent wasn't being recognized.
Version 0.1.0 (2018-01-29)
``````````````````````````
- A map key can't be null, following change in spec.
Version 0.0.26 (2018-01-29)
```````````````````````````
- Remove '//' as a comment, following change in spec.
- Allow 'e' and 'E' in the exponent of a decimal, following change in spec.
Version 0.0.25 (2018-01-12)
```````````````````````````
- Better error message when the end of the document is reached without a map being
closed.
Version 0.0.24 (2018-01-11)
```````````````````````````
- Fix bug where an integer after a value (and before a ',' or '}') in a map doesn't
give a good error.
Version 0.0.23 (2018-01-09)
```````````````````````````
- A map key can't now be a list or a map.
Version 0.0.22 (2018-01-08)
```````````````````````````
- A map key can now be of any type.
- The 'set' type has been removed from Zish.
- Zish now recognizes the full set of Unicode EOL sequences.
- The 'float' type has been removed from Zish.
- Fixed bug when sorting map with keys of more than one type.
Version 0.0.21 (2018-01-04)
```````````````````````````
- Give a better error if the end of the document is reached before a map is completed.
Version 0.0.20 (2018-01-04)
```````````````````````````
- Give an error if there are multiple top-level values, rather than silently truncating.
Version 0.0.19 (2017-09-27)
```````````````````````````
- Decimal exponent dumped as ``E`` rather than ``d``.
Version 0.0.18 (2017-09-12)
```````````````````````````
- Add tests for float formatting.
Version 0.0.17 (2017-09-12)
```````````````````````````
- Tighten up parsing of container types.
- Make sure floats are formatted without an uppercase E.
Version 0.0.16 (2017-09-06)
```````````````````````````
- Allow lists and sets as keys.
Version 0.0.15 (2017-09-05)
```````````````````````````
- Fixed map parsing bug where an error wasn't reported properly if it was expecting a
``:`` but got an integer.
Version 0.0.14 (2017-09-05)
```````````````````````````
- Fixed bug where sets couldn't be formatted.
Version 0.0.13 (2017-08-30)
```````````````````````````
- Performance improvement.
Version 0.0.12 (2017-08-30)
```````````````````````````
- Add Travis configuration.
Version 0.0.11 (2017-08-30)
```````````````````````````
- Give a better error message if a string isn't closed.
Version 0.0.10 (2017-08-29)
```````````````````````````
- New native parser that doesn't use antlr. It's about twice as fast.
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.
Raw data
{
"_id": null,
"home_page": "",
"name": "zish",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "",
"keywords": "zish",
"author": "",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/5c/eb/138db79f12b3806b4df4c1a3d560c90dc761b8e9e49c8bd18268cf4d1aaf/zish-0.1.11.tar.gz",
"platform": null,
"description": "====\nZish\n====\n\nA Python library for the `Zish format <https://github.com/tlocke/zish>`_, released under\nthe `MIT-0 licence <https://choosealicense.com/licenses/mit-0/>`_.\n\n.. image:: https://github.com/tlocke/zish_python/workflows/zish_python/badge.svg\n :alt: Build Status\n\n.. contents:: Table of Contents\n :depth: 2\n :local:\n\nInstallation\n------------\n\n- Create a virtual environment: ``python3 -m venv venv``\n- Activate the virtual environment: ``source venv/bin/activate``\n- Install: ``pip install zish``\n\n\nQuickstart\n----------\n\nTo go from a Python object to an Zish string use ``zish.dumps``. To go from a Zish\nstring to a Python object use ``zish.loads``. Eg.\n\n>>> from zish import loads, dumps\n>>> from datetime import datetime, timezone\n>>> from decimal import Decimal\n>>>\n>>> # Take a Python object\n>>> book = {\n... 'title': 'A Hero of Our Time',\n... 'read_date': datetime(2017, 7, 16, 14, 5, tzinfo=timezone.utc),\n... 'would_recommend': True,\n... 'description': None,\n... 'number_of_novellas': 5,\n... 'price': Decimal('7.99'),\n... 'weight': 6.88,\n... 'key': b'kshhgrl',\n... 'tags': ['russian', 'novel', '19th century']}\n>>>\n>>> # Output it as an Zish string\n>>> zish_str = dumps(book)\n>>> print(zish_str)\n{\n \"description\": null,\n \"key\": 'a3NoaGdybA==',\n \"number_of_novellas\": 5,\n \"price\": 7.99,\n \"read_date\": 2017-07-16T14:05:00Z,\n \"tags\": [\n \"russian\",\n \"novel\",\n \"19th century\",\n ],\n \"title\": \"A Hero of Our Time\",\n \"weight\": 6.88,\n \"would_recommend\": true,\n}\n>>>\n>>> # Load the Zish string, to give us back the Python object\n>>> reloaded_book = loads(zish_str)\n>>> \n>>> # Print the title\n>>> print(reloaded_book['title'])\nA Hero of Our Time\n\n.. table:: Python To Zish Type Mapping\n\n +-----------------------+-----------------------------------------------------------+\n | Python Type | Zish Type |\n +=======================+===========================================================+\n | bool | bool |\n +-----------------------+-----------------------------------------------------------+\n | int | integer |\n +-----------------------+-----------------------------------------------------------+\n | str | string |\n +-----------------------+-----------------------------------------------------------+\n | datetime.datetime | timestamp |\n +-----------------------+-----------------------------------------------------------+\n | dict | map |\n +-----------------------+-----------------------------------------------------------+\n | decimal.Decimal | decimal |\n +-----------------------+-----------------------------------------------------------+\n | float | decimal |\n +-----------------------+-----------------------------------------------------------+\n | bytearray | bytes |\n +-----------------------+-----------------------------------------------------------+\n | bytes | bytes |\n +-----------------------+-----------------------------------------------------------+\n | list | list |\n +-----------------------+-----------------------------------------------------------+\n | tuple | list |\n +-----------------------+-----------------------------------------------------------+\n\n\nRunning The Tests\n-----------------\n\n- Change to the ``zish`` directory: ``cd zish``\n- Create a virtual environment: ``python3 -m venv venv``\n- Activate the virtual environment: ``source venv/bin/activate``\n- Install tox: ``pip install tox``\n- Run tox: ``tox``\n\n\nREADME.rst\n----------\n\nThis file is written in the `reStructuredText\n<https://docutils.sourceforge.io/docs/user/rst/quickref.html>`_ format. To generate an\nHTML page from it, do:\n\n- Activate the virtual environment: ``source venv/bin/activate``\n- Install ``Sphinx``: ``pip install Sphinx``\n- Run ``rst2html.py``: ``rst2html.py README.rst README.html``\n\n\nMaking A New Release\n--------------------\n\nRun ``tox`` to make sure all tests pass, then update the 'Release Notes' section then\ndo::\n\n git tag -a x.y.z -m \"version x.y.z\"\n rm -r dist\n python -m build\n twine upload --sign dist/*\n\n\nRelease Notes\n-------------\n\nVersion 0.1.11 (2023-10-09)\n```````````````````````````\n\n- Fix bug where ``dump()`` didn't escape ``\"`` and ``\\\\`` properly.\n\n- Remove support for Python 3.7 and add support for Python 3.11.\n\n\nVersion 0.1.10 (2022-10-29)\n```````````````````````````\n\n- Switch to MIT-0 licence.\n\n- Make the U+00A0 NO-BREAK SPACE character whitespace\n\n- Better error message when ``dump()`` encounters an unrecognised type.\n\n\nVersion 0.1.9 (2021-04-05)\n``````````````````````````\n\n- Allow trailing commas in maps and lists.\n\n\nVersion 0.1.8 (2020-06-25)\n``````````````````````````\n\n- Make `dumps` sort the `set` type before outputing as a list.\n\n\nVersion 0.1.7 (2020-02-11)\n``````````````````````````\n\n- Use 1-based line and character numbers, rather than zero-based.\n\n- Arrow time library upgraded.\n\n- Line and character numbers now available in errors\n\n\nVersion 0.1.6 (2018-11-12)\n``````````````````````````\n\n- Better error message when parsing an empty string.\n\n\nVersion 0.1.5 (2018-10-30)\n``````````````````````````\n\n- Fix new Flake8 errors.\n\n\nVersion 0.1.4 (2018-10-30)\n``````````````````````````\n\n- Better error message if there's a duplicate key in a map.\n\n\nVersion 0.1.3 (2018-10-30)\n``````````````````````````\n\n- An exception is thrown if there's a duplicate key in a map.\n\n\nVersion 0.1.2 (2018-09-04)\n``````````````````````````\n\n- Change formatting for map and list in dumps. The trailing } and ] are now on a line\n down and at the original index.\n\n\nVersion 0.1.1 (2018-03-13)\n``````````````````````````\n\n- A decimal with an uppercase 'E' in the exponent wasn't being recognized.\n\n\nVersion 0.1.0 (2018-01-29)\n``````````````````````````\n\n- A map key can't be null, following change in spec.\n\n\nVersion 0.0.26 (2018-01-29)\n```````````````````````````\n\n- Remove '//' as a comment, following change in spec.\n\n- Allow 'e' and 'E' in the exponent of a decimal, following change in spec.\n\n\nVersion 0.0.25 (2018-01-12)\n```````````````````````````\n\n- Better error message when the end of the document is reached without a map being\n closed.\n\n\nVersion 0.0.24 (2018-01-11)\n```````````````````````````\n\n- Fix bug where an integer after a value (and before a ',' or '}') in a map doesn't\n give a good error.\n\n\nVersion 0.0.23 (2018-01-09)\n```````````````````````````\n\n- A map key can't now be a list or a map.\n\n\nVersion 0.0.22 (2018-01-08)\n```````````````````````````\n\n- A map key can now be of any type.\n\n- The 'set' type has been removed from Zish.\n\n- Zish now recognizes the full set of Unicode EOL sequences.\n\n- The 'float' type has been removed from Zish.\n\n- Fixed bug when sorting map with keys of more than one type.\n\n\nVersion 0.0.21 (2018-01-04)\n```````````````````````````\n\n- Give a better error if the end of the document is reached before a map is completed.\n\n\nVersion 0.0.20 (2018-01-04)\n```````````````````````````\n\n- Give an error if there are multiple top-level values, rather than silently truncating.\n\n\nVersion 0.0.19 (2017-09-27)\n```````````````````````````\n\n- Decimal exponent dumped as ``E`` rather than ``d``.\n\n\nVersion 0.0.18 (2017-09-12)\n```````````````````````````\n\n- Add tests for float formatting.\n\n\nVersion 0.0.17 (2017-09-12)\n```````````````````````````\n\n- Tighten up parsing of container types.\n- Make sure floats are formatted without an uppercase E.\n\n\nVersion 0.0.16 (2017-09-06)\n```````````````````````````\n\n- Allow lists and sets as keys.\n\n\nVersion 0.0.15 (2017-09-05)\n```````````````````````````\n\n- Fixed map parsing bug where an error wasn't reported properly if it was expecting a\n ``:`` but got an integer.\n\n\nVersion 0.0.14 (2017-09-05)\n```````````````````````````\n\n- Fixed bug where sets couldn't be formatted.\n\n\nVersion 0.0.13 (2017-08-30)\n```````````````````````````\n\n- Performance improvement.\n\n\nVersion 0.0.12 (2017-08-30)\n```````````````````````````\n\n- Add Travis configuration.\n\n\nVersion 0.0.11 (2017-08-30)\n```````````````````````````\n\n- Give a better error message if a string isn't closed.\n\n\nVersion 0.0.10 (2017-08-29)\n```````````````````````````\n\n- New native parser that doesn't use antlr. It's about twice as fast.\n\n\nVersion 0.0.9 (2017-08-24)\n``````````````````````````\n\n- Fix bug where ``int`` was being parsed as ``Decimal``.\n- Make bytes type return a ``bytes`` rather than a ``bytearray``.\n\n\nVersion 0.0.8 (2017-08-24)\n``````````````````````````\n\n- Container types aren't allowed as map keys.\n\n- Performance improvements.\n\n\nVersion 0.0.7 (2017-08-22)\n``````````````````````````\n\n- Fix bug with UTC timestamp formatting.\n\n\nVersion 0.0.6 (2017-08-22)\n``````````````````````````\n\n- Fix bug in timestamp formatting.\n\n- Add note about comments.\n\n\nVersion 0.0.5 (2017-08-18)\n``````````````````````````\n\n- Fix bug where ``dumps`` fails for a ``tuple``.\n\n\nVersion 0.0.4 (2017-08-15)\n``````````````````````````\n\n- Simplify integer types.\n\n\nVersion 0.0.3 (2017-08-09)\n``````````````````````````\n\n- Fixed bug where interpreter couldn't find the ``zish.antlr`` package in eggs.\n\n- Removed a few superfluous escape sequences.\n\n\nVersion 0.0.2 (2017-08-05)\n``````````````````````````\n\n- Now uses RFC3339 for timestamps.\n\n\nVersion 0.0.1 (2017-08-03)\n``````````````````````````\n\n- Fix bug where an EOF could cause an infinite loop.\n\n\nVersion 0.0.0 (2017-08-01)\n``````````````````````````\n\n- First public release. Passes all the tests.\n",
"bugtrack_url": null,
"license": "MIT No Attribution",
"summary": "A Python library for the Zish format.",
"version": "0.1.11",
"project_urls": {
"Homepage": "https://github.com/tlocke/zish_python"
},
"split_keywords": [
"zish"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "b969cbdac2cf46c7dd59585e9b46a0ca44fbec30cdba9e9814e8ae434d01e973",
"md5": "2e0a698ab8cd702ac9612f5b350e22d0",
"sha256": "60c66a9d396a2d1be0051ca91f273196e98f14944b5df8009e6a4b30c782c49c"
},
"downloads": -1,
"filename": "zish-0.1.11-py3-none-any.whl",
"has_sig": false,
"md5_digest": "2e0a698ab8cd702ac9612f5b350e22d0",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 9189,
"upload_time": "2023-10-09T19:32:40",
"upload_time_iso_8601": "2023-10-09T19:32:40.712809Z",
"url": "https://files.pythonhosted.org/packages/b9/69/cbdac2cf46c7dd59585e9b46a0ca44fbec30cdba9e9814e8ae434d01e973/zish-0.1.11-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "5ceb138db79f12b3806b4df4c1a3d560c90dc761b8e9e49c8bd18268cf4d1aaf",
"md5": "7ab75749cc8f7256531c58381d03bf42",
"sha256": "0164f7ed2edb67e0bff04ca5e25ae1a4f960751c8b18357279c582d4ca27ea89"
},
"downloads": -1,
"filename": "zish-0.1.11.tar.gz",
"has_sig": false,
"md5_digest": "7ab75749cc8f7256531c58381d03bf42",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 16022,
"upload_time": "2023-10-09T19:32:42",
"upload_time_iso_8601": "2023-10-09T19:32:42.764488Z",
"url": "https://files.pythonhosted.org/packages/5c/eb/138db79f12b3806b4df4c1a3d560c90dc761b8e9e49c8bd18268cf4d1aaf/zish-0.1.11.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-10-09 19:32:42",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "tlocke",
"github_project": "zish_python",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "zish"
}