Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions launch/launch/actions/pop_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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()
14 changes: 14 additions & 0 deletions launch/launch/actions/pop_launch_configurations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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()
14 changes: 14 additions & 0 deletions launch/launch/actions/push_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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()
14 changes: 14 additions & 0 deletions launch/launch/actions/push_launch_configurations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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()
17 changes: 16 additions & 1 deletion launch/launch/actions/unset_launch_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,28 @@
"""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
from ..utilities import normalize_to_list_of_substitutions
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`
Expand All @@ -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."""
Expand Down