diff --git a/launch/launch/actions/pop_environment.py b/launch/launch/actions/pop_environment.py index 1a18d83de..308a0f327 100644 --- a/launch/launch/actions/pop_environment.py +++ b/launch/launch/actions/pop_environment.py @@ -15,11 +15,18 @@ """Module for the PopEnvironment action.""" from typing import Any +from typing import Dict +from typing import Tuple +from typing import Type from ..action import Action +from ..frontend import Entity +from ..frontend import expose_action +from ..frontend import Parser from ..launch_context import LaunchContext +@expose_action('pop_env') class PopEnvironment(Action): """ Action that pops the state of environment variables from a stack. @@ -32,6 +39,13 @@ def __init__(self, **kwargs: Any) -> None: """Create a PopEnvironment action.""" super().__init__(**kwargs) + @classmethod + def parse(cls, entity: Entity, parser: Parser + ) -> Tuple[Type['PopEnvironment'], Dict[str, Any]]: + """Return ``PopEnvironment`` action and kwargs for constructing it.""" + _, kwargs = super().parse(entity, parser) + return cls, kwargs + def execute(self, context: LaunchContext) -> None: """Execute the action.""" context._pop_environment() diff --git a/launch/launch/actions/pop_launch_configurations.py b/launch/launch/actions/pop_launch_configurations.py index 99c0a2204..1190388d2 100644 --- a/launch/launch/actions/pop_launch_configurations.py +++ b/launch/launch/actions/pop_launch_configurations.py @@ -15,11 +15,18 @@ """Module for the PopLaunchConfigurations action.""" from typing import Any +from typing import Dict +from typing import Tuple +from typing import Type from ..action import Action +from ..frontend import Entity +from ..frontend import expose_action +from ..frontend import Parser from ..launch_context import LaunchContext +@expose_action('pop_vars') class PopLaunchConfigurations(Action): """ Action that pops the state of launch configurations from a stack. @@ -32,6 +39,13 @@ def __init__(self, **kwargs: Any) -> None: """Create a PopLaunchConfigurations action.""" super().__init__(**kwargs) + @classmethod + def parse(cls, entity: Entity, parser: Parser + ) -> Tuple[Type['PopLaunchConfigurations'], Dict[str, Any]]: + """Return ``PopLaunchConfigurations`` action and kwargs for constructing it.""" + _, kwargs = super().parse(entity, parser) + return cls, kwargs + def execute(self, context: LaunchContext) -> None: """Execute the action.""" context._pop_launch_configurations() diff --git a/launch/launch/actions/push_environment.py b/launch/launch/actions/push_environment.py index 4d5d675d9..394816d2c 100644 --- a/launch/launch/actions/push_environment.py +++ b/launch/launch/actions/push_environment.py @@ -15,11 +15,18 @@ """Module for the PushEnvironment action.""" from typing import Any +from typing import Dict +from typing import Tuple +from typing import Type from ..action import Action +from ..frontend import Entity +from ..frontend import expose_action +from ..frontend import Parser from ..launch_context import LaunchContext +@expose_action('push_env') class PushEnvironment(Action): """ Action that pushes the current environment to a stack. @@ -32,6 +39,13 @@ def __init__(self, **kwargs: Any) -> None: """Create a PushEnvironment action.""" super().__init__(**kwargs) + @classmethod + def parse(cls, entity: Entity, parser: Parser + ) -> Tuple[Type['PushEnvironment'], Dict[str, Any]]: + """Return ``PushEnvironment`` action and kwargs for constructing it.""" + _, kwargs = super().parse(entity, parser) + return cls, kwargs + def execute(self, context: LaunchContext) -> None: """Execute the action.""" context._push_environment() diff --git a/launch/launch/actions/push_launch_configurations.py b/launch/launch/actions/push_launch_configurations.py index 8c5f50315..a645633b5 100644 --- a/launch/launch/actions/push_launch_configurations.py +++ b/launch/launch/actions/push_launch_configurations.py @@ -15,11 +15,18 @@ """Module for the PushLaunchConfigurations action.""" from typing import Any +from typing import Dict +from typing import Tuple +from typing import Type from ..action import Action +from ..frontend import Entity +from ..frontend import expose_action +from ..frontend import Parser from ..launch_context import LaunchContext +@expose_action('push_vars') class PushLaunchConfigurations(Action): """ Action that pushes the current state of launch configurations to a stack. @@ -32,6 +39,13 @@ def __init__(self, **kwargs: Any) -> None: """Create a PushLaunchConfigurations action.""" super().__init__(**kwargs) + @classmethod + def parse(cls, entity: Entity, parser: Parser + ) -> Tuple[Type['PushLaunchConfigurations'], Dict[str, Any]]: + """Return ``PushLaunchConfigurations`` action and kwargs for constructing it.""" + _, kwargs = super().parse(entity, parser) + return cls, kwargs + def execute(self, context: LaunchContext) -> None: """Execute the action.""" context._push_launch_configurations() diff --git a/launch/launch/actions/unset_launch_configuration.py b/launch/launch/actions/unset_launch_configuration.py index 4dbeebfb1..e2ec25c30 100644 --- a/launch/launch/actions/unset_launch_configuration.py +++ b/launch/launch/actions/unset_launch_configuration.py @@ -15,9 +15,15 @@ """Module for the UnsetLaunchConfiguration action.""" from typing import Any +from typing import Dict from typing import List +from typing import Tuple +from typing import Type from ..action import Action +from ..frontend import Entity +from ..frontend import expose_action +from ..frontend import Parser from ..launch_context import LaunchContext from ..some_substitutions_type import SomeSubstitutionsType from ..substitution import Substitution @@ -25,11 +31,12 @@ from ..utilities import perform_substitutions +@expose_action('unset') class UnsetLaunchConfiguration(Action): """ Action that unsets a launch configuration by name. - If the given launch configuration name is no set already then nothing + If the given launch configuration name is not set already then nothing happens. /sa :py:class:`launch.actions.SetLaunchConfiguration` @@ -44,6 +51,14 @@ def __init__( super().__init__(**kwargs) self.__name = normalize_to_list_of_substitutions(name) + @classmethod + def parse(cls, entity: Entity, parser: Parser + ) -> Tuple[Type['UnsetLaunchConfiguration'], Dict[str, Any]]: + """Return ``UnsetLaunchConfiguration`` action and kwargs for constructing it.""" + _, kwargs = super().parse(entity, parser) + kwargs['name'] = parser.parse_substitution(entity.get_attr('name')) + return cls, kwargs + @property def name(self) -> List[Substitution]: """Getter for self.__name."""