{ "info": { "author": "Steve McMaster", "author_email": "mcmaster@hurricanelabs.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2", "Programming Language :: Python :: 3" ], "description": "##########\nFiltration\n##########\n\n**A library for parsing arbitrary filters provided by a UI or as a Query String**\n\nFeatures\n========\n- Compatible with Python 3\n- Parses human readable filters\n\nGet Filtration\n==============\n\n.. code-block:: shell\n\n pip install git+https://github.com/HurricaneLabs/filtration.git\n\nRun the tests\n=============\nYou must install nose2, then run:\n\n.. code-block:: shell\n\n git clone https://github.com/HurricaneLabs/filtration.git\n cd filtration\n nose2\n\n########\nUsage\n########\nFiltration is used to parse \"filter expressions\" made up of one or more \"statements\". Each\nstatement is comprised of a \"left hand side\" (LHS), and optionally an operator and a \"right hand\nside\" (RHS). When no operator and RHS are specified, a special \"LHS exists\" syntax is assumed. See\n\"Expression Evaluation\" for more details.\n\nStatements are joined together using \"AND\" or \"OR\" to form an expression. Parentheses may be used\nwhen joining statements together to enforce precedence. For example:\n\n.. code-block:: python\n\n >>> from filtration import Expression\n >>> Expression.parseString(\"a and b or c\")\n ((a and b) or c)\n >>> Expression.parseString(\"a and (b or c)\")\n (a and (b or c))\n >>>\n\nFiltration can also be used to parse query string syntax. See below for more information.\n\nExpression Format\n=================\n\nOperators\n~~~~~~~~~\nThese operators control comparison of the LHS to the RHS. If the operator is omitted (and thus\nthe RHS is also omitted), the statement returns True IF the symbol in the LHS exists at all.\n\n* Equal (\"==\")\n* Not equal (\"!=\")\n* Less than (\"<\")\n* Less than or equal (\"<=\")\n* Greater than (\">\")\n* Greater than or equal (\">=\")\n* Contains (\"in\")\n * RHS must be a list or a Subnet\n* Regular expression (\"=~\")\n * RHS must be a regex token\n\nTokens\n~~~~~~~~~~~~~~~\nThese tokens are used in the LHS or RHS of a statement.\n\nRegex\n-----\nA regular expression must be wrapped in \"/\" and may contain the characters \"i\", \"m\" or \"s\" after\nthe closing \"/\" to represent the corresponding regex flags. Examples::\n\n /abc/\n /^abc/i\n /^abc$/ms\n\nSubnet\n------\nA subnet is an IPv4 subnet in CIDR notation::\n\n 127.0.0.0/8\n 192.168.0.0/24\n\nSymbol\n------\nA symbol is represented as a bare, unquoted string. It begins with a letter or underscore, and\ncan be followed by any number of letters, numbers, dots (\".\") or underscores. Dots have special\nmeaning and are used to indicate dictionary traversal (see Expression Evaluation below).\n\nValue\n-----\nA value can be a date, time, date/time, quoted string, or an integer. A date is represented in\nYYYY-MM-DD format (not quoted), and is interpreted to mean midnight on that date. A time is\nrepresented in HH:MM:SS format (also not quoted), and is interpreted to mean that time on whatever\nday the filter is evaluated. A date/time is represented in YYYY-MM-DDTHH:MM:SS format, where the\n\"T\" is optional and could instead be represented by a space. This format is roughly ISO 8601, but\nis lacking microseconds.\n\nList\n----\nA list is two-or-more Value tokens separated by commas.\n\nExpression Evaluation\n=====================\n\nExpression objects are callable, with a single \"context\" argument. When used in this way, either\ntrue or false is returned, based on whether the \"context\" matches the filter. For example, given\nthis context:\n\n.. code-block:: python\n\n >>> c = {\"a\": 1, \"b\": 2, \"c\": 3}\n\nand this expression:\n\n.. code-block:: python\n\n >>> expr = Expression.parseString(\"a == 1 and b == 2\")\n\ncalling the expression would return True:\n\n.. code-block:: python\n\n >>> expr(c)\n True\n >>>\n\nwhereas this expression would return False:\n\n.. code-block:: python\n\n >>> expr = Expression.parseString(\"a == 2 and b == 2\")\n >>> expr(c)\n False\n >>>\n\nWhen no operator/RHS is provided, the statement resolves to true if the LHS key exists in the\ncontext. For example:\n\n.. code-block:: python\n\n >>> c = {\"a\": 1, \"b\": 2, \"c\": 3}\n >>> expr = Expression.parseString(\"a\")\n >>> expr(c)\n True\n >>> expr = Expression.parseString(\"d\")\n >>> expr(c)\n False\n >>>\n\nDictionary Traversal\n~~~~~~~~~~~~~~~~~~~~\n\nSymbols are able to traverse nested dictionaries in the context. Given this context:\n\n.. code-block:: python\n\n >>> c = {\"a\": {\"b\": {\"c\": 1}}}\n\nThis expression will return true:\n\n.. code-block:: python\n\n >>> expr = Expression.parseString(\"a.b.c == 1\")\n >>> expr(c)\n True\n >>>", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "filtration", "package_url": "https://pypi.org/project/filtration/", "platform": "", "project_url": "https://pypi.org/project/filtration/", "project_urls": null, "release_url": "https://pypi.org/project/filtration/2.0.1/", "requires_dist": null, "requires_python": "", "summary": "filtration - A library for parsing arbitrary filters", "version": "2.0.1" }, "last_serial": 5372665, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "3362752a6a16df38478709ddc492f22e", "sha256": "87f16c7690dfc13b9b6f2569c1653ef160aa5f586d7ff0c5fa5fe19605d6a991" }, "downloads": -1, "filename": "filtration-1.0.0.tar.gz", "has_sig": false, "md5_digest": "3362752a6a16df38478709ddc492f22e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8436, "upload_time": "2018-11-29T03:52:49", "url": "https://files.pythonhosted.org/packages/4d/03/cbe0a1c08f31a484b3fb68d7daab393874a8718ca1d77486c2b3d9de99f7/filtration-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "ae4d65f8e8ad7053c95ae799e66d6e18", "sha256": "073b91094a0d47dc0360f00a291cbd240e36141d6c7b4670cb89d97ba2b4bbf1" }, "downloads": -1, "filename": "filtration-1.0.1.tar.gz", "has_sig": false, "md5_digest": "ae4d65f8e8ad7053c95ae799e66d6e18", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9069, "upload_time": "2018-11-29T03:54:47", "url": "https://files.pythonhosted.org/packages/ce/c6/61711231bfbc7244b33fb61b25e736fe07d28baee0afea150bb2c8dfe953/filtration-1.0.1.tar.gz" } ], "1.0.2": [ { "comment_text": "", "digests": { "md5": "c7b0d06c9be206c18fb3f62d52952968", "sha256": "3609d1f945acab097659f090d2ce0ee452b8fb0c9486db08a55186ddc54b432a" }, "downloads": -1, "filename": "filtration-1.0.2.tar.gz", "has_sig": false, "md5_digest": "c7b0d06c9be206c18fb3f62d52952968", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9422, "upload_time": "2018-11-29T04:11:31", "url": "https://files.pythonhosted.org/packages/eb/9a/e286ea4e2b6f794c6919fc1fc904f4d0ba82f8571cca3b493394cefdac4b/filtration-1.0.2.tar.gz" } ], "2.0.0": [ { "comment_text": "", "digests": { "md5": "21697398fa30890db49e1ab11c395dae", "sha256": "5f4fb4d66cef1f9f63040c8aef378e7a6ae4bb96e7709ff3cabb562d84372704" }, "downloads": -1, "filename": "filtration-2.0.0.tar.gz", "has_sig": false, "md5_digest": "21697398fa30890db49e1ab11c395dae", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4763, "upload_time": "2019-04-09T15:46:08", "url": "https://files.pythonhosted.org/packages/e2/0f/3ee809bf9e02c7bfe388a9859fedb0c668e68b90ae34deb7e3aeced60e97/filtration-2.0.0.tar.gz" } ], "2.0.1": [ { "comment_text": "", "digests": { "md5": "1f8e4dd93e2e234c2e8033ba4aa8f014", "sha256": "4fa0dc1f9638b2c95a5a5c6cb1bc2e3f671588e5c4947abc532aa374af1ffb64" }, "downloads": -1, "filename": "filtration-2.0.1.tar.gz", "has_sig": false, "md5_digest": "1f8e4dd93e2e234c2e8033ba4aa8f014", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4787, "upload_time": "2019-06-07T18:35:14", "url": "https://files.pythonhosted.org/packages/80/8b/754ee1e0c6d7eade8c1ca6ec6b776dca44cd95e2975d58d06488809cc9e3/filtration-2.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "1f8e4dd93e2e234c2e8033ba4aa8f014", "sha256": "4fa0dc1f9638b2c95a5a5c6cb1bc2e3f671588e5c4947abc532aa374af1ffb64" }, "downloads": -1, "filename": "filtration-2.0.1.tar.gz", "has_sig": false, "md5_digest": "1f8e4dd93e2e234c2e8033ba4aa8f014", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4787, "upload_time": "2019-06-07T18:35:14", "url": "https://files.pythonhosted.org/packages/80/8b/754ee1e0c6d7eade8c1ca6ec6b776dca44cd95e2975d58d06488809cc9e3/filtration-2.0.1.tar.gz" } ] }