-
-

APIΒΆ

-

Details of the CEL-Python implementation and the API to the various components.

+
+

API ReferenceΒΆ

+

Detailed reference material for the CEL-Python implementation.

The following modules are described here:

adapterΒΆ

-

Converts some Python-native types into CEL structures.

+

Adapters to convert some Python-native types into CEL structures.

Currently, atomic Python objects have direct use of types in celpy.celtypes.

Non-atomic Python objects are characterized by JSON and Protobuf messages. This module has functions to convert JSON objects to CEL.

@@ -479,8 +539,57 @@
celpy.adapter.json_to_cel(document: Dict[str, Any] | List[Any] | bool | float | int | str | None) BoolType | BytesType | DoubleType | DurationType | IntType | ListType | MapType | None | StringType | TimestampType | UintType[source]ΒΆ
-

Convert parsed JSON object from Python to CEL to the extent possible.

-

It’s difficult to distinguish strings which should be timestamps or durations.

+

Converts parsed JSON object from Python to CEL to the extent possible.

+

Note that it’s difficult to distinguish strings which should be timestamps or durations. +Using the json package objecthook can help do these conversions.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

python

CEL

bool

celpy.celtypes.BoolType

float

celpy.celtypes.DoubleType

int

celpy.celtypes.IntType

str

celpy.celtypes.StringType

None

None

tuple, list

celpy.celtypes.ListType

dict

celpy.celtypes.MapType

datetime.datetime

celpy.celtypes.TimestampType

datetime.timedelta

celpy.celtypes.DurationType

+
+
Parameters:
+

document – A JSON document.

+
+
Returns:
+

celpy.celtypes.Value.

+
+
Raises:
+

internal ValueError or TypeError for failed conversions.

+
+
+

Example:

>>> from pprint import pprint
 >>> from celpy.adapter import json_to_cel
 >>> doc = json.loads('["str", 42, 3.14, null, true, {"hello": "world"}]')
@@ -1365,9 +1474,20 @@ 

Name Resolution evaluate(context: Mapping[str, BoolType | BytesType | DoubleType | DurationType | IntType | ListType | MapType | None | StringType | TimestampType | UintType | CELEvalError | Type[BoolType] | Type[BytesType] | Type[DoubleType] | Type[DurationType] | Type[IntType] | Type[ListType] | Type[MapType] | Callable[[...], None] | Type[StringType] | Type[TimestampType] | Type[TypeType] | Type[UintType] | Type[PackageType] | Type[MessageType] | NameContainer | CELFunction], filter: Any | None = None) BoolType | BytesType | DoubleType | DurationType | IntType | ListType | MapType | None | StringType | TimestampType | UintType[source]ΒΆ

Given variable definitions in the celpy.evaluation.Context, evaluate the given AST and return the resulting value.

-

Generally, this should raise an CELEvalError for most kinds of ordinary problems. -It may raise an CELUnsupportedError for future features that aren’t fully implemented. +

Generally, this should raise an celpy.evaluation.CELEvalError for most kinds of ordinary problems. +It may raise an celpy.evaluation.CELUnsupportedError for future features that aren’t fully implemented. Any Python exception reflects a serious problem.

+
+
Parameters:
+

activation – a celpy.evaluation.Context object with variable values to use for this evaluation.

+
+
Returns:
+

the computed value

+
+
Raises:
+

celpy.evaluation.CELEvalError or celpy.evaluation.CELUnsupportedError for problems encounterd.

+
+

@@ -2909,7 +3029,8 @@

Timzone Details
celpy.evaluation.function_matches(text: str, pattern: str) Result[source]ΒΆ
-

+

Implementation of the match() function using re2

+