launch.conditions package

Submodules

Module contents

conditions Module.

class launch.conditions.IfCondition[source]

Bases: Condition

Encapsulates an if condition to be evaluated when launching.

This condition takes a string expression that is lexically evaluated as a boolean, but the expression may consist of launch.Substitution instances.

See evaluate_condition_expression() to understand what constitutes a valid condition expression.

__init__(predicate_expression: str | Substitution | Iterable[str | Substitution]) None[source]
describe() str[source]

Return a description of this Condition.

exception launch.conditions.InvalidConditionExpressionError[source]

Bases: ValueError

Raised when an expression being evaluated as a condition is invalid.

__init__(expression: str, unexpanded_expression: List[Substitution], valid_expressions: List[str]) None[source]
class launch.conditions.LaunchConfigurationEquals[source]

Bases: Condition

Condition on the value of a launch configuration.

This condition takes an optional string expression that is compared with the value of a launch configuration. If the value is equal to the launch configuration value, then this Condition evaluates to True. The expression may consist of launch.Substitution instances.

If None is provided instead of a string expression, then the condition evaluates to True if the launch configuration is not set.

Deprecated since version 1.1.0: Replaced by the more universally usable substitutions: ‘EqualsSubstitution’ and ‘NotEqualsSubstitution’

__init__(launch_configuration_name: str, expected_value: str | Substitution | Iterable[str | Substitution] | None) None[source]
describe() str[source]

Return a description of this Condition.

class launch.conditions.LaunchConfigurationNotEquals[source]

Bases: LaunchConfigurationEquals

Condition on the value of a launch configuration.

This condition takes an optional string expression that is compared with the value of a launch configuration. If the value is not equal to the launch configuration value, then this Condition evaluates to True. The expression may consist of launch.Substitution instances.

If None is provided instead of a string expression, then the condition evaluates to True if the launch configuration is set.

Deprecated since version 1.1.0: Replaced by the more universally usable substitutions: ‘EqualsSubstitution’ and ‘NotEqualsSubstitution’

__init__(launch_configuration_name: str, expected_value: str | Substitution | Iterable[str | Substitution] | None) None[source]
describe() str[source]

Return a description of this Condition.

class launch.conditions.UnlessCondition[source]

Bases: IfCondition

Encapsulates an if condition to be evaluated when launching.

Exactly the same as IfCondition except it returns true if the condition expression evaluates to false.

__init__(predicate_expression: str | Substitution | Iterable[str | Substitution]) None[source]
describe() str[source]

Return a description of this Condition.

launch.conditions.evaluate_condition_expression(context: LaunchContext, expression: List[Substitution]) bool[source]

Expand an expression and then evaluate it as a condition, returning true or false.

The expanded expression is stripped and has lower() called on it before being logically evaluated as either true or false. A string will be considered True if it matches ‘true’ or ‘1’. A string will be considered False if it matches ‘false’ or ‘0’. Any other string content (including empty string) will result in an error.

Raises:

InvalidConditionExpressionError