Skip to content

Commit

Permalink
Maintain order of parameters regarding name and from (ros2#99)
Browse files Browse the repository at this point in the history
Signed-off-by: Brian Ezequiel Marchi <brian.marchi65@gmail.com>
  • Loading branch information
BMarchi authored and hidmic committed Dec 5, 2019
1 parent 4662df0 commit b2e2a01
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
6 changes: 2 additions & 4 deletions launch_ros/launch_ros/actions/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ def normalize_scalar_value(value):
return param_dict

normalized_params = []
params_without_from = []
for param in params:
from_attr = param.get_attr('from', optional=True)
name = param.get_attr('name', optional=True)
Expand All @@ -221,11 +220,10 @@ def normalize_scalar_value(value):
normalized_params.append(parser.parse_substitution(from_attr))
continue
elif name is not None:
params_without_from.append(param)
normalized_params.append(
get_nested_dictionary_from_nested_key_value_pairs([param]))
continue
raise ValueError('param Entity should have name or from attribute')
normalized_params.append(
get_nested_dictionary_from_nested_key_value_pairs(params_without_from))
return normalized_params

@classmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,14 @@ def test_node_frontend(file):
ls.context,
ld.describe_sub_entities()[2]._Node__parameters
)
assert isinstance(evaluated_parameters[0], pathlib.Path)
assert isinstance(evaluated_parameters[0], dict)
assert isinstance(evaluated_parameters[1], dict)
assert isinstance(evaluated_parameters[2], pathlib.Path)

assert 'param1' in evaluated_parameters[0]
assert evaluated_parameters[0]['param1'] == 'ads'

param_dict = evaluated_parameters[1]
assert 'param1' in param_dict
assert param_dict['param1'] == 'ads'
assert 'param_group1.param_group2.param2' in param_dict
assert 'param_group1.param3' in param_dict
assert 'param_group1.param4' in param_dict
Expand Down

0 comments on commit b2e2a01

Please sign in to comment.