No project description provided
Project description
Common Expression Language (CEL)
The Common Expression Language (CEL) is a non-Turing complete language designed for simplicity, speed, and safety. CEL is primarily used for evaluating expressions in a variety of applications, such as policy evaluation, state machine transitions, and graph traversals.
This Python package wraps the Rust implementation cel-interpreter.
Install from PyPI:
pip install common-expression-language
Basic usage:
from cel import evaluate
expression = "age > 21"
result = evaluate(expression, {"age": 18})
print(result) # False
Simply pass the CEL expression and a dictionary of context to the evaluate
function. The function
returns the result of the expression evaluation converted to Python primitive types.
CEL supports a variety of operators, functions, and types
evaluate(
'resource.name.startsWith("/groups/" + claim.group)',
{
"resource": {"name": "/groups/hardbyte"},
"claim": {"group": "hardbyte"}
}
)
True
Custom Python Functions
This Python library supports user defined Python functions in the context:
from cel import evaluate
def is_adult(age):
return age > 21
evaluate("is_adult(age)", {'is_adult': is_adult, 'age': 18})
# False
You can also explicitly create a Context object:
from cel import evaluate, Context
def is_adult(age):
return age > 21
context = Context()
context.add_function("is_adult", is_adult)
context.update({"age": 18})
evaluate("is_adult(age)", context)
# False
Future work
Command line interface
The package (plans to) provides a command line interface for evaluating CEL expressions:
$ python -m cel '1 + 2'
3
Separate compilation and Execution steps
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file common_expression_language-0.3.0.tar.gz
.
File metadata
- Download URL: common_expression_language-0.3.0.tar.gz
- Upload date:
- Size: 19.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | acafc17918148ea673c64a66d2646876b83f5e04e02fc61ff26e7a40e2493622 |
|
MD5 | 8ff6e321744d4658497635dd1744167f |
|
BLAKE2b-256 | 2f5c09031ca2d146690687e0fab0296923ec72da91a61fe903eac4d14ba570ed |
File details
Details for the file common_expression_language-0.3.0-cp312-none-win_amd64.whl
.
File metadata
- Download URL: common_expression_language-0.3.0-cp312-none-win_amd64.whl
- Upload date:
- Size: 1.0 MB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a92da0e8022f989dad9cea4d82aa3d6506f199e79f9d6d1f49529eaf6cf27ef5 |
|
MD5 | 5c097494d4a2860900bf12a5643dd6ac |
|
BLAKE2b-256 | a0696a76a574a94c90847cec1b7140aa31b6c4bed16c01f9c529228f7f4a9c02 |
File details
Details for the file common_expression_language-0.3.0-cp312-none-win32.whl
.
File metadata
- Download URL: common_expression_language-0.3.0-cp312-none-win32.whl
- Upload date:
- Size: 904.0 kB
- Tags: CPython 3.12, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 759dd6589fba9a133e78bb6603d08612287dfe26c446dc45ad2fb8e0b59f5642 |
|
MD5 | c5bf1f9f32a0f31a01963d134ead14cd |
|
BLAKE2b-256 | 5238419921362a7e3f17c1689e5ecba880297d7463db52049e532dd71cbfc99e |
File details
Details for the file common_expression_language-0.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: common_expression_language-0.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.3 MB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8245ce74dbfbdcd5857b995302f95e25ae7ac8b4a467f2a38e999d7e1bb4f02f |
|
MD5 | 7a3b757404c86816cad9d59a4a00b25c |
|
BLAKE2b-256 | 0adbde2c874348b81aa658cb243d0e03458cc1618b2dfaae0860b14882c79fb9 |
File details
Details for the file common_expression_language-0.3.0-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl
.
File metadata
- Download URL: common_expression_language-0.3.0-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl
- Upload date:
- Size: 1.5 MB
- Tags: CPython 3.12, manylinux: glibc 2.17+ s390x
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e37645e6b8589c18d43ffdb1db176130df4b4c3fa242a0bc4ac81831752174b2 |
|
MD5 | abc46701cef71634664fe041a1996dd2 |
|
BLAKE2b-256 | 2c3d8e53f7d0ea6a3fe979d4d06df0128da3cf75ddf6cd2f213fc54045e65e08 |
File details
Details for the file common_expression_language-0.3.0-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
.
File metadata
- Download URL: common_expression_language-0.3.0-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
- Upload date:
- Size: 1.5 MB
- Tags: CPython 3.12, manylinux: glibc 2.17+ ppc64le
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3dc24ea480a6845dae3eafbdf1a9ad75461d27a71ca1e4444049d17606d5b95b |
|
MD5 | 95b5ca454c9afe9e4cec32115f634464 |
|
BLAKE2b-256 | fec455514f2d76d9b8e5dc2db6444cb0ad87f345b7d7a970c39932a3b137418f |
File details
Details for the file common_expression_language-0.3.0-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
.
File metadata
- Download URL: common_expression_language-0.3.0-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.12, manylinux: glibc 2.17+ ARMv7l
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 96d932fe3be242a4a588ff86c00355fae4853980111add34ecabfb87bb16f85a |
|
MD5 | 85901f119ff3bf368c3963153e3c9a61 |
|
BLAKE2b-256 | 2d7411f3bf0a37498dff4ae6d9c480514588ec3311842fd06c4231b290d835bd |
File details
Details for the file common_expression_language-0.3.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
.
File metadata
- Download URL: common_expression_language-0.3.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 1.3 MB
- Tags: CPython 3.12, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1e3e40f39cd92d1ba3a6fe66b22b2b94b5b31c235c8d23dcc9d412f41f1fd738 |
|
MD5 | 1ae839a1afba058a5da83eef62180e81 |
|
BLAKE2b-256 | 60b3dec072e1b7fde80b3df7e6202f85417626134d87badc146bbdeef018e256 |
File details
Details for the file common_expression_language-0.3.0-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl
.
File metadata
- Download URL: common_expression_language-0.3.0-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl
- Upload date:
- Size: 1.4 MB
- Tags: CPython 3.12, manylinux: glibc 2.5+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e022dcf2e1a3ae11d5e8dc6aa9b33dc8efe1b41deee2fe38c8ceae5853bb8daf |
|
MD5 | edd907949137f29ac54c156b3da0c80e |
|
BLAKE2b-256 | 0986f8afd16c12bba49f5e684f96f52bf6f6164948451cbfabae555ec4cb6ac0 |
File details
Details for the file common_expression_language-0.3.0-cp312-cp312-macosx_11_0_arm64.whl
.
File metadata
- Download URL: common_expression_language-0.3.0-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5be9b5f40eed3315942f518147783823a35fa13b434c9921fe82a7b70a03e2e7 |
|
MD5 | 746f9ccc4ca26e70562dd41a0b22ed96 |
|
BLAKE2b-256 | 2e883165f78283d0c79cddcc19571681ac5582b2882d9885a2b5f3f22020b725 |
File details
Details for the file common_expression_language-0.3.0-cp312-cp312-macosx_10_12_x86_64.whl
.
File metadata
- Download URL: common_expression_language-0.3.0-cp312-cp312-macosx_10_12_x86_64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.12, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1c9af99c4fdb9640b89ba902a344d0d698a17024343a2353e897d18de509ae79 |
|
MD5 | a68432c53144bc8e1a817fae3ad6755b |
|
BLAKE2b-256 | 96e5510dca50091f4b57897bb3e468452b6355a16777789ef319ddac84b24130 |
File details
Details for the file common_expression_language-0.3.0-cp311-none-win_amd64.whl
.
File metadata
- Download URL: common_expression_language-0.3.0-cp311-none-win_amd64.whl
- Upload date:
- Size: 1.0 MB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6c5e884866456d1a97d980b0d8a232d650bbdac9ce10e0436ac817d38f7a2d56 |
|
MD5 | fd1312132d8e453e0bf5bd465fa23745 |
|
BLAKE2b-256 | b6347bb11c03b16ce64960317931d5fd8b66a019629cf946e701883e3b6032d2 |
File details
Details for the file common_expression_language-0.3.0-cp311-none-win32.whl
.
File metadata
- Download URL: common_expression_language-0.3.0-cp311-none-win32.whl
- Upload date:
- Size: 903.3 kB
- Tags: CPython 3.11, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b4aa24ab5f680abf1df7ba611d51e63d30a913aad3cc34ae5e5b4ed134c785ba |
|
MD5 | 1b45bd09dc7c583ada298354f0f254d1 |
|
BLAKE2b-256 | 0ca4061f085d0ae55a7d44bd74eec3a4508f02bd450b10c5f5b79432293fc6c0 |
File details
Details for the file common_expression_language-0.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: common_expression_language-0.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.3 MB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ccbd8f5bf4b7531c9a2e044f386472b7a229ce9ec5c0c0722deca4624b7307b0 |
|
MD5 | 8c25dab2edf740bf49bcc111fe1bec7a |
|
BLAKE2b-256 | b83fe518127957d5acf606f5603924beeb04ead9ce5d0ff91b857646a2241cbb |
File details
Details for the file common_expression_language-0.3.0-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl
.
File metadata
- Download URL: common_expression_language-0.3.0-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl
- Upload date:
- Size: 1.5 MB
- Tags: CPython 3.11, manylinux: glibc 2.17+ s390x
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1fe2f9b695307045826f68a610b1a52594c02cbc58bd7d3231e09e3e542fe14c |
|
MD5 | 39c1230d112143c2131aad681db3b516 |
|
BLAKE2b-256 | 676dc1b35b11089d63f283654c3c9624f2d4fb94794ea2fdd31b7d78326a3a66 |
File details
Details for the file common_expression_language-0.3.0-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
.
File metadata
- Download URL: common_expression_language-0.3.0-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
- Upload date:
- Size: 1.5 MB
- Tags: CPython 3.11, manylinux: glibc 2.17+ ppc64le
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | df3e26056c6a65ccf770f53751d4eec8269d9c34303d92ad856a91fc66cf680a |
|
MD5 | 4fb7131a25bab48992eb0fa227a5f156 |
|
BLAKE2b-256 | 935c3af3f10d9275e2ae30ea35a35fbc0410027c9c789f221d6927995951b4e8 |
File details
Details for the file common_expression_language-0.3.0-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
.
File metadata
- Download URL: common_expression_language-0.3.0-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.11, manylinux: glibc 2.17+ ARMv7l
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e187eff6f7cea2c8ae8142282b404d5b6614c021ae8b59bc232f90a9266f4d5c |
|
MD5 | 3c3b1bbf73b36da20698e5df1e623991 |
|
BLAKE2b-256 | 82995249e605f473b385cb0343d4ad35b28d8309bdefe7e78ac260dec43e7f9e |
File details
Details for the file common_expression_language-0.3.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
.
File metadata
- Download URL: common_expression_language-0.3.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 1.3 MB
- Tags: CPython 3.11, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 814d35fbaae00752840bd3ecb942f99eb35bae4ce4ca6b6cffb53533935b6f83 |
|
MD5 | 4e6426d7de16d02565426f620f21c0ac |
|
BLAKE2b-256 | 782f57ef25245b0831d2c4ef0083ddf2400d887ce6af4a5291d47d55bbf2f4f2 |
File details
Details for the file common_expression_language-0.3.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl
.
File metadata
- Download URL: common_expression_language-0.3.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl
- Upload date:
- Size: 1.4 MB
- Tags: CPython 3.11, manylinux: glibc 2.5+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 28b46919fe394f65da3109d493a4f167877177365154d81c7451bf66e67c78c1 |
|
MD5 | 3ec4a550d3af20a4b0368fbe5783bb29 |
|
BLAKE2b-256 | 5b1ead9940e2ca8a1ec3c45e2b2421caac1293353a8b0e637680b8654a829a80 |
File details
Details for the file common_expression_language-0.3.0-cp311-cp311-macosx_11_0_arm64.whl
.
File metadata
- Download URL: common_expression_language-0.3.0-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 90dc3e647a059c7baf813b2f9baec361b107a5c2747b089e8bd1fd2d50eceb86 |
|
MD5 | 87d2defb332b28153c2bf902a73d089f |
|
BLAKE2b-256 | 740a4a2faf62ecedaf35072d94d78ca9f05ba5343b0286964a58318de2ebdd69 |
File details
Details for the file common_expression_language-0.3.0-cp311-cp311-macosx_10_12_x86_64.whl
.
File metadata
- Download URL: common_expression_language-0.3.0-cp311-cp311-macosx_10_12_x86_64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.11, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 25548c2b932aaecc3f5f3203bc285fb012092b65e3dddbf40d20b996f316ea4b |
|
MD5 | f4dc9bd464c3d7458bd46fe90f575bc4 |
|
BLAKE2b-256 | 95fb019c69deb2e21e7bb9be8ca40c312792e2d532340ff4b79d5a89bb0b8043 |