launch.frontend package
Submodules
- launch.frontend.entity module
- launch.frontend.expose module
- launch.frontend.parse_substitution module
ExtractSubstitution
ExtractSubstitution.arguments()
ExtractSubstitution.double_quoted_arguments()
ExtractSubstitution.double_quoted_fragment()
ExtractSubstitution.double_quoted_part()
ExtractSubstitution.double_quoted_substitution()
ExtractSubstitution.double_quoted_template()
ExtractSubstitution.double_quoted_value()
ExtractSubstitution.fragment()
ExtractSubstitution.part()
ExtractSubstitution.single_quoted_arguments()
ExtractSubstitution.single_quoted_fragment()
ExtractSubstitution.single_quoted_part()
ExtractSubstitution.single_quoted_substitution()
ExtractSubstitution.single_quoted_template()
ExtractSubstitution.single_quoted_value()
ExtractSubstitution.substitution()
ExtractSubstitution.template()
ExtractSubstitution.value()
get_grammar_path()
parse_if_substitutions()
parse_substitution()
replace_escaped_characters()
- launch.frontend.parser module
InvalidFrontendLaunchFileError
Parser
Parser.escape_characters()
Parser.extensions_loaded
Parser.frontend_parsers
Parser.get_available_extensions()
Parser.get_file_extensions()
Parser.get_file_extensions_from_parsers()
Parser.get_parser_from_extension()
Parser.get_parsers_from_filename()
Parser.is_extension_valid()
Parser.is_filename_valid()
Parser.load()
Parser.load_launch_extensions()
Parser.load_parser_implementations()
Parser.may_parse()
Parser.parse_action()
Parser.parse_description()
Parser.parse_if_substitutions()
Parser.parse_substitution()
- launch.frontend.type_utils module
Module contents
Package for launch markup.
- class launch.frontend.Entity[source]
Bases:
object
Single item in the intermediate front_end representation.
- assert_entity_completely_parsed()[source]
Assert that all attributes and children of the entity were parsed.
This function is automatically called after the parse(entity, parser) function completed.
- get_attr(name: str, *, data_type: Type[TargetType], optional: bool, can_be_str: bool = True) TargetType | None [source]
- get_attr(name: str, *, data_type: Type[TargetType], can_be_str: bool = True) TargetType
- get_attr(name: str, *, optional: bool, can_be_str: bool = True) str | None
- get_attr(name: str, *, can_be_str: bool = True) str
Access an attribute of the entity.
By default, it will try to return it as an string. data_type is the expected type of the attribute. Type coercion or type checking is applied depending on the particular frontend.
See
launch.utilities.AllowedTypesTuple
to see what types are allowed.data_type = None will result in yaml parsing of the attribute value as a string.
List[Entity] allows accessing a list of subentities with an specific name.
Check the documentation of each specific frontend implementation to see how a list of attributes or List[Entity] look like.
If optional is True and the attribute cannot be found, None will be returned instead of raising AttributeError.
- Parameters:
name – name of the attribute
data_type – type of the attribute to be read. Defaults to ‘str’
optional – when True, it doesn’t raise an error when the attribute is not found. It returns None instead. Defaults to False
- Raises:
AttributeError – Attribute not found. Only possible if optional is False
TypeError – Attribute found but it is not of the correct type. Only happens in frontend implementations that do type checking
ValueError – Attribute found but can’t be coerced to one of the specified types. Only happens in frontend implementations that do type coercion.
- exception launch.frontend.InvalidFrontendLaunchFileError[source]
Bases:
InvalidLaunchFileError
Exception raised when the given frontend launch file is not valid.
- class launch.frontend.Parser[source]
Bases:
object
Abstract class for parsing launch actions, substitutions and descriptions.
Implementations of the parser class, should override the load method. They could also override the parse_substitution and/or get_file_extensions methods, or not. load_launch_extensions, parse_action, parse_description, get_available_extensions, may_parse, is_filename_valid, get_parsers_from_filename and get_file_extensions_from_parsers are not supposed to be overridden.
- extensions_loaded = False
- frontend_parsers = None
- classmethod get_file_extensions() Set[str] [source]
Return the set of file extensions known to this parser.
- classmethod get_file_extensions_from_parsers() Set[Type[Parser]] [source]
Return a set of file extensions known to the parser implementations.
- classmethod get_parser_from_extension(extension: str) Type[Parser] | None [source]
Return an entity loaded with a markup file.
- classmethod get_parsers_from_filename(filename: str) List[Type[Parser]] [source]
Return a list of parsers which entity loaded with a markup file.
- classmethod is_extension_valid(extension: str) bool [source]
Return an entity loaded with a markup file.
- classmethod is_filename_valid(filename: str) bool [source]
Return True if the filename is valid for any parser.
- classmethod load(file: FilePath | TextIO) Tuple[Entity, Parser] [source]
Parse an Entity from a markup language-based launch file.
Parsers are exposed and provided by available frontend implementations. To choose the right parser, it’ll first attempt to infer the launch description format based on the filename extension, if any. If format inference fails, it’ll try all available parsers one after the other.
- classmethod load_launch_extensions()[source]
Load launch extensions, in order to get all the exposed substitutions and actions.
- classmethod may_parse(filename: str) bool [source]
Return True if the filename is valid for this parser.
- parse_description(entity: Entity) LaunchDescription [source]
Parse a launch description.
- parse_if_substitutions(value: str | Substitution | Iterable[str | Substitution] | int | float | bool | Sequence[int | str] | Sequence[float | str] | Sequence[bool | str] | Sequence[str]) List[Substitution] | int | float | bool | str | List[int | List[Substitution]] | List[float | List[Substitution]] | List[bool | List[Substitution]] | List[str | List[Substitution]] [source]
See
launch.frontend.parser.parse_if_substitutions()
.
- parse_substitution(value: str) List[Substitution] [source]
Parse a substitution.