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
Testing
uv run pytest --log-cli-level=debug
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.1.tar.gz
.
File metadata
- Download URL: common_expression_language-0.3.1.tar.gz
- Upload date:
- Size: 20.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a12bf8d97a04de0866a866d9dadda0cec988f2130b0b32a93b8e6514deddde5f |
|
MD5 | 3528310516a877578081cfde722a3bd3 |
|
BLAKE2b-256 | 7c07ad16c6cb5614764c1503740e3d2952613db7fbc4c48276f197cb55c25988 |
File details
Details for the file common_expression_language-0.3.1-cp312-none-win_amd64.whl
.
File metadata
- Download URL: common_expression_language-0.3.1-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 | 590249a16e8f0e67f3b11b481ed20f98d28d5c8338fa2bdbdd06c31f1cdd7dda |
|
MD5 | caecae5f251b34a3475f2058392c4508 |
|
BLAKE2b-256 | 02f0cb9266c9821e1715d4fe1f7007f8f38cf880ee3038327cdff0d3022b9d8f |
File details
Details for the file common_expression_language-0.3.1-cp312-none-win32.whl
.
File metadata
- Download URL: common_expression_language-0.3.1-cp312-none-win32.whl
- Upload date:
- Size: 904.1 kB
- Tags: CPython 3.12, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 150d66856d19a6856aab68ecc9d28045f3381931e6e94a7182810d2ffc506511 |
|
MD5 | 38e8d8bf0fe996c22169a4b6f4d0ba57 |
|
BLAKE2b-256 | 645267680944d61ecc740b05d7239cd21674aa5b5d3dd094cfd94fab7084be1a |
File details
Details for the file common_expression_language-0.3.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: common_expression_language-0.3.1-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 | 525486bd31cdea134da83a79d317c656704a0fbaa600abdc9ee4c0aff635c547 |
|
MD5 | f45372ef238cef3a76deddc5c50d5330 |
|
BLAKE2b-256 | 2cab31befe7bd9b23ba9a28bff1e7e3af5b5859585925b6f38f6d6130f57bf55 |
File details
Details for the file common_expression_language-0.3.1-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl
.
File metadata
- Download URL: common_expression_language-0.3.1-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 | 8de8c3d03519519fe7f81dce434cb8fdb509ebf1f9853d0d3d998cbaf660bfc7 |
|
MD5 | fbeda9cdc998e7b6e478c8577cb98619 |
|
BLAKE2b-256 | a88e07f6f22e98b981a85e11f4f685d8a6d8babe34f31bea2a950b6a848c4954 |
File details
Details for the file common_expression_language-0.3.1-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
.
File metadata
- Download URL: common_expression_language-0.3.1-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 | f98fce0d2b670f2bebbc0e00e1ed6d93702a49682cbb758b701ef93b03833789 |
|
MD5 | 893e10f8b8d0f02f1baaf0d5b966c02b |
|
BLAKE2b-256 | 3f97591719d9a95c5175d5a0a4446101c0b74a0060624fa2e4602184fe9a02d6 |
File details
Details for the file common_expression_language-0.3.1-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
.
File metadata
- Download URL: common_expression_language-0.3.1-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 | 457f939bceede63bfbe024bb25d65c7b5ae029cb77bdf7ba639b4217ea5dcc6a |
|
MD5 | 6272855ae7a969a44c2280d78afc1d5b |
|
BLAKE2b-256 | 2f4869fea661e7c42f189b7147c4406f8b16a2a5909dd53bff030a3b86fed96f |
File details
Details for the file common_expression_language-0.3.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
.
File metadata
- Download URL: common_expression_language-0.3.1-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 | 54bd1143e5c205a32db5767c1030e901271ea60c88bc971ef21c9132ef967d21 |
|
MD5 | 4fc75c90fa9510bd77420cf7fcc00768 |
|
BLAKE2b-256 | 6da07c0e349b0b0a7cfc3e3651007117d8a8ea96103e6f0fc2e3e36a0e70d55d |
File details
Details for the file common_expression_language-0.3.1-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl
.
File metadata
- Download URL: common_expression_language-0.3.1-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 | 0ddf4ea058adf2f55b6664d2971183ad8b80913eadeac6c18fe255547269c333 |
|
MD5 | f22379558b9086af28ec8abbdab85772 |
|
BLAKE2b-256 | e572012a595e30d441bdd4179dca569acde44f668a548e4738e31752a4520f2e |
File details
Details for the file common_expression_language-0.3.1-cp312-cp312-macosx_11_0_arm64.whl
.
File metadata
- Download URL: common_expression_language-0.3.1-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 | 713b904c7e71902723714b1abc95ce2691b16a5725f9f0fb60ba988d51fd6fb4 |
|
MD5 | b0f35649cc183147d123a3ad9ab95399 |
|
BLAKE2b-256 | 81027fa510d16ce2e289fc767a1a509981f0e86d909931d0e8b417354b1443ae |
File details
Details for the file common_expression_language-0.3.1-cp312-cp312-macosx_10_12_x86_64.whl
.
File metadata
- Download URL: common_expression_language-0.3.1-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 | 983a71636a7bf5aeb64bb1f296f328ff0a4e4f14f77cab1a704605afb4544932 |
|
MD5 | 30f9400c99882034f758b9ee2161d482 |
|
BLAKE2b-256 | 158a6ccb7643e35f737a82395a1ac8509f066063999f1b4fbd5a02a4d6579bec |
File details
Details for the file common_expression_language-0.3.1-cp311-none-win_amd64.whl
.
File metadata
- Download URL: common_expression_language-0.3.1-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 | 511fab3f4b5ea10fa92eeed47943e50bf68828b5315250e268a77e5a247bc33c |
|
MD5 | e34fc2e855a16f5809515ca75ef569db |
|
BLAKE2b-256 | ebc7af17272c6d53a505119375028292eb728dcc8842663fad01a26cf5376ed6 |
File details
Details for the file common_expression_language-0.3.1-cp311-none-win32.whl
.
File metadata
- Download URL: common_expression_language-0.3.1-cp311-none-win32.whl
- Upload date:
- Size: 903.6 kB
- Tags: CPython 3.11, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 13df5d38889e7af910f2989b1d29b060bffcc0df2003468b6b72221781d5a585 |
|
MD5 | 183bc9fa7d9754795aff0468a370fd2a |
|
BLAKE2b-256 | 5833284c62de5a68632c948db606e889a32fea430bfadc434e16fc480cc76bd8 |
File details
Details for the file common_expression_language-0.3.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: common_expression_language-0.3.1-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 | 4f2e743db5f6b48a79d2f44be36acce601b808638ab543d51b992cbd06117b5b |
|
MD5 | 7d70c4b06908b297d003185a78a46c76 |
|
BLAKE2b-256 | 44b1be4bd66669cc2ea5679703ce0a11ed74187c9e8d54e9d001d15c3b103a90 |
File details
Details for the file common_expression_language-0.3.1-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl
.
File metadata
- Download URL: common_expression_language-0.3.1-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 | d90b86dc11628eddbcdbed75992a3b1f7604fe227655ee178f5621c4d8a19c99 |
|
MD5 | 83e3e0b6491945acd05382ae4704449e |
|
BLAKE2b-256 | 33b9ab11826f4c6ca2de9ab11d26958dc89476d8e81f6e9c90ed45f965048a4f |
File details
Details for the file common_expression_language-0.3.1-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
.
File metadata
- Download URL: common_expression_language-0.3.1-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 | 5858c7b3c954d988d0408f70f1e93c7de79deebd35c0c56767c0d2e8a0b379cb |
|
MD5 | 8c38b8bf9e3ca6859b0b21ff4864db68 |
|
BLAKE2b-256 | 4a8a4dfc08a08ce0e9d56d51a0642a637b28683a8b22e965cbd845b469c621c3 |
File details
Details for the file common_expression_language-0.3.1-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
.
File metadata
- Download URL: common_expression_language-0.3.1-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 | 37f7c41160a55969a5ef4d69a77e7aa139374c9955029df798bf06d2d0335820 |
|
MD5 | 27b30bfcd2e7eed8034aafbf61a9a672 |
|
BLAKE2b-256 | 1a4466952df102b3f923a0bc2465666e033ba9f2b322b1a280180e7a081f22b4 |
File details
Details for the file common_expression_language-0.3.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
.
File metadata
- Download URL: common_expression_language-0.3.1-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 | 9ab798d498775f1a0f2fbb64b558463937cf299e44d8c2a9926ddd1bc1962752 |
|
MD5 | 8a51045645c48214aa02364edc306563 |
|
BLAKE2b-256 | dcf092fc644cc301e11ba7d242c535a429747ffab23a1033e705a9cacfc2bb7d |
File details
Details for the file common_expression_language-0.3.1-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl
.
File metadata
- Download URL: common_expression_language-0.3.1-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 | 0dc02dcbe42f5af4d47f3028a48e0f29fbfa5ae41abd18e93370b5f91a0cc327 |
|
MD5 | 3bfbcada455aaaeb886ee9b3c3a7b5f3 |
|
BLAKE2b-256 | 4dff623334aee91d3e379aad73a352c411b8a726065aa3a75922aac0fe06307f |
File details
Details for the file common_expression_language-0.3.1-cp311-cp311-macosx_11_0_arm64.whl
.
File metadata
- Download URL: common_expression_language-0.3.1-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 | bad4d94115e4d363555f04a64a8574c28e224ced91ff197e6fa53ddaf43eb315 |
|
MD5 | 494b12997c49c4e4b5abc1fd922406b8 |
|
BLAKE2b-256 | 94ef6480c50e513aca09fd7ba4ec13c0c93f96cf0cccdb21c4c588eed843ec08 |
File details
Details for the file common_expression_language-0.3.1-cp311-cp311-macosx_10_12_x86_64.whl
.
File metadata
- Download URL: common_expression_language-0.3.1-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 | 143f2815869061a11b307ab1967b10f902ace5c5cebc775b43333b0ecd4384c9 |
|
MD5 | 8f3e45f7d0148b75854d2dba94d1f02a |
|
BLAKE2b-256 | 187228ffaeea17e30e1efd95f6d6ded4138e9b97e381d62cfa4168c0bf717415 |