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-1.0.1.tar.gz
(17.0 kB
view details)
File details
Details for the file rule-engine-1.0.1.tar.gz
.
File metadata
- Download URL: rule-engine-1.0.1.tar.gz
- Upload date:
- Size: 17.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: Python-urllib/3.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cc04eefd7780d282466d32f73098a7e3c5d8378e6c18c5cf20848382ee73995c |
|
MD5 | dbac3ced435478ac0fe0b2a9e26ea029 |
|
BLAKE2b-256 | 8b8fe617646d33395137b57a2f5692542623667c38699ceee9997dbd6facd902 |