Skip to main content

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"}
    }
)

Future work

Support for converting Python datetime objects and timedeltas into CEL types.

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

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

common_expression_language-0.2.0.tar.gz (17.9 kB view details)

Uploaded Source

Built Distributions

common_expression_language-0.2.0-cp312-none-win_amd64.whl (965.0 kB view details)

Uploaded CPython 3.12 Windows x86-64

common_expression_language-0.2.0-cp312-none-win32.whl (869.6 kB view details)

Uploaded CPython 3.12 Windows x86

common_expression_language-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

common_expression_language-0.2.0-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl (1.4 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ s390x

common_expression_language-0.2.0-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (1.4 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ppc64le

common_expression_language-0.2.0-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (1.2 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ARMv7l

common_expression_language-0.2.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.2 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ARM64

common_expression_language-0.2.0-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl (1.3 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.5+ i686

common_expression_language-0.2.0-cp312-cp312-macosx_11_0_arm64.whl (1.1 MB view details)

Uploaded CPython 3.12 macOS 11.0+ ARM64

common_expression_language-0.2.0-cp312-cp312-macosx_10_12_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.12 macOS 10.12+ x86-64

common_expression_language-0.2.0-cp311-none-win_amd64.whl (964.8 kB view details)

Uploaded CPython 3.11 Windows x86-64

common_expression_language-0.2.0-cp311-none-win32.whl (869.1 kB view details)

Uploaded CPython 3.11 Windows x86

common_expression_language-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

common_expression_language-0.2.0-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl (1.4 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ s390x

common_expression_language-0.2.0-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (1.4 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ppc64le

common_expression_language-0.2.0-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (1.2 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARMv7l

common_expression_language-0.2.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.2 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

common_expression_language-0.2.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl (1.3 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.5+ i686

common_expression_language-0.2.0-cp311-cp311-macosx_11_0_arm64.whl (1.1 MB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

common_expression_language-0.2.0-cp311-cp311-macosx_10_12_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.11 macOS 10.12+ x86-64

File details

Details for the file common_expression_language-0.2.0.tar.gz.

File metadata

File hashes

Hashes for common_expression_language-0.2.0.tar.gz
Algorithm Hash digest
SHA256 c9c0811ecc7f47e9b319cad44707d4aa39bc61221351489e6859309cfaef1faa
MD5 3f5aef2f036dec9dc7ff83940944ba15
BLAKE2b-256 992aa4f271c17dfd9781937fc46d9a6b32cb7263096d2f877663736a5394e8eb

See more details on using hashes here.

File details

Details for the file common_expression_language-0.2.0-cp312-none-win_amd64.whl.

File metadata

File hashes

Hashes for common_expression_language-0.2.0-cp312-none-win_amd64.whl
Algorithm Hash digest
SHA256 e58d45f6baea996c4659f126e3cf2e57efb11207964f2083bf9171c0747f725b
MD5 3ef2bcc96aaa36be0948d02b37161127
BLAKE2b-256 fd8f863a3fb46d78167635630b7977e73cea47180cd873900f3ca67c7444e64d

See more details on using hashes here.

File details

Details for the file common_expression_language-0.2.0-cp312-none-win32.whl.

File metadata

File hashes

Hashes for common_expression_language-0.2.0-cp312-none-win32.whl
Algorithm Hash digest
SHA256 178622e57d74fbc30de92ce94729ed56baa5aaf1800742c39ddf74335be63a52
MD5 896d66e78330e8079e733f3dee1ee20a
BLAKE2b-256 aa57ad041c745c2147fbcc9ff76ea3bb69327ba3593c7258c9a339ff4932502e

See more details on using hashes here.

File details

Details for the file common_expression_language-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for common_expression_language-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 96268e113e6a316dcf0795a6597153ef41c7e7684279b3d0bfa1d2dfef37b928
MD5 5982fef7528f37d45832246e8b8455f8
BLAKE2b-256 01cb6c88fca0039dcee6ef0134334db6774fcb85245a88d79da7e7139dd66d6a

See more details on using hashes here.

File details

Details for the file common_expression_language-0.2.0-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl.

File metadata

File hashes

Hashes for common_expression_language-0.2.0-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 1bc339edd1312241475afc1bdfd866635b6852192f15db2aca17c7bc6b2212ee
MD5 8e46c137ae05f9e56f7a782f4a96d379
BLAKE2b-256 0cd4ec229a7aa8acebabb4373ad3258aa660728a6e142a4292fc7eba6942ab1a

See more details on using hashes here.

File details

Details for the file common_expression_language-0.2.0-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl.

File metadata

File hashes

Hashes for common_expression_language-0.2.0-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 3f36ef61ed791a079dcedbe2698028c3fff04007767bbd0326ac5a327ad55984
MD5 d3d0d73019fb28c8ca89dd6c7a70fd20
BLAKE2b-256 2840381f93ccf64dbf348e4ca5365df01f270d81d0ed71bb73f33c907a512483

See more details on using hashes here.

File details

Details for the file common_expression_language-0.2.0-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.

File metadata

File hashes

Hashes for common_expression_language-0.2.0-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 6d1d14d284e7c30d19b8dad47a622dbca4a80cc95cfeba3743f943c1d65d781a
MD5 a9cb797da6e585871b4766881027f2c1
BLAKE2b-256 c3bc34dbd67b92d35c0ce897ddb004c75397ed79892cc6fae5bb6cae8400a3f0

See more details on using hashes here.

File details

Details for the file common_expression_language-0.2.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for common_expression_language-0.2.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 e888bdb347333c6e58104854fb43302d48c5bec25f68953147d51af067b16988
MD5 9141507aef0847afea59e559b7c2a717
BLAKE2b-256 12c424a5e66c279d310cb846b4608ab5c9812f3e6e0603dfff2b9664e9f5971e

See more details on using hashes here.

File details

Details for the file common_expression_language-0.2.0-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl.

File metadata

File hashes

Hashes for common_expression_language-0.2.0-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 fd3db62c00538e04721236c4372e75ac890bcf7e5525f37ab18c1e4e1d6f7db7
MD5 3515972e927f0cd9572d6540bfa7b23b
BLAKE2b-256 b59f96fa45a76d959da0794912a61b0f69de9d11632ab39a0976272a21fdea88

See more details on using hashes here.

File details

Details for the file common_expression_language-0.2.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for common_expression_language-0.2.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8d31066cd68725160588ebd0870d5a1863d32e3f261853b33f3bd92bb5a9f729
MD5 4f7a066c1f22314ad27cd14e33fb189a
BLAKE2b-256 e6e7f2580aba54b3a6a3845451c9a7586487195abbbf8f84ab9b61a9dc1806c2

See more details on using hashes here.

File details

Details for the file common_expression_language-0.2.0-cp312-cp312-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for common_expression_language-0.2.0-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 4d52a3d43b4cdf223d0cab5643498f17fd4f12b0cc754c029559b95ad2293253
MD5 398efb908f23054b5a80c2dda01bb5d2
BLAKE2b-256 cc6a1f71480df2fd44e7f8aee989a1a2b6e8e2f09e047f2855287d3710c14ea4

See more details on using hashes here.

File details

Details for the file common_expression_language-0.2.0-cp311-none-win_amd64.whl.

File metadata

File hashes

Hashes for common_expression_language-0.2.0-cp311-none-win_amd64.whl
Algorithm Hash digest
SHA256 1d6497617eff7b475893a4d1bcc2de6a35d7d6b4f27b5349786ed32611cce3a3
MD5 e197d1ce0004f5663dd626f1ebd31770
BLAKE2b-256 b323b351ccd5775c3db5ac4ee89b083de692e72e55cf14a759e8d794647173f1

See more details on using hashes here.

File details

Details for the file common_expression_language-0.2.0-cp311-none-win32.whl.

File metadata

File hashes

Hashes for common_expression_language-0.2.0-cp311-none-win32.whl
Algorithm Hash digest
SHA256 06d45038d3833f77f36cbab2a773c8ccd3249e1a773da7422b7796895e093f75
MD5 855a1efe0afd8e6d201ed900e5d86cc9
BLAKE2b-256 2dcc803321b3c1ab74424da129f0d67447bf4d62a8a22c0de1b857b21afb76c1

See more details on using hashes here.

File details

Details for the file common_expression_language-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for common_expression_language-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fe10a1a587654c2160acd3a422d2a50641168c5896e15b51db194d0612bd68a8
MD5 46c93e6362b3029853b91c92570f0beb
BLAKE2b-256 962307a5cf6f16165e9bd4aa339537be694a5abcef732316c829fd8e8380ed1f

See more details on using hashes here.

File details

Details for the file common_expression_language-0.2.0-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl.

File metadata

File hashes

Hashes for common_expression_language-0.2.0-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 d76ebbf251d0595def66839915d48a2bfa588df3c2c2d900ef454358b2b3d110
MD5 54c6f58285245192440a389e362cc6fd
BLAKE2b-256 0dd153b4a72837a54a47d86578ff54f34a20ac477863483ff5ea53413c18db65

See more details on using hashes here.

File details

Details for the file common_expression_language-0.2.0-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl.

File metadata

File hashes

Hashes for common_expression_language-0.2.0-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 7fa090655253a82daae30087abc5b4153f71d18db6dd729eba94c52178987822
MD5 cd3f2e17e38b7b85a353dc3612b3ffb4
BLAKE2b-256 1871d26c964bac4a672ae8a3aa574184e391fbef5958c0b6b3ce98a3bc7b2c4b

See more details on using hashes here.

File details

Details for the file common_expression_language-0.2.0-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.

File metadata

File hashes

Hashes for common_expression_language-0.2.0-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 92b77c3ce664415eb4b47a9dae3409af388249ba9d437166aff195c0f323386d
MD5 3f5392b8bf4205a6b101505361a16b5b
BLAKE2b-256 c91c713c99cc77a52073b779dcd79e2ef83149f2527056f58938c09ba0c799a4

See more details on using hashes here.

File details

Details for the file common_expression_language-0.2.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for common_expression_language-0.2.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 9a25c5986adcaa1f0e49cddc70b5e93c1d41d8eb7f0214b0a31f24b2822b67ff
MD5 c6efcf117b56d844a7285ea3d730a52e
BLAKE2b-256 847c7ad3a10b345f5c821bfc33f98c97a5c7a3d6a11a69764a00de50598bae5b

See more details on using hashes here.

File details

Details for the file common_expression_language-0.2.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl.

File metadata

File hashes

Hashes for common_expression_language-0.2.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 a9ebc2792c501ca8a7a172105efcd7d1ce261dabf0c51b0fde028ba6cc3a5711
MD5 dacb8343fb5e022b315a9b6ff1b20271
BLAKE2b-256 69f3d22b4bd2c4b82098cebfb3b4d1c273ad6d7e1718a1622aab504559d7b08e

See more details on using hashes here.

File details

Details for the file common_expression_language-0.2.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for common_expression_language-0.2.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 833ad098baab78643f8400045b7b2e763781c2b5c4b46dc34c18fdb97748cf0b
MD5 75ad891105d8e43821cdec8aa98b8cfb
BLAKE2b-256 5225fe25b1a5277c6809a29febbd4ce6572f4b0639a181323d33f356d6ec2e92

See more details on using hashes here.

File details

Details for the file common_expression_language-0.2.0-cp311-cp311-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for common_expression_language-0.2.0-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 a291b0de7343ca58bc501fa3a9f74242e27fef1764273462d6317aff5842cbb4
MD5 85c522c742bae3a5a9e7fd8789e3fc7f
BLAKE2b-256 162be1ac7d117ea18db7d94513611f91ef06b2aaa445af23d7096d3baf0a3251

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page