Boolrule
Simple boolean expression evaluation engine for python.
Install / Use
/learn @tailsdotcom/BoolruleREADME
======== 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
Related Skills
node-connect
339.3kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
83.9kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
339.3kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
83.9kCommit, push, and open a PR
