Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions ros2interface/ros2interface/verb/show.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
import argparse
import sys
import typing
import os

from ament_index_python.resources import get_resource
from ament_index_python.packages import get_package_share_directory

from ros2interface.api import type_completer
from ros2interface.verb import VerbExtension
Expand All @@ -25,7 +29,6 @@
MessageSpecification, \
parse_message_string, \
SERVICE_REQUEST_RESPONSE_SEPARATOR
from rosidl_runtime_py import get_interface_path


class InterfaceTextLine:
Expand Down Expand Up @@ -108,9 +111,16 @@ def _get_interface_lines(interface_identifier: str) -> typing.Iterable[Interface
raise ValueError(
f"Invalid name '{interface_identifier}'. Expected three parts separated by '/'"
)
pkg_name, _, msg_name = parts
pkg_name, msg_type, msg_name = parts

interfaces, _ = get_resource("rosidl_interfaces", pkg_name)
interfaces = interfaces.splitlines();

interface = [f for f in interfaces if f.endswith(msg_name + "." + msg_type)]
if len(interface) == 0:
interface = [f"{msg_type}/{msg_name}"]

file_path = get_interface_path(interface_identifier)
file_path = os.path.join(get_package_share_directory(pkg_name), interface[0]);
with open(file_path) as file_handler:
for line in file_handler:
yield InterfaceTextLine(
Expand Down