KO
|
EN
gitlite — search
Search
#javascript
#python
#hacktoberfest
#react
#ai
#typescript
#llm
#go
#golang
#android
#machine-learning
#rust
#deep-learning
#linux
rule
★ 17
Open GitHub ↗
A rule engine written in python.
Download README (.md)
Explore Similar Repositories
Integration2019
:
No description available.
SECNVs
:
A tool for simulating CNVs for WES data. It simulates rearranged genome(s), short reads (fastq) and BAM file(s) automatically in one single command.
epub-didatico-conectado
:
Espaço para desenvolvimento de experimento com ePub conectado
Useful-Python-Script
:
包含一些实用的Python脚本,比如天气查询、地理编码、节假日查询、车辆信息查询等等
RomaDroid_android_app_clone_detector
:
Android Clone App Detector
// repository documentation
Was this content helpful?
★ 0
(0 ratings)
Select Rating:
★
★
★
★
★
Submit Feedback
Recent Feedback
×
Download README
Do you want to download the
README.md
file for
rule
?
Download (.md)
# Rule A rule engine written in python. The rule is a json/yaml string or python object of a list expression. The expression is like `[op, arg0, arg1, ..., argn]`, the `op` is the operator, and `arg0..n` is the arguments for the operator. Any argument can be another expression. For writing convenience, the first argument will be tried to resolve as the context parameter. Or, you can just use the special `var` operator to indicate the context parameter. ## Installing ```bash pip install rule ``` ## Usage ```python >>> from rule import Rule >>> >>> context = dict(a=1, world='hello') >>> Rule(['=', ['var', 'a'], 1]).match(context) True >>> Rule("['=', ['var', 'a'], 1]").match(context) True >>> Rule(['=', 'a', 1]).match(context) True >>> Rule(['=', 'hello', 'hello']).match(context) True >>> Rule(['=', 'world', 'hello']).match(context) True >>> Rule(['<', 'a', 10]).match(context) True >>> Rule(['=', ['>', 'a', 10], False]).match(context) True >>> >>> context = dict(ldap_id='Harry', hosts='sa,sb,sc', reason='hehe', nologin=False, ... group='wheel,sysadmin,platform', package='dev-python/sa-tools', ... branch='release', cc='Tony,Mike',) >>> Rule(['contains', 'hosts', 'sa,']).match(context) True >>> Rule(['contains', ['split', 'hosts', ','], 'sa']).match(context) True >>> Rule(['in', 'branch', 'master', 'release']).match(context) True >>> Rule(['=', 'ldap_id', 'Harry']).match(context) True >>> Rule(['match', 'package', 'dev-python/*']).match(context) True >>> Rule(['regex', 'package', 'dev-python/.*']).match(context) True >>> Rule(['is', 'nologin', False]).match(context) True ``` See [rule/op.py](rule/op.py) for more supported operators. ## Development ``` make init # make install make test ``` ## License http://tclh123.mit-license.org/