Skip to content

Commit

Permalink
ROS Interface Glinters (MetroRobots#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
DLu authored Dec 8, 2023
1 parent 9de27c0 commit 8546559
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/ros_glint/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from .core import get_linters

__all__ = ['get_linters']
from .glinters import ros_interfaces

__all__ = ['get_linters', 'ros_interfaces']
32 changes: 32 additions & 0 deletions src/ros_glint/glinters/ros_interfaces.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from ..core import glinter
from ros_introspect.components.ros_interface import PRIMITIVES

STANDARD = {
'Header': 'std_msgs'
}


@glinter
def clean_whitespace_from_interface_definition(package):
# Formerly remove_trailing_whitespace_from_generators
for interface in package.get_ros_interfaces():
interface.changed = True


@glinter
def fill_in_msg_package_names(package):
interfaces = package.get_ros_interfaces()
all_names = {ros_i.name for ros_i in interfaces}

for interface in interfaces:
for section in interface.sections:
for field in section.fields:
if '/' in field.type or field.type in PRIMITIVES:
continue

if field.type in STANDARD:
field.type = STANDARD[field.type] + '/' + field.type
interface.changed = True
elif field.type in all_names:
field.type = package.name + '/' + field.type
interface.changed = True

0 comments on commit 8546559

Please sign in to comment.