Skip to content

Commit 73098cf

Browse files
authored
RosTimer -> ROSTimer and PushRosNamespace -> PushROSNamespace, to follow PEP8 (ros2#326)
Signed-off-by: William Woodall <[email protected]> Signed-off-by: William Woodall <[email protected]>
1 parent 1ec2fe6 commit 73098cf

File tree

6 files changed

+36
-32
lines changed

6 files changed

+36
-32
lines changed

launch_ros/launch_ros/actions/__init__.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
1818
from .lifecycle_node import LifecycleNode
1919
from .load_composable_nodes import LoadComposableNodes
2020
from .node import Node
21-
from .push_ros_namespace import PushRosNamespace
22-
from .ros_timer import RosTimer
21+
from .push_ros_namespace import PushROSNamespace
22+
from .push_ros_namespace import PushROSNamespace as PushRosNamespace
23+
from .ros_timer import ROSTimer
24+
from .ros_timer import ROSTimer as RosTimer
2325
from .set_parameter import SetParameter
2426
from .set_parameters_from_file import SetParametersFromFile
2527
from .set_remap import SetRemap
@@ -32,7 +34,9 @@
3234
'LifecycleNode',
3335
'LoadComposableNodes',
3436
'Node',
37+
'PushROSNamespace',
3538
'PushRosNamespace',
39+
'ROSTimer',
3640
'RosTimer',
3741
'SetParameter',
3842
'SetParametersFromFile',

launch_ros/launch_ros/actions/push_ros_namespace.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
"""Module for the `PushRosNamespace` action."""
15+
"""Module for the `PushROSNamespace` action."""
1616

1717
from typing import List
1818

@@ -35,7 +35,7 @@
3535

3636
@expose_action('push_ros_namespace')
3737
@expose_action('push-ros-namespace')
38-
class PushRosNamespace(Action):
38+
class PushROSNamespace(Action):
3939
"""
4040
Action that pushes the ros namespace.
4141
@@ -48,13 +48,13 @@ def __init__(
4848
namespace: SomeSubstitutionsType,
4949
**kwargs
5050
) -> None:
51-
"""Create a PushRosNamespace action."""
51+
"""Create a PushROSNamespace action."""
5252
super().__init__(**kwargs)
5353
self.__namespace = normalize_to_list_of_substitutions(namespace)
5454

5555
@classmethod
5656
def parse(cls, entity: Entity, parser: Parser):
57-
"""Return `PushRosNamespace` action and kwargs for constructing it."""
57+
"""Return `PushROSNamespace` action and kwargs for constructing it."""
5858
_, kwargs = super().parse(entity, parser)
5959
kwargs['namespace'] = parser.parse_substitution(entity.get_attr('namespace'))
6060
return cls, kwargs

launch_ros/launch_ros/actions/ros_timer.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
"""Module for the RosTimer action."""
15+
"""Module for the ROSTimer action."""
1616

1717
import asyncio
1818
import collections.abc
@@ -39,7 +39,7 @@
3939

4040

4141
@expose_action('ros_timer')
42-
class RosTimer(TimerAction):
42+
class ROSTimer(TimerAction):
4343
"""
4444
Action that defers other entities until a period of time has passed, unless canceled.
4545
@@ -56,15 +56,15 @@ def __init__(
5656
**kwargs
5757
) -> None:
5858
"""
59-
Create a RosTimer.
59+
Create a ROSTimer.
6060
6161
:param period: is the time (in seconds) to set the timer for.
6262
:param actions: is an iterable containing actions to be executed upon on timeout.
6363
"""
6464
super().__init__(period=period, actions=actions, **kwargs)
6565
period_types = list(SomeSubstitutionsType_types_tuple) + [float]
66-
ensure_argument_type(period, period_types, 'period', 'RosTimer')
67-
ensure_argument_type(actions, collections.abc.Iterable, 'actions', 'RosTimer')
66+
ensure_argument_type(period, period_types, 'period', 'ROSTimer')
67+
ensure_argument_type(actions, collections.abc.Iterable, 'actions', 'ROSTimer')
6868
self.__period = type_utils.normalize_typed_substitution(period, float)
6969
self.__timer_future: Optional[asyncio.Future] = None
7070

@@ -94,16 +94,16 @@ def parse(
9494
entity: Entity,
9595
parser: Parser,
9696
):
97-
"""Return the `RosTimer` action and kwargs for constructing it."""
97+
"""Return the `ROSTimer` action and kwargs for constructing it."""
9898
_, kwargs = super().parse(entity, parser)
9999
kwargs['period'] = parser.parse_if_substitutions(
100100
entity.get_attr('period', data_type=float, can_be_str=True))
101101
kwargs['actions'] = [parser.parse_action(child) for child in entity.children]
102102
return cls, kwargs
103103

104104
def describe(self) -> Text:
105-
"""Return a description of this RosTimer."""
106-
return 'RosTimer(period={}, actions=<actions>)'.format(self.__period)
105+
"""Return a description of this ROSTimer."""
106+
return 'ROSTimer(period={}, actions=<actions>)'.format(self.__period)
107107

108108
def execute(self, context: LaunchContext):
109109
self.__timer_future = create_future(context.asyncio_loop)

test_launch_ros/test/test_launch_ros/actions/test_load_composable_nodes.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from launch import LaunchService
2424
from launch.actions import GroupAction
2525
from launch_ros.actions import LoadComposableNodes
26-
from launch_ros.actions import PushRosNamespace
26+
from launch_ros.actions import PushROSNamespace
2727
from launch_ros.actions import SetRemap
2828
from launch_ros.descriptions import ComposableNode
2929
from launch_ros.utilities import get_node_name_count
@@ -414,7 +414,7 @@ def test_load_node_with_param_file(mock_component_container):
414414
# Node name with namespace from launch
415415
# Params file has no namespace
416416
context = _assert_launch_no_errors([
417-
PushRosNamespace('ns'),
417+
PushROSNamespace('ns'),
418418
_load_composable_node(
419419
package='foo_package',
420420
plugin='bar_plugin',
@@ -433,7 +433,7 @@ def test_load_node_with_param_file(mock_component_container):
433433
# Node name with namespace from launch
434434
# Params file has expected namespace
435435
context = _assert_launch_no_errors([
436-
PushRosNamespace('ns'),
436+
PushROSNamespace('ns'),
437437
_load_composable_node(
438438
package='foo_package',
439439
plugin='bar_plugin',
@@ -490,7 +490,7 @@ def test_load_node_with_namespace_in_group(mock_component_container):
490490
context = _assert_launch_no_errors([
491491
GroupAction(
492492
[
493-
PushRosNamespace('foo'),
493+
PushROSNamespace('foo'),
494494
_load_composable_node(
495495
package='foo_package',
496496
plugin='bar_plugin',

test_launch_ros/test/test_launch_ros/actions/test_push_ros_namespace.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
"""Tests for the PushRosNamespace Action."""
15+
"""Tests for the PushROSNamespace Action."""
1616

1717
from launch_ros.actions import Node
18-
from launch_ros.actions import PushRosNamespace
18+
from launch_ros.actions import PushROSNamespace
1919
from launch_ros.actions.load_composable_nodes import get_composable_node_load_request
2020
from launch_ros.descriptions import ComposableNode
2121

@@ -105,10 +105,10 @@ def get_test_cases():
105105
def test_push_ros_namespace(config):
106106
lc = MockContext()
107107
if config.push_ns is not None:
108-
pns1 = PushRosNamespace(config.push_ns)
108+
pns1 = PushROSNamespace(config.push_ns)
109109
pns1.execute(lc)
110110
if config.second_push_ns is not None:
111-
pns2 = PushRosNamespace(config.second_push_ns)
111+
pns2 = PushROSNamespace(config.second_push_ns)
112112
pns2.execute(lc)
113113
node = Node(
114114
package='dont_care',
@@ -132,10 +132,10 @@ def test_push_ros_namespace(config):
132132
def test_push_ros_namespace_with_composable_node(config):
133133
lc = MockContext()
134134
if config.push_ns is not None:
135-
pns1 = PushRosNamespace(config.push_ns)
135+
pns1 = PushROSNamespace(config.push_ns)
136136
pns1.execute(lc)
137137
if config.second_push_ns is not None:
138-
pns2 = PushRosNamespace(config.second_push_ns)
138+
pns2 = PushROSNamespace(config.second_push_ns)
139139
pns2.execute(lc)
140140
node_description = ComposableNode(
141141
package='asd',

test_launch_ros/test/test_launch_ros/actions/test_ros_timer.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# limitations under the License.
1414

1515

16-
"""Tests for the RosTimer Action."""
16+
"""Tests for the ROSTimer Action."""
1717
from functools import partial
1818
import threading
1919
import time
@@ -23,7 +23,7 @@
2323
from launch.actions import DeclareLaunchArgument
2424
import launch.event_handlers
2525
from launch.substitutions import LaunchConfiguration
26-
from launch_ros.actions import RosTimer
26+
from launch_ros.actions import ROSTimer
2727
from launch_ros.actions import SetUseSimTime
2828
import pytest
2929
import rclpy
@@ -57,7 +57,7 @@ def test_multiple_launch_with_timers():
5757
def generate_launch_description():
5858
return launch.LaunchDescription([
5959

60-
RosTimer(
60+
ROSTimer(
6161
period=1.,
6262
actions=[]
6363
),
@@ -76,7 +76,7 @@ def test_timer_with_launch_configuration():
7676
def generate_launch_description():
7777
return launch.LaunchDescription([
7878
DeclareLaunchArgument('my_period', default_value='0.1'),
79-
RosTimer(
79+
ROSTimer(
8080
period=LaunchConfiguration('my_period'),
8181
actions=[]
8282
),
@@ -98,7 +98,7 @@ def test_timer_action_sanity_check():
9898

9999
launch.actions.OpaqueFunction(function=set_start_time),
100100

101-
RosTimer(
101+
ROSTimer(
102102
period=1.,
103103
actions=[
104104
launch.actions.OpaqueFunction(function=set_end_time),
@@ -125,14 +125,14 @@ def test_shutdown_preempts_timers():
125125

126126
ld = launch.LaunchDescription([
127127

128-
RosTimer(
128+
ROSTimer(
129129
period=1.,
130130
actions=[
131131
launch.actions.Shutdown(reason='fast shutdown')
132132
]
133133
),
134134

135-
RosTimer(
135+
ROSTimer(
136136
period=2.,
137137
actions=[
138138
launch.actions.Shutdown(reason='slow shutdown')
@@ -179,7 +179,7 @@ def timer_callback(publisher, time_msg):
179179

180180
launch.actions.OpaqueFunction(function=set_start_time),
181181

182-
RosTimer(
182+
ROSTimer(
183183
period=200.,
184184
actions=[
185185
launch.actions.OpaqueFunction(function=set_end_time)

0 commit comments

Comments
 (0)