cmu-rss-lab / roswire

A library for static and dynamic analysis of ROS applications via Docker 🔌
http://christimperley.co.uk/roswire
Apache License 2.0
8 stars 0 forks source link

Fix corner case handling for empty action files #486

Closed ChrisTimperley closed 2 years ago

ChrisTimperley commented 2 years ago

It turns out the action files can contain three entirely empty sections [https://github.com/ros-teleop/twist_mux_msgs/blob/melodic-devel/action/JoyPriority.action]:

---
---

This causes our current action file parser to fail.

  File "/home/chris/experiments/rosdiscover-evaluation/deps/roswire/src/roswire/common/action.py", line 72, in from_file
    return cls.from_string(package, name, contents)
           │   │           │        │     └ '---\n---\n'
           │   │           │        └ 'JoyPriority'
           │   │           └ 'twist_mux_msgs'
           │   └ <classmethod object at 0x7f1f3cad41c0>
           └ <class 'roswire.ros1.action.ROS1ActionFormat'>

  File "/home/chris/experiments/rosdiscover-evaluation/deps/roswire/src/roswire/ros1/action.py", line 36, in from_string
    sections = ROS1MsgFormat.sections_from_string(s)
               │             │                    └ '---\n---\n'
               │             └ <staticmethod object at 0x7f1f3d08c6a0>
               └ <class 'roswire.ros1.msg.ROS1MsgFormat'>

  File "/home/chris/experiments/rosdiscover-evaluation/deps/roswire/src/roswire/common/msg.py", line 323, in sections_from_string
    sections[section_index] += f"{line}\n"
    │        └ 2
    └ ['', '']