{ "info": { "author": "Kadir Pekel", "author_email": "kadirpekel@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "======\nliquer\n======\n\nQuery your objects for two cents with Django like ``Q`` objects.\n\nSome Examples\n-------------\n``Q`` objects help you identify an object if its any attribute conforms your\ncustom predicate dsl. Let's take a look at the example below::\n\n from liquer import Q\n\n\n class MyClass:\n def __init__(self, foo):\n self.foo = foo\n\n # Define a query.\n # We expect foo attribute of an object to be 'bar'\n # regardless of case sensivity\n q = Q(foo__iexact='bar')\n\n # Create one MyClass instance\n my_obj = MyClass(foo='Bar')\n\n # Test my_obj if it conforms our query object\n assert q(my_obj) # Evaluates to True\n\n # We are also free to test any dictionary object\n my_dict = {'foo': 'Bar'}\n assert q(my_dict) \n \n # Let's fail a test\n my_fail_obj = MyClass(foo='Baz')\n assert q(my_fail_obj) # Evaluates to False, Throws assertion error\n\n\nYou can tail more attributes using '__' underscores to digg objects::\n\n >>> from liquer import Q\n >>> my_dict = {'foo': {'bar': {'baz': 1}}}\n >>> q = Q(foo__bar__baz__lte=2)\n\n >>> q(my_dict)\n True\n\nAlso there is chance for applying and/or logics to query couples::\n\n >>> q = Q(foo__bar__gt=0) & Q(foo__bar__lt=9) # The same as Q(foo__bar__gt=0, foo__bar__lt=9)\n >>> q({'foo': {'bar': 5}})\n True\n >>> q({'foo': {'bar': 18}})\n False\n\nLet's try ``or`` logic::\n\n >>> q = Q(foo__bar=3) | Q(foo__bar=5)\n >>> q({'foo': {'bar': 3}})\n True\n >>> q({'foo': {'bar': 5}})\n True\n >>> q({'foo': {'bar': 4}})\n False\n \nIt's very useful in most cases to register a callback when querying objects::\n\n >>> q = Q(foo__bar=3) | Q(foo__bar=5)\n >>> q.callback({'foo': {'bar': 3}}, lambda x: 'bar found %s' % x['foo']['bar'])\n 'bar found 3'\n\nThe funniest part is to register your own predicates::\n\n >>> from liquer import Q, register\n >>> register('is_sqrt', lambda x, y: x / y == y)\n >>> q = Q(foo__is_sqrt=5)\n >>> q({'foo': 25})\n True\n\nMore is coming soon...\n\nEnjoy!\n\nLicence\n-------\nCopyright (c) 2012 Kadir Pekel.\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the 'Software'), to deal in\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\nof the Software, and to permit persons to whom the Software is furnished to do\nso, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/kadirpekel/liquer", "keywords": null, "license": "UNKNOWN", "maintainer": null, "maintainer_email": null, "name": "liquer", "package_url": "https://pypi.org/project/liquer/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/liquer/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/kadirpekel/liquer" }, "release_url": "https://pypi.org/project/liquer/0.0.4/", "requires_dist": null, "requires_python": null, "summary": "Query your objects for two cents!", "version": "0.0.4" }, "last_serial": 794232, "releases": { "0.0.2": [ { "comment_text": "", "digests": { "md5": "feacbd64440dca8f0ef2821a921a491e", "sha256": "35c3a4fe208143cd4986d86195edd1390f02a2bad7be2919d2951ecffe06d4e9" }, "downloads": -1, "filename": "liquer-0.0.2.tar.gz", "has_sig": false, "md5_digest": "feacbd64440dca8f0ef2821a921a491e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3125, "upload_time": "2013-01-07T00:29:28", "url": "https://files.pythonhosted.org/packages/24/8f/5474c9b88e8b10d452fe4f1b80566bbe4ecd143e238e3d8ef13a07725b34/liquer-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "4df6af46f53e84900bf2c050459dfb5d", "sha256": "a0adf9586bcf020a8162fb776b1fb3c2df624c095aba71aa473c34064177aca3" }, "downloads": -1, "filename": "liquer-0.0.3.tar.gz", "has_sig": false, "md5_digest": "4df6af46f53e84900bf2c050459dfb5d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3637, "upload_time": "2013-01-07T19:54:36", "url": "https://files.pythonhosted.org/packages/10/72/f5bcbd567174e3b118aa794f74cd370d2e2286223fa1fa63c62819c3d2fb/liquer-0.0.3.tar.gz" } ], "0.0.4": [ { "comment_text": "", "digests": { "md5": "6004a64b950b12330aae418ddeb79423", "sha256": "a1c9b1a0ac1b1e3468a69c4b06538e214ca2ed01e5aaae35303c62e0e57812dd" }, "downloads": -1, "filename": "liquer-0.0.4.tar.gz", "has_sig": false, "md5_digest": "6004a64b950b12330aae418ddeb79423", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3713, "upload_time": "2013-01-07T20:41:00", "url": "https://files.pythonhosted.org/packages/46/4a/cf4d9d6e7ed65c46335e3fce37b5e7645df3779635c508459f5e493f12c5/liquer-0.0.4.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "6004a64b950b12330aae418ddeb79423", "sha256": "a1c9b1a0ac1b1e3468a69c4b06538e214ca2ed01e5aaae35303c62e0e57812dd" }, "downloads": -1, "filename": "liquer-0.0.4.tar.gz", "has_sig": false, "md5_digest": "6004a64b950b12330aae418ddeb79423", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3713, "upload_time": "2013-01-07T20:41:00", "url": "https://files.pythonhosted.org/packages/46/4a/cf4d9d6e7ed65c46335e3fce37b5e7645df3779635c508459f5e493f12c5/liquer-0.0.4.tar.gz" } ] }