-
Notifications
You must be signed in to change notification settings - Fork 164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
parse middle_module from message type in ros2topic #278
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,19 +57,20 @@ def __call__(self, prefix, parsed_args, **kwargs): | |
def import_message_type(topic_name, message_type): | ||
# TODO(dirk-thomas) this logic should come from a rosidl related package | ||
try: | ||
package_name, *message_name = message_type.split('/') | ||
if not package_name or not message_name or not all(message_name): | ||
package_name, middle_module, message_name = message_type.split('/') | ||
if not middle_module: | ||
middle_module = 'msg' | ||
if not package_name or not message_name: | ||
raise ValueError() | ||
except ValueError: | ||
raise RuntimeError('The passed message type is invalid') | ||
|
||
# TODO(sloretz) node API to get topic types should indicate if action or msg | ||
middle_module = 'msg' | ||
if topic_name.endswith('/_action/feedback'): | ||
middle_module = 'action' | ||
|
||
module = importlib.import_module(package_name + '.' + middle_module) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps we should just support any number of parts, e.g. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does it not generally make sense to unify this logic and have it in a central place? I know of at least one more other location where we duplicate the same logic: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. There's a TODO at the top of this function. I'm not sure what package it should belong in (or if a new package needs to be created). |
||
return getattr(module, message_name[-1]) | ||
return getattr(module, message_name) | ||
|
||
|
||
class TopicTypeCompleter: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic doesn't seem to make any sense. In which case would
not middle_module
beTrue
?