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.
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"}
}
)
Future work
Support for converting Python datetime objects and timedeltas into CEL types.
Command line interface
The package (plans to) also provides a command line interface for evaluating CEL expressions:
$ python -m cel '1 + 2'
3
Custom Python Functions
Ability to add Python functions to the Context object:
from cel import evaluate, Context
def is_adult(age):
return age > 21
context = Context()
context.add_function("is_adult", is_adult)
print(evaluate("is_adult(age)", {"age": 18}, context)) # False
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
Built Distributions
Hashes for common_expression_language-0.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | a6fabf30f07a613e7851877f955154b2db0610b828820b2f895de601d382a745 |
|
MD5 | cd9f3ae26ea0507506ab2010abb43160 |
|
BLAKE2b-256 | ac9c69b8b29eda09ee6d259b728a155b0bda69d3585728abcd5099b0e623a89a |
Hashes for common_expression_language-0.1.1-cp312-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e1ed511d5413df15daf5a98d2794783a7186cfd2121436d8f8c37c6a70acdfa3 |
|
MD5 | 91dcec32bbf10b2c7dc8015276566639 |
|
BLAKE2b-256 | c730dcda28e9c270972274ea5291d4f7b46a423841763331a05f84bf2f6f8c4b |
Hashes for common_expression_language-0.1.1-cp312-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f2e40cbd1effd3041aaabb7a25598b425af9072e78829849db0a7bc1073a2b7c |
|
MD5 | b22ef09657625897b8527688a46bd330 |
|
BLAKE2b-256 | cf4370ead1135a80d0fdaeed9557a9f3ee39d2b58f1f444b7f8bf4d2134d3704 |
Hashes for common_expression_language-0.1.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5384eaf840151de14c59b7bcb2ed37659ad81059b6da348cb69f2a031d715a31 |
|
MD5 | 0bdd7379f3fd3d62c194f51433eb3fc4 |
|
BLAKE2b-256 | 74d9abf45b123efb69c1f5470f32ee84e6e1b8f029ac0b61e7b2861dfd5c5fb9 |
Hashes for common_expression_language-0.1.1-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d2e4f635609a0907a8bd27b3effde671122dca7bafbc9021a1b7743f635ddacf |
|
MD5 | d5463129ba1dc695ed2889c01bb7204f |
|
BLAKE2b-256 | 81ad634f2bf0cde396fc92a482fb2ade0eab97d62e6c448af34f5f9783fd67da |
Hashes for common_expression_language-0.1.1-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a89d50799bf412970655871165ab8e79b59ff830853b092028d350be8937ba46 |
|
MD5 | e106f1ece4ff99cdc70f7d6d686b237c |
|
BLAKE2b-256 | a6826ccd04e04ff0f40dcdf0704b7fc8b85e1048a0eaf61fd228f2d1ff862ba0 |
Hashes for common_expression_language-0.1.1-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c84047a1875178751a5b28bb8a61e6fc451a597182fd82e9f77c44770c53dd45 |
|
MD5 | 9e5907791440a347c55e71f697e188ad |
|
BLAKE2b-256 | e149c213e4f76deaf14cba731ae11f30b41904f6a494cbf8daf26c7d82926ccb |
Hashes for common_expression_language-0.1.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ebd746d1184f528383aa5808385b2503101aa0e5f3a814f8809ae7368cf54e6b |
|
MD5 | 782b0f657d4f0158524641039d4e5643 |
|
BLAKE2b-256 | bfc4ac9ff8fbb4ea613b39e079292e09842cf3aa0b9263b2da828af92976a1c6 |
Hashes for common_expression_language-0.1.1-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4e95bf5b3b237561b80ddc0ef715306d7c4d04d25fbaf981c97fe298605f07c9 |
|
MD5 | 527edd3091e7e19c8a7f94523801f052 |
|
BLAKE2b-256 | 841bd58ce9ce7c6cb6a77bf2dc2bf4c6356573cbdc8fa4e7663aaf13240e3a0e |
Hashes for common_expression_language-0.1.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5f3730b62fb8601229cea23ce6880cb832e5126d5e6dcb1fd095903564edf1b1 |
|
MD5 | 6c1824801ced0811bf35c6a68f1aee8f |
|
BLAKE2b-256 | cd37fd399479c75bdf0e4a86f3716eb7fdc1eebcda6869ad081017369f68dd3a |
Hashes for common_expression_language-0.1.1-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2d353641e9ab36896ee9a9233713b093e05bf78359c5787d19fb41ebe59f94b3 |
|
MD5 | 26a7a04cbaad404084eb55b89f8ed8fc |
|
BLAKE2b-256 | 2ca86eceafadf2bca630f30c82d4685279ba1043f7c073e39ffe28d31fe7ccc2 |
Hashes for common_expression_language-0.1.1-cp311-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3a0196e262bc2df3d580a57f777a2ed183dbcea9821140ca3535678d03da7b71 |
|
MD5 | 241dedcb8638db410da4e3bf7677a967 |
|
BLAKE2b-256 | 10151ac9d111d5ed0a5b49ff36a4cf9ee9ed176f4283bd52ddbe0b3a4ae1ced2 |
Hashes for common_expression_language-0.1.1-cp311-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8dea1cc5520ef413017270219ee2e04c30684ad419d1fc085b4218fc217eb535 |
|
MD5 | c5893ff46dace812cff83911cc5dfd70 |
|
BLAKE2b-256 | 01a4ed8f69ec1c48072a9af63b3d964c83fc632c39e57eeb22aaa0bc52a09332 |
Hashes for common_expression_language-0.1.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d03ccd15fc0b19321709bab29c0f4166d7f5508955e17a4f317c2da1493b7a56 |
|
MD5 | 44ffdd4bf1718d7d3b7400d5479f3cda |
|
BLAKE2b-256 | 2a8a7f12db01900ac02b6c8a550b57ae8a10543a88c6d67e326ccb89ad2ddd22 |
Hashes for common_expression_language-0.1.1-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fbf3502d802392d904d960d5a42a0875e29c94e422601d708b0dad2cebd78835 |
|
MD5 | 68ce55c050e0773fa943a7a3f907a456 |
|
BLAKE2b-256 | 13a550310dbd70b0ff8cfe93298337e1f1fb9add76b9336b195e8b2d4f57ef60 |
Hashes for common_expression_language-0.1.1-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4bca33deae63996ab7f14d81f99d757f8451a581a58773a2b1cd0b0c24fbf597 |
|
MD5 | a4001918a87f225b525aa9c3697a2626 |
|
BLAKE2b-256 | db52dada311390792d698440b641baffdb8efb41f7e1d54d52ceb7f1929e362f |
Hashes for common_expression_language-0.1.1-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 67bcff72032259caee411a76907918e13cb49ab0db652f1593673344a157fead |
|
MD5 | af830f4a9da513bb1291a65acc0d3c28 |
|
BLAKE2b-256 | ef71a259586a229201f32ef00921956b9c0dd77a956d2730a343c46a550c4a4a |
Hashes for common_expression_language-0.1.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e50a9cece57496682ffc34699cef7854212db67b1e6042cb06ae7c90cc759093 |
|
MD5 | 8b3d48a59b7775997ce12b32d6f5f8dc |
|
BLAKE2b-256 | 11e96f84a377e84fc95e609eae31b9b63208f616e6dc7b51a7efc6bded0a4ae1 |
Hashes for common_expression_language-0.1.1-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0c2b3296cf7393be059d8856076cf7f4f3e0cdacd5f991cb8c0e7e9567b03dfb |
|
MD5 | b476e62f4ddf6e529fdacd821d940544 |
|
BLAKE2b-256 | d1c0a454bdced1aa123ae4933a70c6cc178971bca5df7fc0685514011f062460 |
Hashes for common_expression_language-0.1.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6fa145b82c0816da73b39999eb21dd81e417722a396b31a00e9aab60ba23c43a |
|
MD5 | 3a7fc8e3dbbd732c7145a778da9085df |
|
BLAKE2b-256 | 9e919bd379fe4442f0a642447c898cc0da7ea631b002a101a051a0cfdd7f0f26 |
Hashes for common_expression_language-0.1.1-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3d05b814b75de38ff884618e7b5caab08645b9633699eb525aea9c0e85ea1e63 |
|
MD5 | a76e98e58bc8a92cdaffd5ca2b258447 |
|
BLAKE2b-256 | b51b1daf8f387a0706eea9ead931975d92e27054dc692256bf36cb28fa80a3af |