Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Booleano is an interpreter of boolean expressions, a library to define and run filters available as text (e.g., in a natural language) or in Python code.

stable branche

https://img.shields.io/travis/Yupeek/booleano/master.svg https://readthedocs.org/projects/booleano/badge/?version=latest https://coveralls.io/repos/github/Yupeek/booleano/badge.svg?branch=master Latest PyPI version Number of PyPI downloads per month Code Climate

development status

https://img.shields.io/travis/Yupeek/booleano/develop.svg https://coveralls.io/repos/github/Yupeek/booleano/badge.svg?branch=develop

In order to handle text-based filters, Booleano ships with a fully-featured parser whose grammar is adaptive: Its properties can be overridden using simple configuration directives.

On the other hand, the library exposes a pythonic API for filters written in pure Python. These filters are particularly useful to build reusable conditions from objects provided by a third party library.

TLDR;

a string + some variable = safe boolean evaluation

# is this character a minor guy with a "0" in his name and born after 1983 ?
eval_boolean(
    'age < const:majority & "o" in name & birthdate > "1983-02-02"',
    {"name": "sokka", "age": 15, "birthdate": datetime.date(1984, 1, 1)},
    {'majority': 18},
    grammar_tokens={'belongs_to': 'in'}
) => True

The Fun Use Case

Booleano allow to safely evaluate an expression into something usable.

  • user:name is "john" and user:surname in {"doe", "shepard"}

+``{“user”: {“name”: “katara”}}`` => False +``{“user”: {“name”: “john”, “surname”: “doe”}}`` => True

with some code, you can provide any type you want, and the expression can still be in text:

+``user:birthdate > “03-07-1987”`` +``duration > 1m30s``

check the sample dirrectory to view more running examples !

Documentation

The full documentation is at http://booleano.readthedocs.io/en/latest/.

Contribute

this project was not created by the current maintainer. in fact, the knowlege of this project from us is fare from perfect, but with 100% of test coverages, it’s not hard to keep it running.

if you find a bug, or want some feature, feel free to create a issues, or a Pull Request, but keep in mind that it can be hard for us to work on it. the best way to have it fixed, it’s to write a Pull Request with passing tests, and we will merge it if it’s a good piece of code.

see CONTRIBUTING.rst to know how work with ease on this project.

Upgrade Note

the old alpha release 1.0a1 is not compatible with newer version (starting with 1.1a1) because of heavy import path changes. all import from the modules (__init__.py) is discouraged.

Credit

forked from Gustavo Narea’s booleano project on launchpad.net.

maintened by yupeek

Release files for booleano 1.1a2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for booleano 1.1a2
File Size Uploaded
booleano-1.1a2.tar.gz 35.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for booleano 1.1a2
File Interpreter ABI Platform
booleano-1.1a2-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 90.3 kB

Release files / booleano-1.1a2.tar.gz

Download URL booleano-1.1a2.tar.gz
Size 35.5 kB
Tags Source
SHA-256 checksum
How to use checksums
171c37e3947da5ddbf2a3ed978c5444d06cc4639cc0a3c653b2f45be0c79ee17
BLAKE2b-256 checksum
How to use checksums
19829190ef29c137d73f4ad0330ec99dfbb23a7dad92907771a37c07e326ddfa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / booleano-1.1a2-py2.py3-none-any.whl

Download URL booleano-1.1a2-py2.py3-none-any.whl
Size 54.9 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
51e60c33f89d4066d1b842e0e65bf6e553bf7503399a234def5b8d9dc80bcace
BLAKE2b-256 checksum
How to use checksums
08c615898a01c70c47e274845e86bc25075a563e66589de986d9a96768ba2058
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page