Skip to content

Commit 9070b0b

Browse files
authored
Fix poetenial issues in parser.py (#1404)
This PR tightens up the `rosidl_parser/parser.py` CLI wrapper used by the Node-side `rosidl_parser.js` helper by removing unused code and correcting the expected CLI argument count. **Changes:** - Remove an unused `rosidl_parser` import. - Remove an unused intermediate `msg_name` variable. - Update the CLI argument count check to require 3 parameters after the script name (command, package, file path). Fix: #1403
1 parent 1b3fdb9 commit 9070b0b

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

rosidl_parser/parser.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import sys
1616
import json
1717

18-
import rosidl_parser
1918
from rosidl_adapter import parser
2019

2120
def get_json_object_from_base_type_object(base_type_obj):
@@ -41,15 +40,14 @@ def get_json_object_from_msg_spec_object(msg_spec_object):
4140
for constant in msg_spec_object.constants:
4241
constants.append({'type': constant.type, 'name': constant.name, 'value': constant.value})
4342

44-
msg_name = {'msgName': msg_spec_object.msg_name}
4543
json_obj = {'constants': constants, 'fields': fields, 'baseType': get_json_object_from_base_type_object(msg_spec_object.base_type),
4644
'msgName': msg_spec_object.msg_name}
4745

4846
return json_obj
4947

5048
if __name__ == '__main__':
51-
if len(sys.argv) < 3:
52-
print('Wrong number of argments')
49+
if len(sys.argv) < 4:
50+
print('Usage: {} <command> <packageName> <filePath>'.format(sys.argv[0]), file=sys.stderr)
5351
sys.exit(1)
5452
try:
5553
parser_method = getattr(parser, sys.argv[1])

0 commit comments

Comments
 (0)