{ "info": { "author": "Cory Forward", "author_email": "coryf96@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "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", "Topic :: Software Development :: Build Tools" ], "description": "Query Collections\n=================\n\nA set of classes that makes managing JSON objects easier within Python (and more?)\n----------------------------------------------------------------------------------\n\nWhy?\n----\n\nWhen wanting to access an index of a JSON object (or a Python\ndictionary/map), we need to use ['member'] syntax. This is ok for simple\nJSON objects, but let's say you had a complex object andyou wanted a\ndeeply nested element, such as:\n\n::\n\n dict_instance['member'][0]['items'][0]['id']\n\nThis is where query collections come in. Right now the supported\nstructures are maps (python dictionaries) and lists. Here is how we can\naccess the members in each:\n\nGiven a k:v map:\n\n.. code::\n\n {\n \"population\": {\n \"faculty\": [\n {\n \"id\": \"103902\",\n \"name\": \"Cory\",\n \"field\": \"CS\"\n },\n {\n \"id\": \"6789\",\n \"name\": \"Ted\",\n },\n {\n \"id\": \"67874\",\n \"name\": \"Mike\",\n \"field\": \"CS\"\n }\n ],\n \"count\": 3,\n \"access_codes\": [\n 1, 2, 3\n ]\n }\n }\n\nThis specific instance would be rather difficult to obtain information\nfrom, and would require a lot of generators and other unnecessary bloat\nto achieve a task as simple as \"if there are any users who are faculty,\nreturn those with a 'field' specified\n\nHere is the naive solution with regular builtin Python functionality:\n\n.. code::\n\n json_obj = ...\n if json_obj.get('population').get('faculty') is not None:\n matches = [f_member for f_member in json_obj['population']['faculty'] if 'field' in f_member]\n return matches\n return None_\n\nHere is how we can perform the same operation with a query\\_dict:\n\n.. code::\n\n json_obj = query_dict(...)\n matches = json_obj.query(\"population:faculty:*:field!\")\n\nIn this example, ``*`` denotes \"any member of the list faculty\", and\n``!`` means 'return true if field exist\\`. The wildcard operator, by\ndefault, returns any member who returns a value.\n\nSyntax\n------\n\nThe syntax for queries is very easy to understand! To access a nested\nmember of a parent, simply do: parent:child. This can be chained over\nany amount of nesting. Of course this is in itself useful, but with the\naddition of operators, the use case is much, much more clear!\n\nAcceptable operators: - ``*``: Wildcard operator. Returns the list of\nelements at the given index. - ``!``: Exists operator. Returns true if\nthe member exists.\n\nCombination of rules is also acceptable: - The wildcard by default stops\nerror reporting and returns all matching elements following itself in\nthe query string. For example: .query(\"\\*:id!\") returns all members of\nthe first level where id exists. We can also perform queries by using the\nindex operators and prefixing a question mark.\n\nFiltering\n---------\n\nAs of release 0.0.1.2a8, we can now filter lists to search for children\nthat meet certain filters. This is a simple implementation,\nbut should meet demands for this use case. Storing values inside a string\nwas not an idea I supported (i.e., performing \"eq=13\"), and as such,\nfilters are added an extension to the query method. You can either pass a\nsingle filter, or multiple (as an array), and filters can be accesed within\nthe query string with the '$' operator, which follows this syntax: member$filterIndex.\nIf you only have one filter, there is no need to do member$0, you can simply do: member$\nExample:\n\nFor a problem, we need to filter a list of students to find students with a GPA > 3.0.\nIt is simply done as:\n\n.. code::\n\n results = students.query(\"*:GPA$\", filters.greaterEqual(3.0))\n # returns list of students with GPA > 3.0\n\nMultiple queries (to find list of students where GPA > 3.0 and attendance > 90.0:\n\n.. code::\n\n results = students.query(\"*:GPA$0:*:ATTENDANCE_PCT$1\",\n filters.greaterEqual(3.0), # filter at index '$0'\n filters.greaterEqual(90.0) # filter at index '$1'\n )\n # returns list of students with GPA > 3.0 and attendance > 90.0\n\nStreams\n-------\n\nAs of release 0.0.1a3, the Stream class is now in beta. This is a copy of the\nJava 8 Stream API and nearly all functionality exists. You can create your own\nstream from your own type easily, and query_dict and query_list contain a method\nto create the stream.\n\n.. code::\n\n results = Stream.of(1,2,3,4,5,6,7,8,9,10)\n results.filter(lambda x: x > 5)\\\n .peek(lambda x: print(x))\n\n OUT:\n 6\n 7\n 8\n 9\n 10\n\nExamples:\n---------\n\nYou may find a list of query examples in the /test directory. This\nincludes all current combinations of operators and basic error checking.\n\nquery\\_dict and query\\_list\n---------------------------\n\nCurrently this is all implemented through classes that inherit the dict\nand list class. The only additional functionality of these classes are\ndot access of dictionary members and a 'length'/'len' property of lists.\n\nquery\\_dict\n~~~~~~~~~~~\n\nMembers of the dictionary can be accessed from the dot operator:\n\n::\n\n >>> obj = query_dict({_\n \"name\": \"Cory\",\n \"stats\": {\n \"coolness\": \"over9000\"\n }\n })\n >>> obj.name\n \"Cory\"\n >>> obj.stats.coolness\n \"over9000\"\n\nquery len/length\n~~~~~~~~~~~~~~~~\n\n::\n\n >>> mlist = query_list([1,2,3])\n >>> mlist.len\n 3\n >>> mlist.length\n 3\n\nRoadmap:\n--------\n\n- Equality operator for basic comparisons\n- Equality comparator\n\n\n.. _Release Notes: https://github.com/c4wrd/query_collections/blob/master/REL_Notes.rst\n\nLicense\n-------\n\n::\n\n Query Collections\n\n The MIT License (MIT)\n\n Copyright (c) 2016 Cory Forward\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.", "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/c4wrd/query_collections", "keywords": "json dictionary management query selection", "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "query-collections", "package_url": "https://pypi.org/project/query-collections/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/query-collections/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/c4wrd/query_collections" }, "release_url": "https://pypi.org/project/query-collections/0.0.1.3a4/", "requires_dist": null, "requires_python": null, "summary": "A set of classes built for easier management of Python maps and lists", "version": "0.0.1.3a4" }, "last_serial": 2055475, "releases": { "0.0.1.0a1": [], "0.0.1.1a1": [ { "comment_text": "", "digests": { "md5": "92b130ff3307cc3c94172b0e50f5991e", "sha256": "95f833ab94cbc6517fae66a380050c87ed901d11e52c9484bc058928794ca8e2" }, "downloads": -1, "filename": "query_collections-0.0.1.1a1.tar.gz", "has_sig": false, "md5_digest": "92b130ff3307cc3c94172b0e50f5991e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6230, "upload_time": "2016-02-25T06:35:01", "url": "https://files.pythonhosted.org/packages/3b/5a/e0d7d56e96d0d975e95a823ad4b61493f1a2ce0303bbcdc82578ee2e85e5/query_collections-0.0.1.1a1.tar.gz" } ], "0.0.1.1a2": [ { "comment_text": "", "digests": { "md5": "36069cbfdd1e45513c82bf8c9c9d5474", "sha256": "eab652279a11a6a931e107ddea1bfe7d86f30f82f98d6c18675692e8b776e9b8" }, "downloads": -1, "filename": "query_collections-0.0.1.1a2.tar.gz", "has_sig": false, "md5_digest": "36069cbfdd1e45513c82bf8c9c9d5474", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6188, "upload_time": "2016-02-25T15:21:36", "url": "https://files.pythonhosted.org/packages/da/41/3189ae327f80f28b00f82fceddd02a99dbcec029d3edfdf704f88b9f10f5/query_collections-0.0.1.1a2.tar.gz" } ], "0.0.1.1a3": [ { "comment_text": "", "digests": { "md5": "383ee6e78bc2658e87589f5572ce8c71", "sha256": "65b6fec748dedf1d3e1dcb8a98a353bc8da1c1ef445ca503e0e731380470a64d" }, "downloads": -1, "filename": "query_collections-0.0.1.1a3.tar.gz", "has_sig": false, "md5_digest": "383ee6e78bc2658e87589f5572ce8c71", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6245, "upload_time": "2016-02-25T15:37:43", "url": "https://files.pythonhosted.org/packages/c0/a8/d2ce3b8f461ee9110cbd57587efacfd408c9ad5c39996d301417d3a23bc4/query_collections-0.0.1.1a3.tar.gz" } ], "0.0.1.2a1": [ { "comment_text": "", "digests": { "md5": "43971f9f614d1d2a25743f0a73d1cc47", "sha256": "d566a03389054b73dfef4f8b29357b85d3ec34ae5041ba8c01f1a2bea00b9c10" }, "downloads": -1, "filename": "query_collections-0.0.1.2a1.tar.gz", "has_sig": false, "md5_digest": "43971f9f614d1d2a25743f0a73d1cc47", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7376, "upload_time": "2016-02-25T21:23:23", "url": "https://files.pythonhosted.org/packages/fe/7b/4ed93b4cf904fbd695addec7b1fac45ed6e2580e2e43f6872cfa3c5bf7ab/query_collections-0.0.1.2a1.tar.gz" } ], "0.0.1.2a10": [ { "comment_text": "", "digests": { "md5": "0c220e8a498078ea0c326335d467d42a", "sha256": "1dd7ea240214a85c6f02c931027040a3d40936d7664604ab5dc3515d8c6c5f2d" }, "downloads": -1, "filename": "query_collections-0.0.1.2a10.tar.gz", "has_sig": false, "md5_digest": "0c220e8a498078ea0c326335d467d42a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12129, "upload_time": "2016-03-09T18:36:19", "url": "https://files.pythonhosted.org/packages/d4/c7/2430069ff75bce93991a002a07fc68a319bcacc05b4b4b2a1a69336d86ae/query_collections-0.0.1.2a10.tar.gz" } ], "0.0.1.2a2": [ { "comment_text": "", "digests": { "md5": "f700bdcf3c9dd80cdeaf362c88bc79aa", "sha256": "f08daa607023731ebf750ab05f6c9dce4b8b040b61ab14597e70fcdb28da0787" }, "downloads": -1, "filename": "query_collections-0.0.1.2a2.tar.gz", "has_sig": false, "md5_digest": "f700bdcf3c9dd80cdeaf362c88bc79aa", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7379, "upload_time": "2016-02-25T21:31:25", "url": "https://files.pythonhosted.org/packages/ad/7b/1d164a90ce5f9bf2006323dc948ea42081f9ebb6bebe2f22d93366a68c90/query_collections-0.0.1.2a2.tar.gz" } ], "0.0.1.2a3": [ { "comment_text": "", "digests": { "md5": "eb5fb37adc13251734b7b9a25b1122f3", "sha256": "fe5fe5994940b2cf831d76bb354ffbf4a6cf363897028b57b89ff852b85440be" }, "downloads": -1, "filename": "query_collections-0.0.1.2a3.tar.gz", "has_sig": false, "md5_digest": "eb5fb37adc13251734b7b9a25b1122f3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7417, "upload_time": "2016-02-25T23:13:16", "url": "https://files.pythonhosted.org/packages/1c/a9/e123ba3121676e8a0056a06fb1f10da0ea7af6b6c5ad1ad8d4ea2e7390f6/query_collections-0.0.1.2a3.tar.gz" } ], "0.0.1.2a4": [ { "comment_text": "", "digests": { "md5": "c3a19115201bddcd26117d140980dd01", "sha256": "2b88fc80793205595f3cca08194c5c0c5a5b47a796cafacb900f8d4be03164de" }, "downloads": -1, "filename": "query_collections-0.0.1.2a4.tar.gz", "has_sig": false, "md5_digest": "c3a19115201bddcd26117d140980dd01", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7846, "upload_time": "2016-02-25T23:23:53", "url": "https://files.pythonhosted.org/packages/d1/4d/32073337127e91bc56614e3453d95f59720b9d58d27b82075e73f98ca846/query_collections-0.0.1.2a4.tar.gz" } ], "0.0.1.2a5": [ { "comment_text": "", "digests": { "md5": "2e845cd53cd77ce5a8acedf7a5bd66c3", "sha256": "9bff0a92328792d39635108e0d03a0dc708bc8987aca0788a6d6a6e229a164cd" }, "downloads": -1, "filename": "query_collections-0.0.1.2a5.tar.gz", "has_sig": false, "md5_digest": "2e845cd53cd77ce5a8acedf7a5bd66c3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7883, "upload_time": "2016-02-25T23:29:40", "url": "https://files.pythonhosted.org/packages/f1/7f/ca6a6237ae5340e1f4c491c18ffe3d1ea960c6474e691ddcbbc335e7f1e9/query_collections-0.0.1.2a5.tar.gz" } ], "0.0.1.2a6": [ { "comment_text": "", "digests": { "md5": "4833760b63012dbdcfa68fb28de8ce40", "sha256": "f6f70742f9c756022b2a68b16e19e42b68b064e8f8f9bce9bf96e68997f745f0" }, "downloads": -1, "filename": "query_collections-0.0.1.2a6.tar.gz", "has_sig": false, "md5_digest": "4833760b63012dbdcfa68fb28de8ce40", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7912, "upload_time": "2016-02-25T23:34:02", "url": "https://files.pythonhosted.org/packages/b9/59/7ed5401e3f4fb11ac3dcc2a664e429fc41da268331d16a54e56fcf040951/query_collections-0.0.1.2a6.tar.gz" } ], "0.0.1.2a7": [ { "comment_text": "", "digests": { "md5": "13533d36b68dda928ff4597ad6994b4b", "sha256": "dd223822f6353c84e202609c28cb1c9df3ed51167733cf11f98d90129f780ab5" }, "downloads": -1, "filename": "query_collections-0.0.1.2a7.tar.gz", "has_sig": false, "md5_digest": "13533d36b68dda928ff4597ad6994b4b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8286, "upload_time": "2016-02-29T17:48:30", "url": "https://files.pythonhosted.org/packages/2f/92/96133876f3e7986e87ff9042e1a6606ec5020d697b7294bcf755744834fb/query_collections-0.0.1.2a7.tar.gz" } ], "0.0.1.2a8": [ { "comment_text": "", "digests": { "md5": "a07b2ad9a6c733277bbddb37c81f50eb", "sha256": "706cade74a9e6074192d7bf1c468c98495398a94d1509ff82c55883de7b42520" }, "downloads": -1, "filename": "query_collections-0.0.1.2a8.tar.gz", "has_sig": false, "md5_digest": "a07b2ad9a6c733277bbddb37c81f50eb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11439, "upload_time": "2016-03-06T00:47:45", "url": "https://files.pythonhosted.org/packages/0c/49/450630a8e2a82099bd45b05e8cb165d5420e4c2c3dd39d48e70532307086/query_collections-0.0.1.2a8.tar.gz" } ], "0.0.1.2a9": [ { "comment_text": "", "digests": { "md5": "86ff72c1feccb486e1b4b2aa19dea004", "sha256": "c9785f98b2aedd99a3d765c5f7d081434c9ce00d3ec5f4207edc354b33cc8e59" }, "downloads": -1, "filename": "query_collections-0.0.1.2a9.tar.gz", "has_sig": false, "md5_digest": "86ff72c1feccb486e1b4b2aa19dea004", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11454, "upload_time": "2016-03-08T20:41:38", "url": "https://files.pythonhosted.org/packages/35/68/8eae29162ff2d705d6ac653361b139dad08b67ba38161e5e17cf8c4362d3/query_collections-0.0.1.2a9.tar.gz" } ], "0.0.1.3a0": [ { "comment_text": "", "digests": { "md5": "6587bbaff0c04fae99e60e6b9c0203d6", "sha256": "9fdc4b8f648179348133dfa12d247598cb21e36f57fa9ec4b305d221db49e5e3" }, "downloads": -1, "filename": "query_collections-0.0.1.3a0.tar.gz", "has_sig": false, "md5_digest": "6587bbaff0c04fae99e60e6b9c0203d6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14415, "upload_time": "2016-03-14T22:17:25", "url": "https://files.pythonhosted.org/packages/61/b2/1eec5c21f90208763bce9b7f654e74deb0972c13492f9822d3ebb7a96e85/query_collections-0.0.1.3a0.tar.gz" } ], "0.0.1.3a1": [ { "comment_text": "", "digests": { "md5": "4751cbe0ae95f81dd50837246bb76551", "sha256": "b0f3b94fae0a6e712603d1e735bba810a51a30d63be0aea9469c3610e5fbbc75" }, "downloads": -1, "filename": "query_collections-0.0.1.3a1.tar.gz", "has_sig": false, "md5_digest": "4751cbe0ae95f81dd50837246bb76551", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14233, "upload_time": "2016-03-17T22:10:00", "url": "https://files.pythonhosted.org/packages/bf/c4/dc551370c84fa910e5860de413b1acf4ea104881843679aa68a18d6346ae/query_collections-0.0.1.3a1.tar.gz" } ], "0.0.1.3a2": [ { "comment_text": "", "digests": { "md5": "4f421f2ce9b5f4c2cf83bc38807d51ca", "sha256": "7ed38418b2151b8666b23695d1284e287d7708398fe172d321bbea37163ec04b" }, "downloads": -1, "filename": "query_collections-0.0.1.3a2.tar.gz", "has_sig": false, "md5_digest": "4f421f2ce9b5f4c2cf83bc38807d51ca", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14237, "upload_time": "2016-03-17T22:11:19", "url": "https://files.pythonhosted.org/packages/85/c8/4dacd3106ead108245885206a25f27816ac497c36ee5f70b10df5c74a0f5/query_collections-0.0.1.3a2.tar.gz" } ], "0.0.1.3a3": [ { "comment_text": "", "digests": { "md5": "80761c3cfeb154bc81c68c8349ffdca2", "sha256": "c07a2fb42955cf0254771a5d4a46be4f87df19a14fca5b6eae73049fe101b3de" }, "downloads": -1, "filename": "query_collections-0.0.1.3a3.tar.gz", "has_sig": false, "md5_digest": "80761c3cfeb154bc81c68c8349ffdca2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14335, "upload_time": "2016-04-09T20:04:49", "url": "https://files.pythonhosted.org/packages/82/a6/b20bafe3063bbf78f7d4627afc2ea253d41c8a5ed6b83e9c76285c09006d/query_collections-0.0.1.3a3.tar.gz" } ], "0.0.1.3a4": [ { "comment_text": "", "digests": { "md5": "da7048bb28f4c2a5687bde45b50e97aa", "sha256": "e418e54133548f6cf76f6c722fdf810350768665fb568fbb47bab6a395c32973" }, "downloads": -1, "filename": "query_collections-0.0.1.3a4.tar.gz", "has_sig": false, "md5_digest": "da7048bb28f4c2a5687bde45b50e97aa", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14344, "upload_time": "2016-04-09T20:21:59", "url": "https://files.pythonhosted.org/packages/2d/90/51e8375af0a89c97051f3b3291cb03397faca181f2835db3417548a4990e/query_collections-0.0.1.3a4.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "da7048bb28f4c2a5687bde45b50e97aa", "sha256": "e418e54133548f6cf76f6c722fdf810350768665fb568fbb47bab6a395c32973" }, "downloads": -1, "filename": "query_collections-0.0.1.3a4.tar.gz", "has_sig": false, "md5_digest": "da7048bb28f4c2a5687bde45b50e97aa", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14344, "upload_time": "2016-04-09T20:21:59", "url": "https://files.pythonhosted.org/packages/2d/90/51e8375af0a89c97051f3b3291cb03397faca181f2835db3417548a4990e/query_collections-0.0.1.3a4.tar.gz" } ] }