This project provides a library for creating general purpose "Rule" objects from a logical expression which can then be applied to arbitrary objects to evaluate whether or not they match.
Project description
This project provides a library for creating general purpose “Rule” objects from a logical expression which can then be applied to arbitrary objects to evaluate whether or not they match.
Documentation is available at https://zeroSteiner.github.io/rule-engine/.
Example
import rule_engine
# match a literal first name and applying a regex to the email
rule = rule_engine.Rule(
'first_name == "Luke" and email =~ ".*@rebels.org$"'
) # => <Rule text='first_name == "Luke" and email =~ ".*@rebels.org$"' >
rule.matches({
'first_name': 'Luke', 'last_name': 'Skywalker', 'email': 'luke@rebels.org'
}) # => True
rule.matches({
'first_name': 'Darth', 'last_name': 'Vader', 'email': 'dvader@empire.net'
}) # => False
Credits
Spencer McIntyre - zeroSteiner (@zeroSteiner)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
rule-engine-2.0.0.tar.gz
(23.0 kB
view details)
File details
Details for the file rule-engine-2.0.0.tar.gz
.
File metadata
- Download URL: rule-engine-2.0.0.tar.gz
- Upload date:
- Size: 23.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: Python-urllib/3.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ff338c1222c048c5d7841eba70b6764af39f706b3230d53683f7695fcba4c313 |
|
MD5 | 03eb484ffedfa6df55e090e3e49bb8f1 |
|
BLAKE2b-256 | 31ea7007afb692e5dc157ad295b5aa38b00e8e4a1cc5ce1b880e1d644b6da46a |