{ "info": { "author": "Oliver Bristow", "author_email": "github+pypi@oliverbristow.co.uk", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Database", "Topic :: Software Development" ], "description": "|PyPi Package| |Build Status| |Codacy Rating|\n\njsonstore\n=========\n\nThis module provides a class that maps keys and values from a JSON file\nonto its attributes.\n\nThe goal was to provide a convenient way of loading and saving\nconfiguration in a familiar human readable format. This is a bit more\nflexible than the\n`configparser `__\nmodule which is included with Python.\n\nThis works is tested and working on Python 2.7+ and Python 3.3+. It will\nnot work on 2.6 or lower, but is expected to work on 3.0-3.2. The tests\ndo not work in 3.2.6 due to\n`mistreating `__\nthe \ud83d\udca9 when parsing the test code. This is also tested on pypy and pypy3.\n\nExamples\n--------\n\nBasics\n~~~~~~\n\n.. code:: python\n\n # by default JsonStore commits on every change unless in a transaction\n store = JsonStore('config.json')\n store.a_string = \"something\"\n store.a_list = [1, 2, 3]\n store.a_dictionary = {\n 'dict-list': [{}],\n 'ln(2)': 0.69314718056,\n 'for-you': u\"\ud83d\udc90\",\n }\n\n # you can use [\u2026] to set/get/delete string keys\n store['some_key'] = \"a value\"\n # the key is split on '.'s and works on dictionaries\n del store['a_dictionary.dict-list']\n store['a_dictionary.new_value'] = \"old value\"\n # you can also use the syntactic sugar for tuple keys (explicit lists work too)\n assert store['a_dictionary', 'new_value'] == \"old value\"\n # you can traverse lists too\n assert store['a_list', -1] == 3\n # you can use slices in lists\n assert len(store['a_list', 1:]) == 2\n\n # deep copies are made when assigning values\n my_list = ['fun']\n store.a_list = my_list\n assert store.a_list is not my_list\n assert 'a_list' in store\n\n # deep copies are also returned to avoid unsanitary changes being made\n store.a_dictionary['new_value'] = \"new value\" # won't update the store!\n assert store.a_dictionary['new_value'] == \"old value\"\n assert store.a_dictionary is not store.a_dictionary\n\nTransactions\n~~~~~~~~~~~~\n\n``JsonStore`` objects can be used as `context\nmanagers `__ to provide\ntransactions which are rolled back in the event of an exception. The\ntransaction model is primitive; you can only nest transactions.\n\nWhile a store is put into a transaction, it will not save changes to\nfile until all of the transactions have been closed.\n\n.. code:: python\n\n from jsonstore import JsonStore\n\n # even with auto_commit=True, the file won't be saved until the last contexts has been closed\n with JsonStore('config.json', indent=None, auto_commit=False) as store:\n self.value = 1\n\n # the context manager will roll back changes made if an exception is raised\n store = JsonStore('config.json', indent=None)\n try:\n with store:\n store.value = \"new\"\n raise Exception\n except Exception:\n pass\n # here we see the value that was saved previously\n assert store.value == 1\n\n.. |Build Status| image:: https://travis-ci.org/Code0x58/python-jsonstore.svg?branch=master\n :target: https://travis-ci.org/Code0x58/python-jsonstore\n.. |Codacy Rating| image:: https://api.codacy.com/project/badge/Grade/37ea488773444de59469a3775be83faf\n :target: https://www.codacy.com/app/evilumbrella-github/python-jsonstore?utm_source=github.com&utm_medium=referral&utm_content=Code0x58/python-jsonstore&utm_campaign=Badge_Grade\n.. |PyPi Package| image:: https://badge.fury.io/py/python-jsonstore.svg\n :target: https://pypi.org/project/python-jsonstore/\n\n\n", "description_content_type": "text/x-rst", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/Code0x58/python-jsonstore/", "keywords": "json key value store", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "python-jsonstore", "package_url": "https://pypi.org/project/python-jsonstore/", "platform": "", "project_url": "https://pypi.org/project/python-jsonstore/", "project_urls": { "Homepage": "https://github.com/Code0x58/python-jsonstore/" }, "release_url": "https://pypi.org/project/python-jsonstore/1.1.2/", "requires_dist": null, "requires_python": "", "summary": "", "version": "1.1.2" }, "last_serial": 4601484, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "b0e12612cabdd03b59ed8a82ab09e4c3", "sha256": "e387c56edb5273708ea5b6831bf91db014b67b154592f82dc9a3a7b4275df38a" }, "downloads": -1, "filename": "python_jsonstore-1.0.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "b0e12612cabdd03b59ed8a82ab09e4c3", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 8188, "upload_time": "2017-04-12T19:03:50", "url": "https://files.pythonhosted.org/packages/3b/9d/1753acc65d091c9459915b7490b7b81399f97de833ab73b4e6f753d58bf2/python_jsonstore-1.0.0-py2.py3-none-any.whl" } ], "1.1.0": [ { "comment_text": "", "digests": { "md5": "63dd44b9e23b415859193e59ccc2e7ad", "sha256": "e1b53f6cf182f5f27f41edff6ef8cf5a9f9fd9118790829472999c127ada20df" }, "downloads": -1, "filename": "python_jsonstore-1.1.0-py2.py3-none-any.whl", "has_sig": true, "md5_digest": "63dd44b9e23b415859193e59ccc2e7ad", "packagetype": "bdist_wheel", "python_version": "3.7", "requires_python": null, "size": 6190, "upload_time": "2018-09-05T20:51:50", "url": "https://files.pythonhosted.org/packages/52/78/eeb1f352b69b3ba66f9d69ff0fae3a90cc0a2a62c811e037c37bcc311d34/python_jsonstore-1.1.0-py2.py3-none-any.whl" } ], "1.1.1": [ { "comment_text": "", "digests": { "md5": "c06cbdd9ab747e5de4a83b5dc3ad6ce0", "sha256": "9bde540cd63a45be9434bfe040cc4791909f81f4a35e3dbd306c004eede4c809" }, "downloads": -1, "filename": "python_jsonstore-1.1.1-py2.py3-none-any.whl", "has_sig": true, "md5_digest": "c06cbdd9ab747e5de4a83b5dc3ad6ce0", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 4540, "upload_time": "2018-12-15T02:06:49", "url": "https://files.pythonhosted.org/packages/a5/71/e52996f7de137d5024c14c687c0cab5e4166181aa974706c205db497b9bf/python_jsonstore-1.1.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1aeee884286fa00c0c50686445621df6", "sha256": "836e42ca1ced1532918137a30ced61cf2bd4213af82134894c07c094623482e6" }, "downloads": -1, "filename": "python-jsonstore-1.1.1.tar.gz", "has_sig": true, "md5_digest": "1aeee884286fa00c0c50686445621df6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7081, "upload_time": "2018-12-15T02:06:51", "url": "https://files.pythonhosted.org/packages/29/18/cd1404e6c465c99f101314ad1b2a5bece3a586f2d451626ec08a7086e5d6/python-jsonstore-1.1.1.tar.gz" } ], "1.1.2": [ { "comment_text": "", "digests": { "md5": "856b6dcb70696cea5bfcf9daf41744a4", "sha256": "15c31ad1accfff7c0679511f34a2e78662cd987616cf3210774060e57ed1d65b" }, "downloads": -1, "filename": "python_jsonstore-1.1.2-py2.py3-none-any.whl", "has_sig": true, "md5_digest": "856b6dcb70696cea5bfcf9daf41744a4", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 4539, "upload_time": "2018-12-15T02:11:14", "url": "https://files.pythonhosted.org/packages/f8/e9/9901f96b42255aa8faf49c2588b5fbfeb4bc0b02d54a06e7087c9225d573/python_jsonstore-1.1.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a057584be7ed60ca82f38737040f2197", "sha256": "8191cd73aa019409daa9747d918cba01630993c3354fb067e28b6190ee854d51" }, "downloads": -1, "filename": "python-jsonstore-1.1.2.tar.gz", "has_sig": true, "md5_digest": "a057584be7ed60ca82f38737040f2197", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7071, "upload_time": "2018-12-15T02:11:16", "url": "https://files.pythonhosted.org/packages/68/e0/7d0aa02650ddd80e75ab343fe1dc265fe1db7efb153406247f223572b54d/python-jsonstore-1.1.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "856b6dcb70696cea5bfcf9daf41744a4", "sha256": "15c31ad1accfff7c0679511f34a2e78662cd987616cf3210774060e57ed1d65b" }, "downloads": -1, "filename": "python_jsonstore-1.1.2-py2.py3-none-any.whl", "has_sig": true, "md5_digest": "856b6dcb70696cea5bfcf9daf41744a4", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 4539, "upload_time": "2018-12-15T02:11:14", "url": "https://files.pythonhosted.org/packages/f8/e9/9901f96b42255aa8faf49c2588b5fbfeb4bc0b02d54a06e7087c9225d573/python_jsonstore-1.1.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a057584be7ed60ca82f38737040f2197", "sha256": "8191cd73aa019409daa9747d918cba01630993c3354fb067e28b6190ee854d51" }, "downloads": -1, "filename": "python-jsonstore-1.1.2.tar.gz", "has_sig": true, "md5_digest": "a057584be7ed60ca82f38737040f2197", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7071, "upload_time": "2018-12-15T02:11:16", "url": "https://files.pythonhosted.org/packages/68/e0/7d0aa02650ddd80e75ab343fe1dc265fe1db7efb153406247f223572b54d/python-jsonstore-1.1.2.tar.gz" } ] }