better_launch.toml.substitutions module

exception better_launch.toml.substitutions.SubstitutionError

Bases: ValueError

Exception type that will be thrown by substitution handlers.

better_launch.toml.substitutions.apply_substitutions(value: str, substitutions: dict[str, Callable] = None, context: dict[str, Any] = None, *, eval_type: Literal['full', 'literal', 'none'] = 'full') Any

Applies substitutions to a string.

Substitution strings are expected to follow the pattern: ${key *args}, where key is a substitution type and *args are additional arguments to the substitution handler.

If no other substitutions are specified, this function will handle the following ones: - ${param …} - ${env …} - ${eval …}

Substitutions other than those above will be looked up in the provided context dict.

Parameters

valuestr

A string that may contain substitution tokens.

substitutionsdict[str, Callable], optional

Custom substitution handlers. If None, defaults to param, env, and eval.

contextdict[str, Any], optional

A dict containing additional values the substitution may use.

eval_typeLiteral[β€œfull”, β€œliteral”, β€œnone”], optional

If and to what extent eval should be allowed. Default is β€œfull”.

Returns

str

The input string with all substitution tokens handled.

Raises

ValueError

If the input string contains unbalanced braces or quotes.

SubstitutionError

If a substitution handler fails.

better_launch.toml.substitutions.sub_env(key: str, default: Any = <object object>)
better_launch.toml.substitutions.sub_eval(*args, context: dict, eval_type: Literal['full', 'literal', 'none'] = 'full')
better_launch.toml.substitutions.sub_param(full_node_name: str, param: str)