cloup.constraints.conditions¶
This modules contains predicates with an associated description that you can use
as conditions of conditional constraints (see cloup.constraints.If).
Predicates should be treated as immutable objects, even though immutability is not (at the moment) enforced.
Classes¶
Attributes¶
Contents¶
- cloup.constraints.conditions.P¶
- class cloup.constraints.conditions.Predicate[source]¶
Bases:
abc.ABCA
Callablethat takes aclick.Contextand returns a boolean, with an associated description. Meant to be used as condition in a conditional constraint (seeIf).- abstract description(ctx)[source]¶
Succinct description of the predicate (alias: desc).
- Parameters:
ctx (click.Context)
- Return type:
- negated_description(ctx)[source]¶
Succinct description of the negation of this predicate (alias: neg_desc).
- Parameters:
ctx (click.Context)
- Return type:
- desc(ctx)[source]¶
Short alias for
description().- Parameters:
ctx (click.Context)
- Return type:
- neg_desc(ctx)[source]¶
Short alias for
negated_description().- Parameters:
ctx (click.Context)
- Return type:
- abstract __call__(ctx)[source]¶
Evaluate the predicate on the given context.
- Parameters:
ctx (click.Context)
- Return type:
- class cloup.constraints.conditions.Not(predicate)[source]¶
-
Logical NOT of a predicate.
- Parameters:
predicate (P)
- predicate¶
- description(ctx)[source]¶
Succinct description of the predicate (alias: desc).
- Parameters:
ctx (click.Context)
- Return type:
- negated_description(ctx)[source]¶
Succinct description of the negation of this predicate (alias: neg_desc).
- Parameters:
ctx (click.Context)
- Return type:
- __call__(ctx)[source]¶
Evaluate the predicate on the given context.
- Parameters:
ctx (click.Context)
- Return type:
- class cloup.constraints.conditions.IsSet(param_name)[source]¶
Bases:
PredicateTrue if the parameter is set.
- Parameters:
param_name (str)
- param_name¶
- description(ctx)[source]¶
Succinct description of the predicate (alias: desc).
- Parameters:
ctx (click.Context)
- Return type:
- negated_description(ctx)[source]¶
Succinct description of the negation of this predicate (alias: neg_desc).
- Parameters:
ctx (click.Context)
- Return type:
- __call__(ctx)[source]¶
Evaluate the predicate on the given context.
- Parameters:
ctx (click.Context)
- Return type:
- class cloup.constraints.conditions.AllSet(*param_names)[source]¶
Bases:
PredicateTrue if all listed parameters are set.
Added in version 0.8.0.
- Parameters:
param_names (str)
- param_names = ()¶
- negated_description(ctx)[source]¶
Succinct description of the negation of this predicate (alias: neg_desc).
- Parameters:
ctx (click.Context)
- Return type:
- description(ctx)[source]¶
Succinct description of the predicate (alias: desc).
- Parameters:
ctx (click.Context)
- Return type:
- __call__(ctx)[source]¶
Evaluate the predicate on the given context.
- Parameters:
ctx (click.Context)
- Return type:
- class cloup.constraints.conditions.AnySet(*param_names)[source]¶
Bases:
PredicateTrue if any of the listed parameters is set.
Added in version 0.8.0.
- Parameters:
param_names (str)
- param_names = ()¶
- negated_description(ctx)[source]¶
Succinct description of the negation of this predicate (alias: neg_desc).
- Parameters:
ctx (click.Context)
- Return type:
- description(ctx)[source]¶
Succinct description of the predicate (alias: desc).
- Parameters:
ctx (click.Context)
- Return type:
- __call__(ctx)[source]¶
Evaluate the predicate on the given context.
- Parameters:
ctx (click.Context)
- Return type:
- class cloup.constraints.conditions.Equal(param_name, value)[source]¶
Bases:
PredicateTrue if the parameter value equals
value.- Parameters:
param_name (str)
value (Any)
- param_name¶
- value¶
- description(ctx)[source]¶
Succinct description of the predicate (alias: desc).
- Parameters:
ctx (click.Context)
- Return type:
- negated_description(ctx)[source]¶
Succinct description of the negation of this predicate (alias: neg_desc).
- Parameters:
ctx (click.Context)
- Return type:
- __call__(ctx)[source]¶
Evaluate the predicate on the given context.
- Parameters:
ctx (click.Context)
- Return type: