An external client depends on the :py:class:`celpy.Environment`.
The :py:class:`celpy.Environment` builds the initial AST and the final runnable "program." The :py:class:`celpy.Environment` may also contain a type provider and type adapters.
The :py:class:`celpy.Environment` also builds an :py:class:`celpy.evaluation.Activation` with the variable and function bindings and the default package.
The :py:class:`celpy.evaluation.Activation` create a kind of chainmap for name resolution. The chain has the following structure:
- The end of the chain is the built-in defaults.
- A layer on top of this can be provided as part of integration into some other app or framework.
- The next layer is the "current" activation when evaluating a given expression. This often has command-line variables.
- A transient top-most layer is used to create a local variable binding for the macro evaluations.
The AST is created by Lark from the CEL expression.
There are two :py:class:`celpy.Runner` implementations.
- The :py:class:`celpy.InterpretedRunner` walks the AST, creating the final result or exception.
- The :py:class:`celpy.CompiledRunner` transforms the AST to remove empty rules. Then emits the result as a Python expression. It uses the Python internal :py:func:`compile` and :py:func:`eval` functions to evaluate the expression.
There are ten extension types that wrap Python built-in types to provide the unique CEL semantics.
- :py:class:`celtypes.BoolType` wraps
intand creates additional type overload exceptions. - :py:class:`celtypes.BytesType` wraps
bytesit handles conversion from :py:class:`celtypes.StringType`. - :py:class:`celtypes.DoubleType` wraps
floatand creates additional type overload exceptions. - :py:class:`celtypes.IntType` wraps
intand adds a 64-bit signed range constraint. - :py:class:`celtypes.UintType` wraps
intand adds a 64-bit unsigned range constraint. - :py:class:`celtypes.ListType` wraps
listand includes some type overload exceptions. - :py:class:`celtypes.MapType` wraps
dictand includes some type overload exceptions. Additionally, theMapKeyTypestype hint is the subset of types permitted as keys. - :py:class:`celtypes.StringType` wraps
strand includes some type overload exceptions. - :py:class:`celtypes.TimestampType` wraps
datetime.datetimeand includes a number of conversions fromdatetime.datetime,int, andstrvalues. - :py:class:`celtypes.DurationType` wraps
datetime.timedeltaand includes a number of conversions fromdatetime.timedelta,int, andstrvalues.
Additionally, a :py:class:`celtypes.NullType` is defined, but does not seem to be needed. It hasn't been deleted, yet. but should be considered deprecated.