{ "info": { "author": "Ryan Miller", "author_email": "ryan@devopsmachine.com", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 2", "Programming Language :: Python :: 3", "Topic :: Utilities" ], "description": "######\nEncase\n######\n\n\n.. image:: https://travis-ci.org/RyanMillerC/encase.svg?branch=master\n :target: https://travis-ci.org/RyanMillerC/encase\n\nAn extension of the Python built-in Dictionary class for working with large\ndatasets.\n\n\nFeatures\n========\n\nThe Encase class is used to create dictionary objects with:\n\n* Attribute access via dot (.) notation\n* Nested instances\n* Recursive conversion for existing dictionaries, including nested lists of\n dictionaries\n\nThis allows key/value pairs to be accessed like instance attributes, which\nmakes code dealing with APIs that return large amounts of JSON easier to read\nand write. Instead of writing,\n\n``relevant_data = api_result['data']['subset']['subsubset']``\n\nyou can accomplish the same with,\n\n``relevant_data = api_result.data.subset.subsubset``.\n\n\nInstallation\n============\n\nInstall this package using pip:\n\n``pip install encase``\n\n\nDocumentation\n=============\n\nEncase is an extension of the Python dictionary class and therefore inherits\nall attributes and methods of regular dictionary objects. This also means that\nan Encase instance can be used as a drop in replacement for a dict object.\n\nUsage\n-----\n\nBasic Usage\n::\n\n >>> from encase import Encase\n >>> d = Encase()\n >>> d.hello_world = \"Hello World!\"\n >>> print(d.hello_world)\n Hello World!\n\nInstances can also be nested\n::\n >>> d.child = Encase()\n >>> d.child.message = \"Encase Instances can be nested\"\n >>> print(d.child.message)\n Encase Instances can be nested\n\nMethods\n-------\n\nget(key)\n\"\"\"\"\"\"\"\"\nReturn value of attribute at 'key'. This is the method form of using,\n``encase.child``. This can be used when you won't know a key name prior and\nneed to use a variable for 'key'.\n\n``param str key``\n Name of attribute whose value will be returned\n\nset(key, value)\n\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\nSet value of attribute at 'key'. This is the method form of using,\n``encase.child = 'Value'``. This can be used when you won't know key name prior\nand need to use a variable for 'key'.\n\n``param str key``\n Name of attribute to set\n``param str value``\n Value to set for attribute\n\n \nExamples\n========\n\nCreate a JSON File from Encase instance:\n::\n\n >>> import json\n >>> j = Encase()\n >>> j.data = Encase()\n >>> j.data.info = \"JSON can be converted into nested Encases\"\n >>> j.data.features = []\n >>> j.data.features.append('Recursively transform dictionaries')\n >>> j.data.features.append('Supports recursion through lists as well')\n >>> j.data.features.append(Encase())\n >>> j.data.features[2].example = \"Example of a Encase in a list\"\n\n >>> print(j)\n {\n 'data': {\n 'info': 'JSON can be converted into nested Encases',\n 'features': [\n 'Resursively transform dictionaries into Encases',\n 'Supports recursion through lists as well',\n {\n 'example': 'Example of a Encase in a list'\n }\n ]\n }\n }\n\n >>> with open('example.json', 'w') as stream:\n ... json.dump(j, stream)\n\nRead a JSON File into Encase instance:\n::\n\n >>> with open('example.json', 'r') as stream:\n ... j_data = json.load(stream)\n\n >>> j_stack = Encase(j_data)\n >>> print(j_stack.data.info)\n JSON can be converted into nested Encases\n\n >>> for item in j_stack.data.features:\n ... print(item)\n ...\n Resursively transform dictionaries into Encases\n Supports recursion through lists as well\n {'example': 'Example of a Encase in a list'}\n\n >>> print(j_stack.data.features[2].example)\n Example of a Encase in a list\n\n\nAuthor\n======\n\nRyan Miller - ryan@devopsmachine.com", "description_content_type": "", "docs_url": null, "download_url": "https://github.com/RyanMillerC/encase/archive/1.1.tar.gz", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/RyanMillerC/encase", "keywords": "data,dictionary", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "encase", "package_url": "https://pypi.org/project/encase/", "platform": "", "project_url": "https://pypi.org/project/encase/", "project_urls": { "Download": "https://github.com/RyanMillerC/encase/archive/1.1.tar.gz", "Homepage": "https://github.com/RyanMillerC/encase" }, "release_url": "https://pypi.org/project/encase/1.1/", "requires_dist": null, "requires_python": "", "summary": "A Better Dictionary Class", "version": "1.1" }, "last_serial": 4058546, "releases": { "1.0": [ { "comment_text": "", "digests": { "md5": "0af0b0f34749e673c0c08f0967b164f4", "sha256": "09a145350be1fbb689d2a5668152e176230872b0d8e56ae333bbec927d80d576" }, "downloads": -1, "filename": "encase-1.0.tar.gz", "has_sig": false, "md5_digest": "0af0b0f34749e673c0c08f0967b164f4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 1450, "upload_time": "2018-04-14T06:24:37", "url": "https://files.pythonhosted.org/packages/29/4c/a699ffe0ba67fb41299a8db1457239f2da7ce27eb60a01f559b590a0d1a1/encase-1.0.tar.gz" } ], "1.0.2": [ { "comment_text": "", "digests": { "md5": "9c41bcdaa174f7216add3f3defe63cef", "sha256": "5b46b2e6e5189c274a0494a408414611242fa03d4b8804e2d9ff49508ce3e6c3" }, "downloads": -1, "filename": "encase-1.0.2.tar.gz", "has_sig": false, "md5_digest": "9c41bcdaa174f7216add3f3defe63cef", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2607, "upload_time": "2018-04-15T18:28:50", "url": "https://files.pythonhosted.org/packages/dc/e0/bd116cc4b7902cbc030ee730e3457aa14bd692d82cb0233a96adc430d49a/encase-1.0.2.tar.gz" } ], "1.1": [ { "comment_text": "", "digests": { "md5": "bf833c22afa40b28201928c94b6e841a", "sha256": "35d338f63d102e4ac0c9caa458004054d6772856dcea0706033d25fbb940d791" }, "downloads": -1, "filename": "encase-1.1.tar.gz", "has_sig": false, "md5_digest": "bf833c22afa40b28201928c94b6e841a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4079, "upload_time": "2018-07-13T16:20:50", "url": "https://files.pythonhosted.org/packages/ea/de/a91fca6d42ce1d4c95723eba90379763c6b3c6c8330f247740f0c5bbd917/encase-1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "bf833c22afa40b28201928c94b6e841a", "sha256": "35d338f63d102e4ac0c9caa458004054d6772856dcea0706033d25fbb940d791" }, "downloads": -1, "filename": "encase-1.1.tar.gz", "has_sig": false, "md5_digest": "bf833c22afa40b28201928c94b6e841a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4079, "upload_time": "2018-07-13T16:20:50", "url": "https://files.pythonhosted.org/packages/ea/de/a91fca6d42ce1d4c95723eba90379763c6b3c6c8330f247740f0c5bbd917/encase-1.1.tar.gz" } ] }