:mod:`cloup.constraints.conditions` =================================== .. py:module:: cloup.constraints.conditions .. autoapi-nested-parse:: This modules contains predicates with an associated description 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 ------- .. autosummary:: ~cloup.constraints.conditions.Predicate ~cloup.constraints.conditions.Not ~cloup.constraints.conditions.IsSet ~cloup.constraints.conditions.AllSet ~cloup.constraints.conditions.AnySet ~cloup.constraints.conditions.Equal Attributes ---------- .. autoapisummary:: cloup.constraints.conditions.P Contents -------- .. py:data:: P .. py:class:: Predicate Bases: :py:obj:`abc.ABC` A ``Callable`` that takes a ``click.Context`` and returns a boolean, with an associated description. Meant to be used as condition in a conditional constraint (see :class:`~cloup.constraints.If`). .. py:method:: description(self, ctx) :abstractmethod: Succinct description of the predicate (alias: `desc`). .. py:method:: negated_description(self, ctx) Succinct description of the negation of this predicate (alias: `neg_desc`). .. py:method:: desc(self, ctx) Short alias for :meth:`description`. .. py:method:: neg_desc(self, ctx) Short alias for :meth:`negated_description`. .. py:method:: negated(self) .. py:method:: __call__(self, ctx) :abstractmethod: Evaluate the predicate on the given context. .. py:method:: __invert__(self) .. py:method:: __or__(self, other) .. py:method:: __and__(self, other) .. py:method:: __repr__(self) Return repr(self). .. py:method:: __eq__(self, other) Return self==value. .. py:class:: Not(predicate) Bases: :py:obj:`Predicate`, :py:obj:`Generic`\ [\ :py:obj:`P`\ ] Logical NOT of a predicate. .. py:method:: description(self, ctx) Succinct description of the predicate (alias: `desc`). .. py:method:: negated_description(self, ctx) Succinct description of the negation of this predicate (alias: `neg_desc`). .. py:method:: __call__(self, ctx) Evaluate the predicate on the given context. .. py:method:: __invert__(self) .. py:method:: __repr__(self) Return repr(self). .. py:class:: IsSet(param_name) Bases: :py:obj:`Predicate` True if the parameter is set. .. py:method:: description(self, ctx) Succinct description of the predicate (alias: `desc`). .. py:method:: negated_description(self, ctx) Succinct description of the negation of this predicate (alias: `neg_desc`). .. py:method:: __call__(self, ctx) Evaluate the predicate on the given context. .. py:method:: __and__(self, other) .. py:method:: __or__(self, other) .. py:class:: AllSet(*param_names) Bases: :py:obj:`Predicate` True if all listed parameters are set. .. versionadded:: 0.8.0 .. py:method:: negated_description(self, ctx) Succinct description of the negation of this predicate (alias: `neg_desc`). .. py:method:: description(self, ctx) Succinct description of the predicate (alias: `desc`). .. py:method:: __call__(self, ctx) Evaluate the predicate on the given context. .. py:method:: __and__(self, other) .. py:class:: AnySet(*param_names) Bases: :py:obj:`Predicate` True if any of the listed parameters is set. .. versionadded:: 0.8.0 .. py:method:: negated_description(self, ctx) Succinct description of the negation of this predicate (alias: `neg_desc`). .. py:method:: description(self, ctx) Succinct description of the predicate (alias: `desc`). .. py:method:: __call__(self, ctx) Evaluate the predicate on the given context. .. py:method:: __or__(self, other) .. py:class:: Equal(param_name, value) Bases: :py:obj:`Predicate` True if the parameter value equals ``value``. .. py:method:: description(self, ctx) Succinct description of the predicate (alias: `desc`). .. py:method:: negated_description(self, ctx) Succinct description of the negation of this predicate (alias: `neg_desc`). .. py:method:: __call__(self, ctx) Evaluate the predicate on the given context.