From b514fd538f7e29706c6204c7aaf413413dae16aa Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Thu, 16 Jun 2022 16:26:07 -0700 Subject: [PATCH] only make one get_parameter_value call in ros2 param dump Signed-off-by: Brian Chen --- ros2param/ros2param/verb/dump.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ros2param/ros2param/verb/dump.py b/ros2param/ros2param/verb/dump.py index fc4990610..8f0ccaac8 100644 --- a/ros2param/ros2param/verb/dump.py +++ b/ros2param/ros2param/verb/dump.py @@ -52,17 +52,17 @@ def add_arguments(self, parser, cli_name): # noqa: D102 help='DEPRECATED: Does nothing.') @staticmethod - def get_parameter_value(node, node_name, param): + def get_parameter_values(node, node_name, params): response = call_get_parameters( node=node, node_name=node_name, - parameter_names=[param]) + parameter_names=params) # requested parameter not set if not response.values: return '# Parameter not set' # extract type specific value - return get_value(parameter_value=response.values[0]) + return [get_value(parameter_value=i) for i in response.values] def insert_dict(self, dictionary, key, value): split = key.split(PARAMETER_SEPARATOR_STRING, 1) @@ -93,9 +93,10 @@ def main(self, *, args): # noqa: D102 # retrieve values response = call_list_parameters(node=node, node_name=absolute_node_name) + response = sorted(response) + parameter_values = self.get_parameter_values(node, absolute_node_name, response) - for param_name in sorted(response): - pval = self.get_parameter_value(node, absolute_node_name, param_name) + for param_name, pval in zip(response, parameter_values): self.insert_dict( yaml_output[node_name.full_name]['ros__parameters'], param_name, pval)