:mod:`cloup.constraints.conditions` =================================== .. py:module:: cloup.constraints.conditions .. autoapi-nested-parse:: This modules contains described predicates that you can use as conditions of conditional constraints (see :class:`cloup.constraints.If`). Predicates should be treated as immutable objects, even though immutability is not (at the moment) enforced. Classes summary --------------- .. autosummary:: ~cloup.constraints.conditions.Predicate ~cloup.constraints.conditions.Not ~cloup.constraints.conditions.IsSet ~cloup.constraints.conditions.Equal Contents -------- .. data:: P .. class:: Predicate Bases: :py:obj:`abc.ABC` A ``Callable`` that takes a ``Context`` and returns a boolean, with an associated description. Meant to be used as condition in a conditional constraint (see :class:`~cloup.constraints.If`). .. method:: description(self, ctx) :abstractmethod: Succint description of the predicate (alias: `desc`). .. method:: negated_description(self, ctx) Succint description of the negation of this predicate (alias: `neg_desc`). .. method:: desc(self, ctx) Short alias for :meth:`description`. .. method:: neg_desc(self, ctx) Short alias for :meth:`negated_description`. .. method:: negated(self) .. method:: __call__(self, ctx) :abstractmethod: Evaluate the predicate on the given context. .. method:: __invert__(self) .. method:: __or__(self, other) .. method:: __and__(self, other) .. method:: __repr__(self) Return repr(self). .. class:: Not(predicate) Bases: :py:obj:`Predicate`, :py:obj:`Generic`\ [\ :py:obj:`P`\ ] A ``Callable`` that takes a ``Context`` and returns a boolean, with an associated description. Meant to be used as condition in a conditional constraint (see :class:`~cloup.constraints.If`). .. method:: description(self, ctx) Succint description of the predicate (alias: `desc`). .. method:: negated_description(self, ctx) Succint description of the negation of this predicate (alias: `neg_desc`). .. method:: __call__(self, ctx) Evaluate the predicate on the given context. .. method:: __invert__(self) .. method:: __repr__(self) Return repr(self). .. class:: IsSet(param_name) Bases: :py:obj:`Predicate` A ``Callable`` that takes a ``Context`` and returns a boolean, with an associated description. Meant to be used as condition in a conditional constraint (see :class:`~cloup.constraints.If`). .. method:: description(self, ctx) Succint description of the predicate (alias: `desc`). .. method:: negated_description(self, ctx) Succint description of the negation of this predicate (alias: `neg_desc`). .. method:: __call__(self, ctx) Evaluate the predicate on the given context. .. class:: Equal(param_name, value) Bases: :py:obj:`Predicate` True if the parameter value equals ``value``. .. method:: description(self, ctx) Succint description of the predicate (alias: `desc`). .. method:: negated_description(self, ctx) Succint description of the negation of this predicate (alias: `neg_desc`). .. method:: __call__(self, ctx) Evaluate the predicate on the given context.