launch.frontend.parser module

Module for Parser class and parsing methods.

exception launch.frontend.parser.InvalidFrontendLaunchFileError[source]

Bases: InvalidLaunchFileError

Exception raised when the given frontend launch file is not valid.

class launch.frontend.parser.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.

escape_characters(value: str) str[source]

Escape characters in strings.

extensions_loaded = False
frontend_parsers = None
classmethod get_available_extensions() List[str][source]

Return the registered extensions.

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 load_parser_implementations()[source]

Load all the available frontend entities.

classmethod may_parse(filename: str) bool[source]

Return True if the filename is valid for this parser.

parse_action(entity: Entity) Action[source]

Parse an action, using its registered parsing method.

parse_description(entity: Entity) LaunchDescription[source]

Parse a launch description.

parse_if_substitutions(value: str | Path | Substitution | Iterable[str | Path | 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.