Skip to content

Commit

Permalink
Remove comments from yaml file before applying substitutions
Browse files Browse the repository at this point in the history
Signed-off-by: Ivan Santiago Paunovic <ivanpauno@ekumenlabs.com>
  • Loading branch information
ivanpauno committed Aug 26, 2022
1 parent 7b0aa89 commit 95d4699
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion launch_ros/launch_ros/parameter_descriptions.py
Expand Up @@ -240,7 +240,13 @@ def evaluate(self, context: LaunchContext) -> Path:
with open(param_file_path, 'r') as f, NamedTemporaryFile(
mode='w', prefix='launch_params_', delete=False
) as h:
parsed = perform_substitutions(context, parse_substitution(f.read()))
try:
file_without_comments = yaml.safe_dump(yaml.safe_load(f.read()))
except Exception:
raise SubstitutionFailure(
'The parameter file is not a valid yaml file, '
'before applying substitutions')
parsed = perform_substitutions(context, parse_substitution(file_without_comments))
try:
yaml.safe_load(parsed)
except Exception:
Expand Down

0 comments on commit 95d4699

Please sign in to comment.