Predicate

source: bluebase/core/predicate.py


class Comp(*values)[source]

Bases: Enum

A comparison operator for predicates.

EQ = '='

Compare whether the target value is equal to the predicate value.

NE = '<>'

Compare whether the target value is not equal to the predicate value.

LT = '<'

Compare whether the target value is less than the predicate value.

LE = '<='

Compare whether the target value is less than or equal to the predicate value.

GT = '>'

Compare whether the target value is greater than the predicate value.

GE = '>='

Compare whether the target value is greater than or equal to the predicate value.

dataclassclass Predicate(name: str, comp: Comp, value: bool | int | float | str)[source]

Bases: object

A predicate for evaluating a value.

Variables:
  • name (str) – the name of the attribute

  • comp (Comp) – the comparison operator

  • value (bool | int | float | str) – the reference value of the predicate

evaluate(value: bool | int | float | str) → bool[source]

Evaluate whether a value satisfies the predicate.