{ "info": { "author": "nadir.izr", "author_email": "nadir@soundmindtech.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.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.2", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "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\n\nIf that doesn't suit you, and you want to manage updates yourself, the\nentire library is self-contained in ``json_logic.py`` and you can\ndownload it straight into your project as you see fit.\n\n.. code:: bash\n\n curl -O https://raw.githubusercontent.com/nadirizr/json-logic-py/master/json_logic.py\n\nDifferences from the original `JavaScript version `__\n------------------------------------------------------------------------------------------------\n\nThe only difference is in the straightforward '==' and '===' comparison\noperators, since they have different expected behavior in Python than in\nJavaScript.\n\nIn JS: \\* '==' - Performs type coercion and compares. \\* '===' - Does\nnot perform type coercion.\n\nIn Python: \\* '==' - Does not perform type coercion, compares using\nPyton's **eq** operator. \\* '===' - Does not perform type coercion,\ncompares using Python's 'is' operator.", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/nadirizr/json-logic-py", "keywords": "json-logic", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "json-logic", "package_url": "https://pypi.org/project/json-logic/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/json-logic/", "project_urls": { "Homepage": "https://github.com/nadirizr/json-logic-py" }, "release_url": "https://pypi.org/project/json-logic/0.6.3/", "requires_dist": [ "coverage; extra == 'test'", "check-manifest; extra == 'dev'" ], "requires_python": "", "summary": "Build complex rules, serialize them as JSON, and execute them in Python", "version": "0.6.3" }, "last_serial": 2743533, "releases": { "0.6.2": [ { "comment_text": "", "digests": { "md5": "96141840c2c8443742a486ea69644ce8", "sha256": "de32d2e59f57aa9a4d8958234443fa2f35a37c323624b155f784ffdec2cc5922" }, "downloads": -1, "filename": "json_logic-0.6.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "96141840c2c8443742a486ea69644ce8", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 8198, "upload_time": "2015-12-03T15:22:07", "url": "https://files.pythonhosted.org/packages/ba/f0/3324a879fd34b955faf3f309d2e7c4d454193384ea87f8ff135be152d364/json_logic-0.6.2-py2.py3-none-any.whl" } ], "0.6.3": [ { "comment_text": "", "digests": { "md5": "3387d84c302b93e37262199a4532d3c3", "sha256": "dd873af85ae44292cdd708357c16d7788cf7590befa8fa1250cced27589fa7f0" }, "downloads": -1, "filename": "json_logic-0.6.3-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "3387d84c302b93e37262199a4532d3c3", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 8282, "upload_time": "2015-12-04T10:35:12", "url": "https://files.pythonhosted.org/packages/03/7f/6ccb8a3f78f891944eaf916b9fc35f3135f995ec6c871e873ba1e5933544/json_logic-0.6.3-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "af583d1030cb8c97a89847180cb68bda", "sha256": "d67d4656f4f5b427858141fa8247bf3062d612ebed99005b069d92e31139375f" }, "downloads": -1, "filename": "json_logic-0.6.3.tar.gz", "has_sig": false, "md5_digest": "af583d1030cb8c97a89847180cb68bda", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5783, "upload_time": "2015-12-04T10:35:17", "url": "https://files.pythonhosted.org/packages/72/e6/676a25a57eddf96fc2d693e609bc1c235a3084be6474d3b5fdad8a4e4417/json_logic-0.6.3.tar.gz" } ], "0.7.0a0": [ { "comment_text": "", "digests": { "md5": "86ff82eb68b7e04f7cf57144013e0d8e", "sha256": "a7af2e3673212279b4c7b63d0b0ead5f6b3d89cef8970bdbf60595d3bc9dd819" }, "downloads": -1, "filename": "json_logic-0.7.0a0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "86ff82eb68b7e04f7cf57144013e0d8e", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7552, "upload_time": "2017-03-31T11:22:49", "url": "https://files.pythonhosted.org/packages/47/cc/65de2481a8b7fae1582c564527d47ecae82f9c9e7ba60ad570b012f22634/json_logic-0.7.0a0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "689d04e0a3a388c0ef63408b8c925cd4", "sha256": "84580b974bcfec7b00d63745f19ca363939fc2b93c579f578d41d7d10c12fe0c" }, "downloads": -1, "filename": "json_logic-0.7.0a0.tar.gz", "has_sig": false, "md5_digest": "689d04e0a3a388c0ef63408b8c925cd4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6295, "upload_time": "2017-03-31T11:22:51", "url": "https://files.pythonhosted.org/packages/7d/05/5b516986c0706b7ae5f4b2155b1c32979479b378b55c0dd9bcc48e70fc5d/json_logic-0.7.0a0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "3387d84c302b93e37262199a4532d3c3", "sha256": "dd873af85ae44292cdd708357c16d7788cf7590befa8fa1250cced27589fa7f0" }, "downloads": -1, "filename": "json_logic-0.6.3-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "3387d84c302b93e37262199a4532d3c3", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 8282, "upload_time": "2015-12-04T10:35:12", "url": "https://files.pythonhosted.org/packages/03/7f/6ccb8a3f78f891944eaf916b9fc35f3135f995ec6c871e873ba1e5933544/json_logic-0.6.3-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "af583d1030cb8c97a89847180cb68bda", "sha256": "d67d4656f4f5b427858141fa8247bf3062d612ebed99005b069d92e31139375f" }, "downloads": -1, "filename": "json_logic-0.6.3.tar.gz", "has_sig": false, "md5_digest": "af583d1030cb8c97a89847180cb68bda", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5783, "upload_time": "2015-12-04T10:35:17", "url": "https://files.pythonhosted.org/packages/72/e6/676a25a57eddf96fc2d693e609bc1c235a3084be6474d3b5fdad8a4e4417/json_logic-0.6.3.tar.gz" } ] }