{ "info": { "author": "Oleg Golovanov", "author_email": "golovanov.ov@gmail.com", "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.7", "Programming Language :: Python :: 3.2", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "PlaneDict\n---------\n\n|Version| |PyVersions| |Status| |Coverage| |License|\n\nPlaneDict is a dict-like class which represents built-in dict class\nas a 'plane' structure, i.e. path-value pairs. Path is a tuple of keys,\nvalue is a value which allows in built-in dict.\n\nSupported methods:\n * native:\n * __check_path__(self, path)\n * overridden:\n * __init__(self, seq=None, _factory=dict, \\**kwargs)\n * __getitem__(self, path)\n * __setitem__(self, path, value)\n * __delitem__(self, path)\n * __iter__(self)\n * __len__(self)\n * __repr__(self)\n * get(self, key, default=None, stddict=False)\n * inherited:\n * clear(self)\n * pop(self, key, default=)\n * popitem(self)\n * setdefault(self, key, default=None)\n * update(\\*args, \\**kwds)\n * __contains__(self, key)\n * __eq__(self, other)\n * __ne__(self, other)\n * keys(self)\n * iterkeys(self)\n * values(self)\n * itervalues(self)\n * items(self)\n * iteritems(self)\n\nInstallation\n------------\n::\n\n $ pip install planedict\n\nNotes\n-----\n1. Constructor have _factory argument, it expects dict-like class (dict by default).\n OrderedDict is useful to use.\n2. After removing value by path, if higher dicts will become\n empty, they will be removed.\n3. get method has stddict parameter. If it's True then method will return\n built-in dict, it will return PlaneDict object else.\n4. If PlaneDict object was passed to update method, it's a 'soft'\n update, i.e. the intersecting values will be overridden and the new\n values will be added.\n If standard dict passed to update method, it works as a\n standard update method.\n5. __check_path__ method takes a sequence of keys.\n For example: __check_path__((1, [2, [3]], 4, (5, 6), (i for i in [7, 8])))\n returns (1, 2, 3, 4, (5, 6), 7, 8). As you can see from the\n example above, tuple is not unfold, because tuple can be\n a key of dict. So if you want to get a single-key tuple,\n you should do this:\n\n .. code-block:: python\n\n d[('key',),]\n\n or\n\n .. code-block:: python\n\n path = 'key',\n d[path,]\n\nSee examples.\n\n\nExamples\n--------\n\n.. code-block:: python\n\n d = PlaneDict(\n {\n 'key1': {\n 'key2': 'val2',\n 'key3': 'val3'\n },\n 'key4': {\n 'key5': {\n 'key6': 'val6'\n }\n }\n }\n )\n\n >>> len(d)\n 3\n\n >>> d['key4', 'key5', 'key6']\n 'val6'\n\n >>> path = ['key1', 'key2', 'key10']\n >>> d[path] = 1\n >>> d[path]\n 1\n\n >>> del d['key4', 'key5', 'key6']\n >>> d\n {'key1': {'key3': 'val3', 'key2': 'val2'}}\n\n >>> list(d)\n [('key1', 'key3'),\n ('key1', 'key2'),\n ('key4', 'key5', 'key6')]\n\n >>> d.get('key1', stddict=True)\n {'key3': 'val3', 'key2': 'val2'}\n >>> d.get(('key1', 'key2'))\n 'val2'\n\n >>> d.clear()\n >>> print d\n {}\n\n >>> d.pop(['key4', 'key5', 'key6'], default=None)\n 'val6'\n >>> d.pop(['key4', 'key5', 'key6'], default=None)\n None\n\n >>> d.popitem()\n (('key1', 'key3'), 'val3')\n\n >>> d.setdefault(['key1', 'key2'], default=None)\n 'val2'\n >>> d.setdefault(['key1', 'key7', 'key8', 'key9'], default=None)\n >>> d['key1']\n {'key3': 'val3', 'key2': 'val2', 'key7': {'key8': {'key9': None}}}\n\n >>> update = {'key1': {'key10': 'val10'}}\n >>> d.update(PlaneDict(update))\n >>> d\n {'key1': {'key2': 'val2', 'key3': 'val3', 'key10': 'val10'}, 'key4': {'key5': {'key6': 'val6'}}}\n >>> d.update(update)\n >>> d\n {'key1': {'key10': 'val10'}, 'key4': {'key5': {'key6': 'val6'}}}\n\n >>> d.keys()\n [('key1', 'key3'),\n ('key1', 'key2'),\n ('key4', 'key5', 'key6')]\n\n >>> d.values()\n ['val3', 'val2', 'val6']\n\n >>> d.items()\n [(('key1', 'key3'), 'val3'),\n (('key1', 'key2'), 'val2'),\n (('key4', 'key5', 'key6'), 'val6')]\n\n >>> ['key1', 'key2'] in d\n True\n >>> ['key1', 'missed_key'] in d\n False\n\n >>> d == PlaneDict({'key1': {'key2': 'val2', 'key3': 'val3'}, 'key4': {'key5': {'key6': 'val6'}}})\n True\n\n >>> d == {'key1': {'key2': 'val2', 'key3': 'val3'}, 'key4': {'key5': {'key6': 'val6'}}}\n False\n\nLicense\n-------\n\nMIT licensed. See the bundled `LICENSE `_ file for more details.\n\n.. |Version| image:: https://img.shields.io/pypi/v/planedict.svg\n :target: https://pypi.python.org/pypi/planedict\n.. |PyVersions| image:: https://img.shields.io/pypi/pyversions/planedict.svg\n :target: https://pypi.python.org/pypi/planedict\n.. |Status| image:: https://img.shields.io/travis/oleg-golovanov/planedict.svg\n :target: https://travis-ci.org/oleg-golovanov/planedict\n.. |Coverage| image:: https://img.shields.io/coveralls/oleg-golovanov/planedict.svg\n :target: https://coveralls.io/github/oleg-golovanov/planedict\n.. |License| image:: https://img.shields.io/github/license/oleg-golovanov/planedict.svg\n :target: https://github.com/oleg-golovanov/planedict/blob/master/LICENSE\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/oleg-golovanov/planedict", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "planedict", "package_url": "https://pypi.org/project/planedict/", "platform": "any", "project_url": "https://pypi.org/project/planedict/", "project_urls": { "Homepage": "https://github.com/oleg-golovanov/planedict" }, "release_url": "https://pypi.org/project/planedict/1.4.0/", "requires_dist": null, "requires_python": "", "summary": "PlaneDict is a dict-like class which represents built-in dict class as a 'plane' structure, i.e. pairs path-value. Path is a tuple of keys, value is value which allows in built-in dict.", "version": "1.4.0" }, "last_serial": 3159271, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "07fa15acdfd33e64d767d12ade197512", "sha256": "f1d4480c89c1977ff51d2615310df8177521baaa90194c52118af8618a487bce" }, "downloads": -1, "filename": "planedict-1.0.0.tar.gz", "has_sig": false, "md5_digest": "07fa15acdfd33e64d767d12ade197512", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3678, "upload_time": "2014-08-08T21:03:56", "url": "https://files.pythonhosted.org/packages/de/61/1bc58969e540e985018404486ae540c571805aa5ba65c2346b681f94feb3/planedict-1.0.0.tar.gz" } ], "1.1.1": [ { "comment_text": "", "digests": { "md5": "ab1c39cda53ad8dedb46ac2b063f45a6", "sha256": "a5f039e693e4e4b5c1792ad270d6ab9fa573a8929ee595647d2a9bec65b9a9ea" }, "downloads": -1, "filename": "planedict-1.1.1.tar.gz", "has_sig": false, "md5_digest": "ab1c39cda53ad8dedb46ac2b063f45a6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3753, "upload_time": "2014-11-14T10:44:12", "url": "https://files.pythonhosted.org/packages/67/8c/1d10850138fabd1462e0b6b22af9ecb285eacfe498ff99783a63dfca8def/planedict-1.1.1.tar.gz" } ], "1.2.0": [ { "comment_text": "", "digests": { "md5": "5f5cff2fac531115dffdd5fa6309f031", "sha256": "73035ef726a0171b665c3ae02132eca9393850cdc4705ad59df570c89aa96e21" }, "downloads": -1, "filename": "planedict-1.2.0.tar.gz", "has_sig": false, "md5_digest": "5f5cff2fac531115dffdd5fa6309f031", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4408, "upload_time": "2015-07-01T22:18:45", "url": "https://files.pythonhosted.org/packages/f9/9a/e5b33e0499598d4278e627372ca55bd3040abfe83dec9cc308386d0aef13/planedict-1.2.0.tar.gz" } ], "1.3.1": [ { "comment_text": "", "digests": { "md5": "2582c9bfe1ac887e69c5d583710b2eca", "sha256": "5d312fd877d20d7a350aa1e26e982c9cd8c25ee63d62d5bce6fd3c5a363044b4" }, "downloads": -1, "filename": "planedict-1.3.1.tar.gz", "has_sig": false, "md5_digest": "2582c9bfe1ac887e69c5d583710b2eca", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4916, "upload_time": "2015-11-15T13:43:28", "url": "https://files.pythonhosted.org/packages/ed/c9/f18adba0ba2dc399dd1765278d96fb66cac3b3b2ff22e9b18c6c5daf1b06/planedict-1.3.1.tar.gz" } ], "1.4.0": [ { "comment_text": "", "digests": { "md5": "d2114cd5f84008645ac880630073be31", "sha256": "5a9fa3befedb9de54d0186b81d73ee46194989197897e04d4c5ce650bed76257" }, "downloads": -1, "filename": "planedict-1.4.0.tar.gz", "has_sig": false, "md5_digest": "d2114cd5f84008645ac880630073be31", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4882, "upload_time": "2017-09-08T13:49:31", "url": "https://files.pythonhosted.org/packages/f1/00/11f34181e4cdaf7e302a7d8af9de74567971beb0e3a4af03752746daf10e/planedict-1.4.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "d2114cd5f84008645ac880630073be31", "sha256": "5a9fa3befedb9de54d0186b81d73ee46194989197897e04d4c5ce650bed76257" }, "downloads": -1, "filename": "planedict-1.4.0.tar.gz", "has_sig": false, "md5_digest": "d2114cd5f84008645ac880630073be31", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4882, "upload_time": "2017-09-08T13:49:31", "url": "https://files.pythonhosted.org/packages/f1/00/11f34181e4cdaf7e302a7d8af9de74567971beb0e3a4af03752746daf10e/planedict-1.4.0.tar.gz" } ] }