Cannot parse message definitions with floats written as `0.`
Your Environment
Thank you for taking the time to report an issue.
To more efficiently resolve this issue, we'd like to know some basic information about your system and setup.
-
Your operating system: Ubuntu 20.04
-
Version of python you are running (
python --version): Python 3.12.7 -
How did you install rosbags? Did you use pip to install from PyPI or a repository checkout or something else? Installed via pip in a clean virtual environment
-
Version of rosbags you have installed (
pip show rosbags | grep Version): 0.10.4
The Issue
Trying to parse a message with a float value written with a trailing decimal point, e.g. 0., causes the following error:
Traceback (most recent call last):
File "/home/rye/git/setup/.venv/lib/python3.12/site-packages/rosbags/typesys/base.py", line 55, in parse_message_definition
assert npos == len(text), f'Could not parse: {text!r}'
^^^^^^^^^^^^^^^^^
AssertionError: Could not parse: 'MSG: msg/my_float\nfloat my_float 0.'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/rye/git/setup/.venv/lib/python3.12/site-packages/rosbags/typesys/msg.py", line 371, in get_types_from_msg
return parse_message_definition(VisitorMSG(), f'MSG: {name}\n{text}')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/rye/git/setup/.venv/lib/python3.12/site-packages/rosbags/typesys/base.py", line 59, in parse_message_definition
raise TypesysError(msg) from err
rosbags.typesys.base.TypesysError: Could not parse: 'MSG: msg/my_float\nfloat my_float 0.'
Steps to Reproduce
from rosbags.typesys import get_types_from_msg
get_types_from_msg("float my_float 0.", "msg/my_float")