{ "info": { "author": "metagriffin", "author_email": "mg.pypi@uberdev.org", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python" ], "description": "=================================\n(Yet Another) Auto-Attribute Dict\n=================================\n\nAn ``aadict`` is a python dict sub-class that allows attribute-style\naccess to dict items, e.g. ``d.foo`` is equivalent to ``d['foo']``.\n``aadict`` also provides a few other helpful methods, such as ``pick``\nand ``omit`` methods. Also, an ``aadict`` is more call chaining\nfriendly (e.g. methods such as `update` return ``self``) and is\npickle'able.\n\n\nProject\n=======\n\n* Homepage: https://github.com/metagriffin/aadict\n* Bugs: https://github.com/metagriffin/aadict/issues\n\n\nTL;DR\n=====\n\nInstall:\n\n.. code-block:: bash\n\n $ pip install aadict\n\nUse:\n\n.. code-block:: python\n\n from aadict import aadict\n\n # attribute access\n d = aadict(foo='bar', zig=87)\n assert d.foo == d['foo'] == 'bar'\n\n # helper methods\n assert d.pick('foo') == {'foo': 'bar'}\n assert d.omit('foo') == {'zig': 87}\n\n # method chaining\n d2 = aadict(x='y').update(d).omit('zig')\n assert d2.x == 'y' and d2.foo == 'bar' and d2.zig is None\n\n # converting a dict to an aadict recursively\n d3 = aadict.d2ar(dict(foo=dict(bar='zig')))\n assert d3.foo.bar == 'zig'\n\n\nDetails\n=======\n\nThe aadict module provides the following functionality:\n\n\naadict\n------\n\nAn `aadict` object is basically identical to a `dict` object, with the\nexception that attributes, if not reserved for other purposes, map to\nthe dict's items. For example, if a dict ``d`` has an item ``'foo'``,\nthen a request for ``d.foo`` will return that item lookup. aadicts\nalso have several helper methods, for example ``aadict.pick``. To\nfetch the value of an item that has the same name as one of the helper\nmethods you need to reference it by item lookup,\ni.e. ``d['pick']``. The helper methods are:\n\n* **aadict.pick** instance method:\n\n Returns a new aadict, reduced to only include the specified\n keys. Example:\n\n .. code-block:: python\n\n d = aadict(foo='bar', zig=87, zag=['a', 'b'])\n assert d.pick('foo', 'zag') == {'foo': 'bar', 'zag': ['a', 'b']}\n\n* **aadict.omit** instance method:\n\n Identical to the ``aadict.pick`` method, but returns the complement,\n i.e. all of those keys that are *not* specified. Example:\n\n .. code-block:: python\n\n d = aadict(foo='bar', zig=87, zag=['a', 'b'])\n assert d.omit('foo', 'zag') == {'zig': 87}\n\n* **aadict.d2ar** class method:\n\n Recursively converts the supplied `dict` to an `aadict`, including\n all sub-list and sub-dict types. Due to being recursive, but only\n copying dict-types, this is effectively a hybrid of a shallow and\n a deep clone. Example:\n\n .. code-block:: python\n\n d = aadict.d2ar(dict(foo=dict(bar='zig')))\n assert d.foo.bar == 'zig'\n\n Without the recursive walking, the ``.bar`` attribute syntax\n would yield an AttributeError exception because d.foo would\n reference a `dict` type, not an `aadict`.\n\n* **aadict.d2a** class method:\n\n Converts the supplied `dict` to an `aadict`. Example:\n\n .. code-block:: python\n\n d = aadict.d2a(dict(foo='bar'))\n assert d.foo == d['foo'] == 'bar'\n\n Note that this is identical to just using the constructor,\n but is provided as a symmetry to the ``aadict.d2ar`` class\n method, e.g.:\n\n .. code-block:: python\n\n d = aadict(dict(foo='bar'))\n assert d.foo == d['foo'] == 'bar'\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/metagriffin/aadict", "keywords": "auto attribute access dict helpers pick omit", "license": "GPLv3+", "maintainer": "", "maintainer_email": "", "name": "aadict", "package_url": "https://pypi.org/project/aadict/", "platform": "any", "project_url": "https://pypi.org/project/aadict/", "project_urls": { "Homepage": "http://github.com/metagriffin/aadict" }, "release_url": "https://pypi.org/project/aadict/0.2.3/", "requires_dist": null, "requires_python": "", "summary": "An auto-attribute dict (and a couple of other useful dict functions)", "version": "0.2.3" }, "last_serial": 2456724, "releases": { "0.2.0": [ { "comment_text": "", "digests": { "md5": "cb86df995cd4e7c15fae3f2db8397629", "sha256": "bbf500b0acbbc84cfa6488b8f9c8651cbc266147f86275dc6ba467fce2a4c7fb" }, "downloads": -1, "filename": "aadict-0.2.0.tar.gz", "has_sig": false, "md5_digest": "cb86df995cd4e7c15fae3f2db8397629", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4097, "upload_time": "2013-10-19T21:26:51", "url": "https://files.pythonhosted.org/packages/a6/22/02de4df49ebf6cdb9c37e6de923390d14c7731cade3345320f9cce34fd5a/aadict-0.2.0.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "35466d06c2572648ae81980457ef86f3", "sha256": "630234a3c6d3baed5cff1249c80707788cd6a2b275edbf70fe8b9f3f52f1514b" }, "downloads": -1, "filename": "aadict-0.2.1.tar.gz", "has_sig": false, "md5_digest": "35466d06c2572648ae81980457ef86f3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16771, "upload_time": "2013-11-20T17:51:14", "url": "https://files.pythonhosted.org/packages/cb/20/0c96f9bd0d95ff8f5fe89ea7c884ce1b0d81aef46762ec90cf155ba25a14/aadict-0.2.1.tar.gz" } ], "0.2.2": [ { "comment_text": "", "digests": { "md5": "0224a75cadb04183ea0c444aaa81b362", "sha256": "491d75eedad3d1d45204fdda3b70a12f6982d242d927dac68a7dbe69270b5491" }, "downloads": -1, "filename": "aadict-0.2.2.tar.gz", "has_sig": false, "md5_digest": "0224a75cadb04183ea0c444aaa81b362", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 17698, "upload_time": "2015-08-18T00:49:17", "url": "https://files.pythonhosted.org/packages/7e/b9/2bb637d40e365282d3e26819408583f17004cf8705c94fa8f44e8ba4790f/aadict-0.2.2.tar.gz" } ], "0.2.3": [ { "comment_text": "", "digests": { "md5": "c2832f665d91026d635e7b9262bb8479", "sha256": "a77328ac55dbb5735da99441870251befe135f687ab707a7a178561363b27704" }, "downloads": -1, "filename": "aadict-0.2.3.tar.gz", "has_sig": false, "md5_digest": "c2832f665d91026d635e7b9262bb8479", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16511, "upload_time": "2016-11-12T17:07:33", "url": "https://files.pythonhosted.org/packages/50/30/2d6c516ff308e1a2e25b8cf4274bd0ed763861b3d2b5cd1fb54c6d59bfcb/aadict-0.2.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "c2832f665d91026d635e7b9262bb8479", "sha256": "a77328ac55dbb5735da99441870251befe135f687ab707a7a178561363b27704" }, "downloads": -1, "filename": "aadict-0.2.3.tar.gz", "has_sig": false, "md5_digest": "c2832f665d91026d635e7b9262bb8479", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16511, "upload_time": "2016-11-12T17:07:33", "url": "https://files.pythonhosted.org/packages/50/30/2d6c516ff308e1a2e25b8cf4274bd0ed763861b3d2b5cd1fb54c6d59bfcb/aadict-0.2.3.tar.gz" } ] }