{ "info": { "author": "Thomas Welfley", "author_email": "thomas.welfley+querylist@gmail.com", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Topic :: Software Development :: Libraries" ], "description": "# querylist\n\n[![Build Status](https://img.shields.io/travis/thomasw/querylist.svg)](https://travis-ci.org/thomasw/querylist)\n[![Coverage Status](https://img.shields.io/coveralls/thomasw/querylist.svg)](https://coveralls.io/r/thomasw/querylist)\n[![Latest Version](https://img.shields.io/pypi/v/querylist.svg)](https://pypi.python.org/pypi/querylist/)\n[![Downloads](https://img.shields.io/pypi/dm/querylist.svg)](https://pypi.python.org/pypi/querylist/)\n\nSick of for loop + conditional soup when dealing with complicated lists?\nQuerylist is here to help.\n\nThis package provides a data structure called a QueryList, an extension of\nPython's built in list data type that adds django ORM-eseque filtering,\nexclusion, and get methods. QueryLists allow developers to easily query and\nretrieve data from complex lists without the need for unnecessarily verbose\niteration and selection cruft.\n\nThe package also provides BetterDict, a backwards-compatible wrapper for\ndictionaries that enables dot lookups and assignment for key values.\n\nTake a look at the [complete\ndocumentation](https://querylist.readthedocs.org/) for more information.\n\n## Installation\n\nQuerylist can be installed like any other python package:\n\n > pip install querylist\n\nQuerylist is tested against Python 2.6, 2.7, 3.3, 3.4, and pypy.\n\n## Usage\n\n### BetterDicts\n\nBetterDicts wrap normal dicts. They have all of the same functionality one\nwould expect from a normal dict:\n\n >>> from querylist import BetterDict\n >>> src = {'foo': 'bar', 'items': True}\n >>> bd = BetterDict(src)\n >>> bd == src\n True\n >>> bd['foo']\n 'bar'\n >>> bd.items()\n [('items', True), ('foo', 'bar')]\n\nHowever, BetterDicts can also preform dot lookups and assignment of key\nvalues!\n\n >>> bd.bar_time = True\n >>> bd.foo = 'meh'\n >>> bd.foo\n 'meh'\n >>> bd.bar_time\n True\n >>> bd['bar_time']\n True\n\nKey values that conflict with normal dict attributes are accessible via a\n`_bd_` attribute.\n\n >>> bd.items\n \n >>> bd._bd_.items\n True\n\n[More about BetterDicts >>](https://querylist.readthedocs.org/en/latest/betterdict.html)\n\n### QueryLists\n\nQueryLists work just like lists:\n\n >>> from querylist import QueryList\n >>> site_list = [\n {\n 'url': 'http://site1.tld/',\n 'meta': {\n 'keywords': ['Mustard', 'kittens'],\n 'description': 'My cool site'\n },\n 'published': True,\n 'id': 1,\n 'name': 'Site 1'\n }, {\n 'url': 'http://site2.tld/',\n 'meta': {\n 'keywords': ['Catsup', 'dogs'],\n 'description': 'My cool site'\n },\n 'published': True,\n 'id': 2,\n 'name': 'SitE 2'\n }, {\n 'url': 'http://site3.tld/',\n 'meta': {\n 'keywords': ['Mustard', 'kittens'],\n 'description': 'My cool site'\n },\n 'published': False,\n 'id': 3,\n 'name': 'Site 3'\n }\n ]\n >>> ql = QueryList(site_list)\n >>> ql == site_list\n True\n\nThey also let developers, exclude objects that don't match criteria via field\nlookups or filter the QueryList to only the objects that do match a provided\ncriteria:\n\n >>> ql.exclude(published=True)\n [{'url': 'http://site3.tld/', 'meta': {'keywords': ['Mustard', 'kittens'], 'description': 'My cool site'}, 'id': 3, 'name': 'Site 3', 'published': False}]\n >>> ql.filter(published=True).exclude(meta__keywords__contains='Catsup')\n [{'url': 'http://site1.tld/', 'meta': {'keywords': ['Mustard', 'kittens'], 'description': 'My cool site'}, 'id': 1, 'name': 'Site 1', 'published': True}]\n\nAnd finally, they let developers retrieve specific objects with the get\nmethod:\n\n >>> ql.get(id=2)\n {'url': 'http://site1.tld/', 'meta': {'keywords': ['Mustard', 'kittens'], 'description': 'My cool site'}, 'id': 2, 'name': 'Site 1', 'published': True}\n\nBy default, QueryLists work exclusively with lists of dictionaries. This is\nachieved partly by converting the member dicts to BetterDicts on\ninstantiation. QueryLists also supports lists of any objects that support dot\nlookups. `QueryList.__init__()` has parameters that let users easily convert\nlists of dictionaries to custom objects. Consider the `site_list` example\nabove: instead of just letting the QueryList default to a BetterDict, we could\ninstantiate it with a custom Site class that provides methods for publishing,\nunpublishing, and deleting sites. That would then allow us to write code like\nthe following, which publishes all unpublished sites:\n\n >>> from site_api import Site\n >>> ql = QueryList(site_list, wrap=Site)\n >>> [x.publish() for x in ql.exclude(published=True)]\n\n[More about QueryLists >>](https://querylist.readthedocs.org/en/latest/querylist.html)\n\n## Contributing\n\n1. Fork the repo and then clone it locally.\n2. Install the development requirements: `pip install -r requirements.txt` (\n use `requirements26.txt` for python 2.6)\n3. Use [testtube](https://github.com/thomasw/testtube/)'s `stir` command\n(installed via #2) to monitor the project directory for changes and\nautomatically run the test suite.\n4. Make changes and submit a pull request.\n\nAt the moment, Querylist has great test coverage. Please do your part to help\nkeep it that way by writing tests whenever you add or change code.\n\n## Everything else\n\nCopyright (c) [Thomas Welfley](http://welfley.me). See\n[LICENSE](https://github.com/thomasw/querylist/blob/master/LICENSE) for\ndetails.\n", "description_content_type": null, "docs_url": null, "download_url": "https://github.com/thomasw/querylist/downloads", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/thomasw/querylist", "keywords": null, "license": "UNKNOWN", "maintainer": null, "maintainer_email": null, "name": "querylist", "package_url": "https://pypi.org/project/querylist/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/querylist/", "project_urls": { "Download": "https://github.com/thomasw/querylist/downloads", "Homepage": "https://github.com/thomasw/querylist" }, "release_url": "https://pypi.org/project/querylist/0.4.0/", "requires_dist": null, "requires_python": null, "summary": "This package provides a QueryList class with django ORM-esque filtering, excluding, and getting for lists. It also provides BetterDict, a dot lookup/assignment capable wrapper for dicts that is 100% backwards compatible.", "version": "0.4.0" }, "last_serial": 1816602, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "1ceadb173925bb8c658536d90ede5f60", "sha256": "0ce7a087e66fb7999473092493c2700e80f3a23adcfd25292e1c4c12f7919437" }, "downloads": -1, "filename": "querylist-0.0.1.tar.gz", "has_sig": false, "md5_digest": "1ceadb173925bb8c658536d90ede5f60", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8835, "upload_time": "2012-12-16T22:53:35", "url": "https://files.pythonhosted.org/packages/6c/d8/02456a77b6164d3489605a6c7aaeef96137419a6734b4ffcf2d851e9598d/querylist-0.0.1.tar.gz" } ], "0.1.0": [ { "comment_text": "", "digests": { "md5": "7097e3217bb2b7cf80f816ccd41bd302", "sha256": "b62a250f315e207bc49b8f28723c8516d06178a10a18ddb77bea423e3611e8da" }, "downloads": -1, "filename": "querylist-0.1.0.tar.gz", "has_sig": false, "md5_digest": "7097e3217bb2b7cf80f816ccd41bd302", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8830, "upload_time": "2012-12-16T22:56:16", "url": "https://files.pythonhosted.org/packages/10/68/84afdefe62fc7dc71e338515f605354122b1c3a9a029c73b85b0d29f06b6/querylist-0.1.0.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "457809fff4915e8f96557816dfdeeb9b", "sha256": "4a3e1b0d29526e508537a361097b4568e661af562d73794a63d4dfecfb8fc6c2" }, "downloads": -1, "filename": "querylist-0.2.0.tar.gz", "has_sig": false, "md5_digest": "457809fff4915e8f96557816dfdeeb9b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8646, "upload_time": "2014-12-27T17:53:37", "url": "https://files.pythonhosted.org/packages/3b/6d/c22d6f7c0255190449b7f11048be76218df2fbd99dc52d49a27014a74821/querylist-0.2.0.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "3ce4f1b6fd0ddb3f5ab4ee60acb53c69", "sha256": "d9d9750d553e6e2c54fe280b9e7c9aa7ca0504479f33232c0d80bbcde6749836" }, "downloads": -1, "filename": "querylist-0.3.0.tar.gz", "has_sig": false, "md5_digest": "3ce4f1b6fd0ddb3f5ab4ee60acb53c69", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 127350, "upload_time": "2015-09-09T00:31:15", "url": "https://files.pythonhosted.org/packages/8b/bf/6154c30059139d3e37d88327924abe9c9caba7cad0f76f41aee31e2a94c7/querylist-0.3.0.tar.gz" } ], "0.4.0": [ { "comment_text": "", "digests": { "md5": "8001d8e61b6b54f266d0c793e724e091", "sha256": "d83e4d8fc367ee056c652f5ea82b4e35a629f6bdff8c2245f223f3a9a7837d12" }, "downloads": -1, "filename": "querylist-0.4.0-py2-none-any.whl", "has_sig": false, "md5_digest": "8001d8e61b6b54f266d0c793e724e091", "packagetype": "bdist_wheel", "python_version": "2.6", "requires_python": null, "size": 13501, "upload_time": "2015-11-14T20:56:45", "url": "https://files.pythonhosted.org/packages/3b/80/948c031840efa76f06e5e4f416f6e893ac176ec8032fa9c4107fa32cfc3b/querylist-0.4.0-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d731ace6df30a4a4f8e9c818a26d00fb", "sha256": "6a3ec57cda338527586efb1a5f2abfb6895ffe145c381b2f2c0454fd3fbe08e3" }, "downloads": -1, "filename": "querylist-0.4.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "d731ace6df30a4a4f8e9c818a26d00fb", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 13500, "upload_time": "2015-11-14T20:58:52", "url": "https://files.pythonhosted.org/packages/7a/9a/961112ce4a83199d3be48cff7aa8697418f3be3beed2efa763616a2e7c66/querylist-0.4.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1775ae66e5fd9f6c33a0c2a1282c2625", "sha256": "fd6167e10e93ddb901960b6dac9cf5936d87ab384feea278b07070c287511dd5" }, "downloads": -1, "filename": "querylist-0.4.0.tar.gz", "has_sig": false, "md5_digest": "1775ae66e5fd9f6c33a0c2a1282c2625", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 128818, "upload_time": "2015-11-14T20:50:31", "url": "https://files.pythonhosted.org/packages/96/25/3b073a6a5ea1c4d3cfbe9e5f4059ee1beed65c83282361d796a1dd6f4ac4/querylist-0.4.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "8001d8e61b6b54f266d0c793e724e091", "sha256": "d83e4d8fc367ee056c652f5ea82b4e35a629f6bdff8c2245f223f3a9a7837d12" }, "downloads": -1, "filename": "querylist-0.4.0-py2-none-any.whl", "has_sig": false, "md5_digest": "8001d8e61b6b54f266d0c793e724e091", "packagetype": "bdist_wheel", "python_version": "2.6", "requires_python": null, "size": 13501, "upload_time": "2015-11-14T20:56:45", "url": "https://files.pythonhosted.org/packages/3b/80/948c031840efa76f06e5e4f416f6e893ac176ec8032fa9c4107fa32cfc3b/querylist-0.4.0-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d731ace6df30a4a4f8e9c818a26d00fb", "sha256": "6a3ec57cda338527586efb1a5f2abfb6895ffe145c381b2f2c0454fd3fbe08e3" }, "downloads": -1, "filename": "querylist-0.4.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "d731ace6df30a4a4f8e9c818a26d00fb", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 13500, "upload_time": "2015-11-14T20:58:52", "url": "https://files.pythonhosted.org/packages/7a/9a/961112ce4a83199d3be48cff7aa8697418f3be3beed2efa763616a2e7c66/querylist-0.4.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1775ae66e5fd9f6c33a0c2a1282c2625", "sha256": "fd6167e10e93ddb901960b6dac9cf5936d87ab384feea278b07070c287511dd5" }, "downloads": -1, "filename": "querylist-0.4.0.tar.gz", "has_sig": false, "md5_digest": "1775ae66e5fd9f6c33a0c2a1282c2625", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 128818, "upload_time": "2015-11-14T20:50:31", "url": "https://files.pythonhosted.org/packages/96/25/3b073a6a5ea1c4d3cfbe9e5f4059ee1beed65c83282361d796a1dd6f4ac4/querylist-0.4.0.tar.gz" } ] }