launch.substitutions.environment_variable module

Module for the EnvironmentVariable substitution.

class launch.substitutions.environment_variable.EnvironmentVariable[source]

Bases: Substitution

Substitution that gets an environment variable value as a string.

If the environment variable is not found, it returns empty string.

Note that the environment variable is resolved based on the launch context’s environment (i.e., context.environment) even though the substitution may be associated with an entity that might have a different set of environment variables.

__init__(name: str | Substitution | Iterable[str | Substitution], *, default_value: str | Substitution | Iterable[str | Substitution] | None = None) None[source]

Construct an environment variable substitution.

Parameters:
  • name – name of the environment variable.

  • default_value – used when the environment variable doesn’t exist. If None, the substitution is not optional.

Raises:

launch.substitutions.substitution_failure.SubstitutionFailure – If the environment variable doesn’t exist and default_value is None.

property default_value: List[Substitution] | None

Getter for default_value.

describe() str[source]

Return a description of this substitution as a string.

property name: List[Substitution]

Getter for name.

classmethod parse(data: Sequence[str | Substitution | Iterable[str | Substitution]])[source]

Parse EnviromentVariable substitution.

perform(context: LaunchContext) str[source]

Perform the substitution by looking up the environment variable.