|
12 | 12 | # See the License for the specific language governing permissions and |
13 | 13 | # limitations under the License. |
14 | 14 |
|
15 | | -from ast import literal_eval |
| 15 | +import keyword |
16 | 16 | import os |
17 | 17 | import pathlib |
| 18 | +import sys |
| 19 | +from ast import literal_eval |
18 | 20 |
|
19 | 21 | from rosidl_cmake import convert_camel_case_to_lower_case_underscore |
20 | 22 | from rosidl_cmake import expand_template |
|
31 | 33 | from rosidl_parser.definition import IdlContent |
32 | 34 | from rosidl_parser.definition import IdlLocator |
33 | 35 | from rosidl_parser.definition import INTEGER_TYPES |
| 36 | +from rosidl_parser.definition import Message |
34 | 37 | from rosidl_parser.definition import NamespacedType |
35 | 38 | from rosidl_parser.parser import parse_idl_file |
36 | 39 |
|
@@ -73,6 +76,18 @@ def generate_py(generator_arguments_file, typesupport_impls): |
73 | 76 | idl_file = parse_idl_file(locator) |
74 | 77 | idl_content.elements += idl_file.content.elements |
75 | 78 |
|
| 79 | + # NOTE(sam): remove when a language specific name mangling is implemented |
| 80 | + for message in idl_content.get_elements_of_type(Message): |
| 81 | + for member in message.structure.members: |
| 82 | + msg_name = message.structure.namespaced_type.name |
| 83 | + if (keyword.iskeyword(member.name)): |
| 84 | + print(('Member name "{}" in the message "{}" is a ' |
| 85 | + 'reserved keyword in Python and is not supported ' |
| 86 | + 'at the moment. Please use a different name.') |
| 87 | + .format(member.name, msg_name), file=sys.stderr) |
| 88 | + |
| 89 | + # TODO(sam): add reseved keyword warnings for services and actions |
| 90 | + |
76 | 91 | for subfolder in modules.keys(): |
77 | 92 | with open(os.path.join(args['output_dir'], subfolder, '__init__.py'), 'w') as f: |
78 | 93 | for idl_stem in sorted(modules[subfolder]): |
|
0 commit comments