{ "info": { "author": "mohsin.niazi", "author_email": "mohsin.niazi@qubit.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.2", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "json-logic-py\n=============\n\nThis parser accepts `JsonLogic `__ rules and\nexecutes them in Python.\n\nThis is a Python porting of the excellent GitHub project by\n`jwadhams `__ for JavaScript:\n`json-logic-js `__.\n\nAll credit goes to him, this is simply an implementation of the same\nlogic in Python (small differences below).\n\nThe JsonLogic format is designed to allow you to share rules (logic)\nbetween front-end and back-end code (regardless of language difference),\neven to store logic along with a record in a database. JsonLogic is\ndocumented extensively at `JsonLogic.com `__,\nincluding examples of every `supported\noperation `__ and a place to `try\nout rules in your browser `__.\n\nThe same format can also be executed in PHP by the library\n`json-logic-php `__\n\nExamples\n--------\n\nSimple\n~~~~~~\n\n.. code:: python\n\n from json_logic import jsonLogic\n jsonLogic( { \"==\" : [1, 1] } )\n # True\n\nThis is a simple test, equivalent to ``1 == 1``. A few things about the\nformat:\n\n1. The operator is always in the \"key\" position. There is only one key\n per JsonLogic rule.\n2. The values are typically an array.\n3. Each value can be a string, number, boolean, array (non-associative),\n or null\n\nCompound\n~~~~~~~~\n\nHere we're beginning to nest rules.\n\n.. code:: python\n\n jsonLogic(\n {\"and\" : [\n { \">\" : [3,1] },\n { \"<\" : [1,3] }\n ] }\n )\n # True\n\nIn an infix language (like Python) this could be written as:\n\n.. code:: python\n\n ( (3 > 1) and (1 < 3) )\n\nData-Driven\n~~~~~~~~~~~\n\nObviously these rules aren't very interesting if they can only take\nstatic literal data. Typically ``jsonLogic`` will be called with a rule\nobject and a data object. You can use the ``var`` operator to get\nattributes of the data object:\n\n.. code:: python\n\n jsonLogic(\n { \"var\" : [\"a\"] }, # Rule\n { a : 1, b : 2 } # Data\n )\n # 1\n\nIf you like, we support `syntactic\nsugar `__ on unary\noperators to skip the array around values:\n\n.. code:: python\n\n jsonLogic(\n { \"var\" : \"a\" },\n { a : 1, b : 2 }\n )\n # 1\n\nYou can also use the ``var`` operator to access an array by numeric\nindex:\n\n.. code:: python\n\n jsonLogic(\n {\"var\" : 1 },\n [ \"apple\", \"banana\", \"carrot\" ]\n )\n # \"banana\"\n\nHere's a complex rule that mixes literals and data. The pie isn't ready\nto eat unless it's cooler than 110 degrees, *and* filled with apples.\n\n.. code:: python\n\n rules = { \"and\" : [\n {\"<\" : [ { \"var\" : \"temp\" }, 110 ]},\n {\"==\" : [ { \"var\" : \"pie.filling\" }, \"apple\" ] }\n ] }\n\n data = { \"temp\" : 100, \"pie\" : { \"filling\" : \"apple\" } }\n\n jsonLogic(rules, data)\n # True\n\nAlways and Never\n~~~~~~~~~~~~~~~~\n\nSometimes the rule you want to process is \"Always\" or \"Never.\" If the\nfirst parameter passed to ``jsonLogic`` is a non-object,\nnon-associative-array, it is returned immediately.\n\n.. code:: python\n\n #Always\n jsonLogic(True, data_will_be_ignored);\n # True\n\n #Never\n jsonLogic(False, i_wasnt_even_supposed_to_be_here);\n # False\n\nInstallation\n------------\n\nThe best way to install this library is via\n`PIP `__:\n\n.. code:: bash\n\n pip install json-logic-qubit\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/qubitproducts/json-logic-py", "keywords": "json-logic", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "json_logic_qubit", "package_url": "https://pypi.org/project/json_logic_qubit/", "platform": "", "project_url": "https://pypi.org/project/json_logic_qubit/", "project_urls": { "Homepage": "https://github.com/qubitproducts/json-logic-py" }, "release_url": "https://pypi.org/project/json_logic_qubit/0.9.1/", "requires_dist": null, "requires_python": "", "summary": "Build complex rules, serialize them as JSON, and execute them in Python", "version": "0.9.1" }, "last_serial": 4173259, "releases": { "0.9": [ { "comment_text": "", "digests": { "md5": "9f3539f97b642c6747cacb4730be67b5", "sha256": "77d4f4ae4c24057c0dee93a07cab0883d8f202b30e1e53a40ffcdf9795ea754e" }, "downloads": -1, "filename": "json_logic_qubit-0.9-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "9f3539f97b642c6747cacb4730be67b5", "packagetype": "bdist_wheel", "python_version": "3.6", "requires_python": null, "size": 13200, "upload_time": "2018-08-15T13:46:01", "url": "https://files.pythonhosted.org/packages/e9/95/3d1352c95ecb99932c1aaa95e326ad643bddd4dce0faa1b82cc6351c7b0a/json_logic_qubit-0.9-py2.py3-none-any.whl" } ], "0.9.1": [ { "comment_text": "", "digests": { "md5": "e5ab212bec0493fbe4e02816726c0225", "sha256": "d024ff0c77659eb97ddf742e0bd1b7caacd44bc53fdfc8f3977f4062a3c3b056" }, "downloads": -1, "filename": "json_logic_qubit-0.9.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "e5ab212bec0493fbe4e02816726c0225", "packagetype": "bdist_wheel", "python_version": "3.6", "requires_python": null, "size": 13196, "upload_time": "2018-08-15T14:41:05", "url": "https://files.pythonhosted.org/packages/d8/62/2b023e1dcc6917d40a9f5687916d1c647e26af06c579f200bd0f3b91481a/json_logic_qubit-0.9.1-py2.py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "e5ab212bec0493fbe4e02816726c0225", "sha256": "d024ff0c77659eb97ddf742e0bd1b7caacd44bc53fdfc8f3977f4062a3c3b056" }, "downloads": -1, "filename": "json_logic_qubit-0.9.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "e5ab212bec0493fbe4e02816726c0225", "packagetype": "bdist_wheel", "python_version": "3.6", "requires_python": null, "size": 13196, "upload_time": "2018-08-15T14:41:05", "url": "https://files.pythonhosted.org/packages/d8/62/2b023e1dcc6917d40a9f5687916d1c647e26af06c579f200bd0f3b91481a/json_logic_qubit-0.9.1-py2.py3-none-any.whl" } ] }