========
boolrule
========
.. image:: https://img.shields.io/pypi/v/boolrule.svg
:target: https://pypi.python.org/pypi/boolrule
.. image:: https://github.com/tailsdotcom/boolrule/actions/workflows/ci.yml/badge.svg
:target: https://github.com/tailsdotcom/boolrule/actions/workflows/ci.yml
.. image:: https://readthedocs.org/projects/boolrule/badge/?version=latest
:target: https://boolrule.readthedocs.io/en/latest/?badge=latest
Simple boolean expression evaluation engine.
* Free software: MIT license
* Documentation: https://boolrule.readthedocs.io.
Features
========
Compare simple boolean statements::
>>> rule = BoolRule('5 > 3')
>>> rule.test()
True
>>> rule = BoolRule('5 < 3')
>>> rule.test()
False
Evaluate boolean statements against a context dict::
>>> can_buy_beer = BoolRule('user.age_years >= 18')
>>> can_buy_beer.test({'user':{'age_years': 12}})
False
>>> can_buy_beer.test({'user':{'age_years': 20}})
True
Combine conditions with and and or operators to produce complex expressions::
>>> is_hipster = BoolRule('address.postcode.outcode in ("E1","E2") or user.has_beard = true')
>>> address = {
>>> 'postcode': {
>>> 'outcode': 'E1'
>>> }
>>> }
>>> is_hipster.test({'has_beard': False, 'address': address})
True
Credits
=======
Made possible by the excellent pyparsing_ library.
This package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template.
.. _pyparsing: http://pyparsing.wikispaces.com/
.. _Cookiecutter: https://github.com/audreyr/cookiecutter
.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage
=======
History
=======
0.3.5 (2024-02-09)
==================
* Introduce not∩ operator
0.3.4 (2021-09-24)
==================
* Fixed error caused by early return when evaluating nested expressions.
0.3.3 (2021-07-15)
==================
* Upgrade dependencies.
0.3.2 (2020-09-23)
==================
* Add Type hinting.
0.3.1 (2020-09-09)
==================
* Raise an exception when the whole expression cannot be parsed. Previous behaviour would discard the segment
that didn't match the expression grammar.
0.3.0 (2018-01-15)
==================
* Add None type and is/isnot operators (contributed by ocurero)
0.2.0 (2016-10-27)
==================
* Fixed error caused by refactor from internal codebase that was preventing deep context level values from being
referenced in a substitution value
0.1.2 (2016-09-30)
==================
* Improved documentation
0.1.1 (2016-09-30)
==================
* Made ``context`` optional
* Improved documentation
0.1.0 (2016-09-30)
==================
* First release on PyPI.
Raw data
{
"_id": null,
"home_page": "https://github.com/tailsdotcom/boolrule",
"name": "boolrule",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "boolrule boolean expression",
"author": "Steve Webster",
"author_email": "spjwebster@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/ef/11/7875300b704b4a17d9c7e20e8597a325eb61e79f174d8a4609f2b0ba516d/boolrule-0.3.5.tar.gz",
"platform": null,
"description": "========\nboolrule\n========\n\n.. image:: https://img.shields.io/pypi/v/boolrule.svg\n :target: https://pypi.python.org/pypi/boolrule\n\n.. image:: https://github.com/tailsdotcom/boolrule/actions/workflows/ci.yml/badge.svg\n :target: https://github.com/tailsdotcom/boolrule/actions/workflows/ci.yml\n\n.. image:: https://readthedocs.org/projects/boolrule/badge/?version=latest\n :target: https://boolrule.readthedocs.io/en/latest/?badge=latest\n\nSimple boolean expression evaluation engine.\n\n* Free software: MIT license\n* Documentation: https://boolrule.readthedocs.io.\n\n\nFeatures\n========\n\nCompare simple boolean statements::\n\n >>> rule = BoolRule('5 > 3')\n >>> rule.test()\n True\n >>> rule = BoolRule('5 < 3')\n >>> rule.test()\n False\n\n\nEvaluate boolean statements against a context dict::\n\n >>> can_buy_beer = BoolRule('user.age_years >= 18')\n >>> can_buy_beer.test({'user':{'age_years': 12}})\n False\n >>> can_buy_beer.test({'user':{'age_years': 20}})\n True\n\nCombine conditions with and and or operators to produce complex expressions::\n\n >>> is_hipster = BoolRule('address.postcode.outcode in (\"E1\",\"E2\") or user.has_beard = true')\n >>> address = {\n >>> 'postcode': {\n >>> 'outcode': 'E1'\n >>> }\n >>> }\n >>> is_hipster.test({'has_beard': False, 'address': address})\n True\n\n\nCredits\n=======\n\nMade possible by the excellent pyparsing_ library.\n\nThis package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template.\n\n.. _pyparsing: http://pyparsing.wikispaces.com/\n.. _Cookiecutter: https://github.com/audreyr/cookiecutter\n.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage\n\n\n\n=======\nHistory\n=======\n\n0.3.5 (2024-02-09)\n==================\n\n* Introduce not\u2229 operator\n\n\n0.3.4 (2021-09-24)\n==================\n\n* Fixed error caused by early return when evaluating nested expressions.\n\n\n0.3.3 (2021-07-15)\n==================\n\n* Upgrade dependencies.\n\n\n0.3.2 (2020-09-23)\n==================\n\n* Add Type hinting.\n\n\n0.3.1 (2020-09-09)\n==================\n\n* Raise an exception when the whole expression cannot be parsed. Previous behaviour would discard the segment\n that didn't match the expression grammar.\n\n\n0.3.0 (2018-01-15)\n==================\n\n* Add None type and is/isnot operators (contributed by ocurero)\n\n\n0.2.0 (2016-10-27)\n==================\n\n* Fixed error caused by refactor from internal codebase that was preventing deep context level values from being\n referenced in a substitution value\n\n\n0.1.2 (2016-09-30)\n==================\n\n* Improved documentation\n\n\n0.1.1 (2016-09-30)\n==================\n\n* Made ``context`` optional\n* Improved documentation\n\n\n0.1.0 (2016-09-30)\n==================\n\n* First release on PyPI.\n",
"bugtrack_url": null,
"license": "MIT license",
"summary": "Simple boolean expression evaluation engine",
"version": "0.3.5",
"project_urls": {
"Homepage": "https://github.com/tailsdotcom/boolrule"
},
"split_keywords": [
"boolrule",
"boolean",
"expression"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "7ba779e6a38d19a69d4b621aa641e283cacc37ee4516a3a66e80ae91beb1c157",
"md5": "dfb5a0818aa67f664445e1b71c461124",
"sha256": "a3d654e28c8637ca4168777f193b11dd08dd73c24b233e5f1e3d727546cb01a7"
},
"downloads": -1,
"filename": "boolrule-0.3.5-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "dfb5a0818aa67f664445e1b71c461124",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": null,
"size": 6450,
"upload_time": "2023-05-11T13:20:49",
"upload_time_iso_8601": "2023-05-11T13:20:49.109202Z",
"url": "https://files.pythonhosted.org/packages/7b/a7/79e6a38d19a69d4b621aa641e283cacc37ee4516a3a66e80ae91beb1c157/boolrule-0.3.5-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "ef117875300b704b4a17d9c7e20e8597a325eb61e79f174d8a4609f2b0ba516d",
"md5": "d3eb6450707a6b98a989fddf878d12a2",
"sha256": "cea74e3fc9a605acae5e596214d877a689a27b06adf0ddc3bca3117d48121191"
},
"downloads": -1,
"filename": "boolrule-0.3.5.tar.gz",
"has_sig": false,
"md5_digest": "d3eb6450707a6b98a989fddf878d12a2",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 17928,
"upload_time": "2023-05-11T13:20:50",
"upload_time_iso_8601": "2023-05-11T13:20:50.535700Z",
"url": "https://files.pythonhosted.org/packages/ef/11/7875300b704b4a17d9c7e20e8597a325eb61e79f174d8a4609f2b0ba516d/boolrule-0.3.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-05-11 13:20:50",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "tailsdotcom",
"github_project": "boolrule",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "boolrule"
}