{ "info": { "author": "Hagai Helman Tov", "author_email": "hagai.helman@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6" ], "description": "# JSOP - JSON-Style Object Persistence\n\n**JSOP** is a persistence engine that allows an application to store a large amount of JSON-style data on disk, but to access it in an efficient way.\n\nIt is based on the ```dbm``` module, but offers a much easier-to-use API.\n\nJSOP is also designed to enable easy migration of data in existing applications, that already store data in JSON files, with minimal changes to the code.\n\n## Installation\n\n```bash\npip3 install jsop\n```\n\n## Quickstart Guide\n\n### Creating a new JSOP file\n\nProgrammatically :\n\n```python\n# 'data' is any JSON-serializable object.\n\nimport jsop\n\njsop.JSOP(\"/path/to/jsop\").init(data)\n```\n\nOr from the command line:\n\n```bash\npython3 -m jsop init /path/to/jsop /path/to/data.json\n```\n\n(If an initial JSON file is not given, the file will be initialized with an empty map.)\n\n### Read and Write\n\n```python\nwith jsop.JSOP(\"/path/to/jsop\") as data:\n name = data[\"name\"]\n data[\"age\"] = 30\n for friend in data[\"friends\"]:\n print(friend[\"name\"])\n```\n\n## Supported Operations\n\n### Assignments\n\nYou can store any JSON-serializable data with JSOP using simple assignment. For example:\n\n```python\npath = \"/path/to/jsop\"\n\njsop.JSOP(path).init() # initalize with an empty map.\n\nwith jsop.JSOP(path) as data:\n data[\"string\"] = \"Hello, World!\"\n data[\"boolean\"] = True\n data[\"map\"] = {\"a\": 1, \"b\": 2, \"c\": 3}\n data[\"map\"][\"d\"] = 4\n data[\"map\"][\"list\"] = [5,6,7]\n```\n\nThe file will be saved once the ```with``` block exits.\n\n### Accessing Data\n\nWhen you retrieve data of primitive types, you just get the corresponding python type:\n\n```python\nwith jsop.JSOP(path) as data:\n my_string = data[\"string\"]\n # type(my_string) is str\n\n my_int = data[\"map\"][\"c\"]\n # type(my_int) is int\n```\n\nHowever, when you retrieve a map or a list, you get special objects, named ```JDict``` and ```JList```, respectively.\n\n### Map Operations\n\nWith ```JDict```, you can do most of the things you can do with a python ```dict```:\n\n```python\nwith jsop.JSOP(path) as data:\n my_map = data[\"map\"]\n # type(my_map) is JDict\n \n a = my_map[\"a\"] # item access\n my_map[\"b\"] = 3 # item assignment\n del my_map[\"c\"] # item removal\n if \"d\" in my_map:\n pass # using the \"in\" operator\n length = len(my_map) # getting map's size\n keys = my_map.keys() # getting list of keys\n for key in my_map:\n pass # iteration over keys\n if my_map == my_map:\n pass # comparison with a JDict\n if my_map == {\"a\": 1, \"b\": 3}:\n pass # comparison with a Python dict\n my_map.clear() # removing all keys from a map\n```\n\nAlso, you can convert the map to a regular python ```dict```, by using the ```export()``` method:\n\n```python\nwith jsop.JSOP(path) as data:\n my_map = data[\"map\"].export()\n # type(my_map) is dict\n\n my_map[\"e\"] = 5\n\n data[\"map\"] = my_map\n```\n\nNote that like a JSON map, the keys in a JSOP map are always strings. If a different object is given as a key, it is converted to a string.\n\n### List Operations\n\nLikewise, The ```JList``` object supports many of the operations supported by a python ```list```:\n\n```python\nwith jsop.JSOP(path) as data:\n my_list = data[\"map\"][\"list\"]\n # type(my_list) is JList\n\n for item in my_list:\n pass # iteration over items\n my_list.append(8) # adding an item\n eight = my_list.pop() # removing (and returning) the last item\n six = my_list[1]\t\t # item access by index\n my_list[1] = 9 # item assignment\n my_list.remove(9) # removing an arbitrary item\n if 8 in my_list:\n pass # using the \"in\" operator\n length = len(my_list) # getting list's size\n if my_list == my_list:\n pass # comparison with a JList\n if my_list == [5,6,7]:\n pass # comparison with a Python list\n my_list.clear() # removing all items from list\n```\n\nLike as in ```JDict```, ```JList``` also supports the ```export()``` method, which returns a python ```list```:\n\n```python\nwith jsop.JSOP(path) as data:\n my_list = data[\"map\"][\"list\"].export()\n # type(my_list) is list\n```\n\n## Copy and Backup\n\nIn order to create copy a JSOP file, it is recommended to export its content to JSON. The reason is that JSON files take less space, and also because of partability: this practice avoids problems resulting from the use of different ```dbm``` implementations on different systems.\n\nThis can be done from the command line:\n\n```bash\npython3 -m jsop export /path/to/jsop /path/to/copy.json\n```\n\nIf JSON file path is not given, the result will be printed to the standard output.", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/hagai-helman/jsop", "keywords": "JSON,dbm,persistence", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "jsop", "package_url": "https://pypi.org/project/jsop/", "platform": "", "project_url": "https://pypi.org/project/jsop/", "project_urls": { "Homepage": "https://github.com/hagai-helman/jsop" }, "release_url": "https://pypi.org/project/jsop/1.0.1/", "requires_dist": null, "requires_python": "~=3.6", "summary": "A way to store large amounts of JSON-style data on disk, and to access it quickly.", "version": "1.0.1" }, "last_serial": 4824894, "releases": { "0.2.1": [ { "comment_text": "", "digests": { "md5": "9619be37aae0be6dceb3885615a084b2", "sha256": "f8f12e824cdbe7061fc3bc25aaa59733d9500e889d1708bd867e0722754859ce" }, "downloads": -1, "filename": "jsop-0.2.1.tar.gz", "has_sig": false, "md5_digest": "9619be37aae0be6dceb3885615a084b2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3680, "upload_time": "2019-02-03T16:04:39", "url": "https://files.pythonhosted.org/packages/c4/3f/93592fdce5a2d5802d940e2db57a6d92b99e8bc7f6d8f8c0e27c88ad711c/jsop-0.2.1.tar.gz" } ], "0.2.2": [ { "comment_text": "", "digests": { "md5": "826204569536121ca09d24faca1cdac1", "sha256": "a12a2c053e39b39ba3c00a1adfa5ef63c56da1f452dd717ff1963b6b49fe981b" }, "downloads": -1, "filename": "jsop-0.2.2.tar.gz", "has_sig": false, "md5_digest": "826204569536121ca09d24faca1cdac1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3657, "upload_time": "2019-02-03T16:09:08", "url": "https://files.pythonhosted.org/packages/78/9b/4ed7876da7d2317dd02c3ae0929be97fd0a4bee8139671c8a41066f4f68c/jsop-0.2.2.tar.gz" } ], "0.2.3": [ { "comment_text": "", "digests": { "md5": "7333654614937dc99101eac16221b4e1", "sha256": "f9807cd0eab05340a41ed6f3b386477496974f89faea32840e5e5b513960d73a" }, "downloads": -1, "filename": "jsop-0.2.3.tar.gz", "has_sig": false, "md5_digest": "7333654614937dc99101eac16221b4e1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4292, "upload_time": "2019-02-03T16:47:44", "url": "https://files.pythonhosted.org/packages/d9/a2/4670993c8ac8d6da54247713e00e1043fddc6fa486d6bc8e4ab451290b22/jsop-0.2.3.tar.gz" } ], "0.3.1": [ { "comment_text": "", "digests": { "md5": "820e2ec1892485e6fe83ca1d841d44a4", "sha256": "a4a042c96634265da1f82bfa4d1f4b516ee2214906940ad60e771e687a3961dd" }, "downloads": -1, "filename": "jsop-0.3.1.tar.gz", "has_sig": false, "md5_digest": "820e2ec1892485e6fe83ca1d841d44a4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5227, "upload_time": "2019-02-05T00:28:00", "url": "https://files.pythonhosted.org/packages/94/09/a81729dc5d493b3a59c9ca28c9d8d6b3d8e3a3c64b4a21d6d1c34cdfcf2e/jsop-0.3.1.tar.gz" } ], "0.5.0": [ { "comment_text": "", "digests": { "md5": "fe369601d42d6121369c29604e0adf02", "sha256": "659132d746030a11b7b74a9346b9e547204d04a4365bffae2a102a0e55755e5a" }, "downloads": -1, "filename": "jsop-0.5.0.tar.gz", "has_sig": false, "md5_digest": "fe369601d42d6121369c29604e0adf02", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5679, "upload_time": "2019-02-09T14:19:19", "url": "https://files.pythonhosted.org/packages/c4/ff/8609cb789335b265396d704d2f06ebe170641bdf3993f2a3c990f1471b1e/jsop-0.5.0.tar.gz" } ], "0.6.0": [ { "comment_text": "", "digests": { "md5": "dafe9082a758184e46a1882585139e19", "sha256": "6364df7a395009eaa74ee4da2875d1614c257614ed19e169b2aa788b9eaec391" }, "downloads": -1, "filename": "jsop-0.6.0.tar.gz", "has_sig": false, "md5_digest": "dafe9082a758184e46a1882585139e19", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6554, "upload_time": "2019-02-13T23:33:05", "url": "https://files.pythonhosted.org/packages/7b/71/c47a12437b9ada3c64be67ff73d155defddc68af490451b958784e5d3724/jsop-0.6.0.tar.gz" } ], "0.7.0": [ { "comment_text": "", "digests": { "md5": "4e063bf61a8dbd24673a8c0f1c11fffd", "sha256": "7f0c03f081252bb653098e1862ff908a8084f9db3a94b5e7a0854b7014399a0c" }, "downloads": -1, "filename": "jsop-0.7.0.tar.gz", "has_sig": false, "md5_digest": "4e063bf61a8dbd24673a8c0f1c11fffd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6563, "upload_time": "2019-02-13T23:52:24", "url": "https://files.pythonhosted.org/packages/63/a7/7c79661035fac14f6b989da89c83a8a3cb1667bdf82cc7aa554ae941e6c7/jsop-0.7.0.tar.gz" } ], "0.7.1": [ { "comment_text": "", "digests": { "md5": "4c5f8af9058752cdad6ff6214e9d1fde", "sha256": "03923d9fc1434197ef478e58cdf0e63af289a03c434dc67869b1da52a2383f2d" }, "downloads": -1, "filename": "jsop-0.7.1.tar.gz", "has_sig": false, "md5_digest": "4c5f8af9058752cdad6ff6214e9d1fde", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6819, "upload_time": "2019-02-14T16:29:55", "url": "https://files.pythonhosted.org/packages/dd/d4/96021760a742bbf2fcc309b858bec8e715ce09c4e68c7c8ad9a4d6596c30/jsop-0.7.1.tar.gz" } ], "1.0.0": [ { "comment_text": "", "digests": { "md5": "00de7a25988e5cf374d106275c9f63e7", "sha256": "90e414a8f0be195e22ec8494dde5f9d6b1b7d52a04a77de8008f71d19c7e4c5c" }, "downloads": -1, "filename": "jsop-1.0.0.tar.gz", "has_sig": false, "md5_digest": "00de7a25988e5cf374d106275c9f63e7", "packagetype": "sdist", "python_version": "source", "requires_python": "~=3.6", "size": 6828, "upload_time": "2019-02-14T18:39:03", "url": "https://files.pythonhosted.org/packages/c0/13/9173f55afab7250342e2118ad213201dd08965b0dbd84ab758e936396721/jsop-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "9437ce36a3407914b364ba3cbb852e95", "sha256": "f70bb3d8682138cc35721c6aa9d7a90fd35488daa4597ccfe06184d66a574b3e" }, "downloads": -1, "filename": "jsop-1.0.1.tar.gz", "has_sig": false, "md5_digest": "9437ce36a3407914b364ba3cbb852e95", "packagetype": "sdist", "python_version": "source", "requires_python": "~=3.6", "size": 6945, "upload_time": "2019-02-15T14:08:45", "url": "https://files.pythonhosted.org/packages/4d/99/6b0229339d7b01ce32dea9a2de52e740a0a0d54e5b4d72b38b2992dc4168/jsop-1.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "9437ce36a3407914b364ba3cbb852e95", "sha256": "f70bb3d8682138cc35721c6aa9d7a90fd35488daa4597ccfe06184d66a574b3e" }, "downloads": -1, "filename": "jsop-1.0.1.tar.gz", "has_sig": false, "md5_digest": "9437ce36a3407914b364ba3cbb852e95", "packagetype": "sdist", "python_version": "source", "requires_python": "~=3.6", "size": 6945, "upload_time": "2019-02-15T14:08:45", "url": "https://files.pythonhosted.org/packages/4d/99/6b0229339d7b01ce32dea9a2de52e740a0a0d54e5b4d72b38b2992dc4168/jsop-1.0.1.tar.gz" } ] }