ros-parser 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. ros_parser-0.1.0/PKG-INFO +101 -0
  2. ros_parser-0.1.0/README.md +75 -0
  3. ros_parser-0.1.0/pyproject.toml +58 -0
  4. ros_parser-0.1.0/src/ros_parser/__init__.py +44 -0
  5. ros_parser-0.1.0/src/ros_parser/_lark_standalone_runtime.py +3547 -0
  6. ros_parser-0.1.0/src/ros_parser/_utils.py +149 -0
  7. ros_parser-0.1.0/src/ros_parser/message_path/README.md +264 -0
  8. ros_parser-0.1.0/src/ros_parser/message_path/__init__.py +31 -0
  9. ros_parser-0.1.0/src/ros_parser/message_path/_standalone_parser.py +18 -0
  10. ros_parser-0.1.0/src/ros_parser/message_path/_standalone_parser.pyi +19 -0
  11. ros_parser-0.1.0/src/ros_parser/message_path/grammar.lark +81 -0
  12. ros_parser-0.1.0/src/ros_parser/message_path/models.py +676 -0
  13. ros_parser-0.1.0/src/ros_parser/message_path/parser.py +162 -0
  14. ros_parser-0.1.0/src/ros_parser/models.py +209 -0
  15. ros_parser-0.1.0/src/ros_parser/py.typed +0 -0
  16. ros_parser-0.1.0/src/ros_parser/ros1_msg/__init__.py +23 -0
  17. ros_parser-0.1.0/src/ros_parser/ros1_msg/_standalone_parser.py +18 -0
  18. ros_parser-0.1.0/src/ros_parser/ros1_msg/_standalone_parser.pyi +5 -0
  19. ros_parser-0.1.0/src/ros_parser/ros1_msg/grammar.lark +116 -0
  20. ros_parser-0.1.0/src/ros_parser/ros1_msg/parser.py +372 -0
  21. ros_parser-0.1.0/src/ros_parser/ros1_msg/schema_parser.py +100 -0
  22. ros_parser-0.1.0/src/ros_parser/ros2_msg/__init__.py +23 -0
  23. ros_parser-0.1.0/src/ros_parser/ros2_msg/_standalone_parser.py +18 -0
  24. ros_parser-0.1.0/src/ros_parser/ros2_msg/_standalone_parser.pyi +17 -0
  25. ros_parser-0.1.0/src/ros_parser/ros2_msg/grammar.lark +134 -0
  26. ros_parser-0.1.0/src/ros_parser/ros2_msg/parser.py +505 -0
  27. ros_parser-0.1.0/src/ros_parser/ros2_msg/schema_parser.py +91 -0
@@ -0,0 +1,101 @@
1
+ Metadata-Version: 2.3
2
+ Name: ros-parser
3
+ Version: 0.1.0
4
+ Summary: Python parser for ROS message definitions and Foxglove message path syntax
5
+ Keywords: ros,ros1,ros2,parser,message,robotics
6
+ Author: Marko Bausch
7
+ License: GPL-3.0
8
+ Classifier: Development Status :: 4 - Beta
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Intended Audience :: Science/Research
11
+ Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Topic :: Scientific/Engineering
19
+ Classifier: Topic :: Software Development :: Compilers
20
+ Classifier: Typing :: Typed
21
+ Requires-Python: >=3.10
22
+ Project-URL: Homepage, https://github.com/mrkbac/robotic-tools
23
+ Project-URL: Issues, https://github.com/mrkbac/robotic-tools/issues
24
+ Project-URL: Repository, https://github.com/mrkbac/robotic-tools
25
+ Description-Content-Type: text/markdown
26
+
27
+ # ROS Parser
28
+
29
+ A Python parser for ROS message definitions and Foxglove message path syntax.
30
+
31
+ ## Installation
32
+
33
+ ```bash
34
+ uv add ros-parser
35
+ ```
36
+
37
+ ## Parsers
38
+
39
+ - **ros1_msg**: Parses ROS1 message definition files (.msg)
40
+ - **ros2_msg**: Parses ROS2 message definition files (.msg)
41
+ - **message_path**: Parses Foxglove message path syntax for data access and filtering
42
+
43
+ ## Usage
44
+
45
+ ### Parsing ROS2 Messages
46
+
47
+ ```python
48
+ from ros_parser import ros2_msg
49
+
50
+ definition = ros2_msg.parse_message_string("""
51
+ float64 x
52
+ float64 y
53
+ float64 z
54
+ """)
55
+
56
+ for field in definition.fields:
57
+ print(f"{field.name}: {field.type}")
58
+ ```
59
+
60
+ ### Parsing ROS1 Messages
61
+
62
+ ```python
63
+ from ros_parser import ros1_msg
64
+
65
+ definition = ros1_msg.parse_message_string("""
66
+ Header header
67
+ float64 x
68
+ float64 y
69
+ float64 z
70
+ """)
71
+
72
+ for field in definition.fields:
73
+ print(f"{field.name}: {field.type}")
74
+ ```
75
+
76
+ ### Parsing Schema with Dependencies
77
+
78
+ ```python
79
+ from ros_parser import parse_schema_to_definitions
80
+
81
+ # Parse a full schema including embedded type definitions
82
+ definitions = parse_schema_to_definitions(
83
+ "geometry_msgs/msg/Pose",
84
+ schema_data
85
+ )
86
+ ```
87
+
88
+ ## Regenerating Standalone Parsers
89
+
90
+ The project uses Lark to generate standalone parsers from grammar files. If you modify any `.lark` grammar file, regenerate the parsers:
91
+
92
+ ```bash
93
+ uv run _generate_standalone.py \
94
+ src/ros_parser/ros1_msg/grammar.lark \
95
+ src/ros_parser/ros2_msg/grammar.lark \
96
+ src/ros_parser/message_path/grammar.lark \
97
+ --output-dir src/ros_parser \
98
+ --lexer contextual
99
+ ```
100
+
101
+ For more details on the message path syntax, see [src/ros_parser/message_path/README.md](src/ros_parser/message_path/README.md).
@@ -0,0 +1,75 @@
1
+ # ROS Parser
2
+
3
+ A Python parser for ROS message definitions and Foxglove message path syntax.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ uv add ros-parser
9
+ ```
10
+
11
+ ## Parsers
12
+
13
+ - **ros1_msg**: Parses ROS1 message definition files (.msg)
14
+ - **ros2_msg**: Parses ROS2 message definition files (.msg)
15
+ - **message_path**: Parses Foxglove message path syntax for data access and filtering
16
+
17
+ ## Usage
18
+
19
+ ### Parsing ROS2 Messages
20
+
21
+ ```python
22
+ from ros_parser import ros2_msg
23
+
24
+ definition = ros2_msg.parse_message_string("""
25
+ float64 x
26
+ float64 y
27
+ float64 z
28
+ """)
29
+
30
+ for field in definition.fields:
31
+ print(f"{field.name}: {field.type}")
32
+ ```
33
+
34
+ ### Parsing ROS1 Messages
35
+
36
+ ```python
37
+ from ros_parser import ros1_msg
38
+
39
+ definition = ros1_msg.parse_message_string("""
40
+ Header header
41
+ float64 x
42
+ float64 y
43
+ float64 z
44
+ """)
45
+
46
+ for field in definition.fields:
47
+ print(f"{field.name}: {field.type}")
48
+ ```
49
+
50
+ ### Parsing Schema with Dependencies
51
+
52
+ ```python
53
+ from ros_parser import parse_schema_to_definitions
54
+
55
+ # Parse a full schema including embedded type definitions
56
+ definitions = parse_schema_to_definitions(
57
+ "geometry_msgs/msg/Pose",
58
+ schema_data
59
+ )
60
+ ```
61
+
62
+ ## Regenerating Standalone Parsers
63
+
64
+ The project uses Lark to generate standalone parsers from grammar files. If you modify any `.lark` grammar file, regenerate the parsers:
65
+
66
+ ```bash
67
+ uv run _generate_standalone.py \
68
+ src/ros_parser/ros1_msg/grammar.lark \
69
+ src/ros_parser/ros2_msg/grammar.lark \
70
+ src/ros_parser/message_path/grammar.lark \
71
+ --output-dir src/ros_parser \
72
+ --lexer contextual
73
+ ```
74
+
75
+ For more details on the message path syntax, see [src/ros_parser/message_path/README.md](src/ros_parser/message_path/README.md).
@@ -0,0 +1,58 @@
1
+ [project]
2
+ name = "ros-parser"
3
+ version = "0.1.0"
4
+ description = "Python parser for ROS message definitions and Foxglove message path syntax"
5
+ readme = "README.md"
6
+ requires-python = ">=3.10"
7
+ license = {text = "GPL-3.0"}
8
+ authors = [
9
+ {name = "Marko Bausch"}
10
+ ]
11
+ keywords = ["ros", "ros1", "ros2", "parser", "message", "robotics"]
12
+ classifiers = [
13
+ "Development Status :: 4 - Beta",
14
+ "Intended Audience :: Developers",
15
+ "Intended Audience :: Science/Research",
16
+ "License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
17
+ "Operating System :: OS Independent",
18
+ "Programming Language :: Python :: 3",
19
+ "Programming Language :: Python :: 3.10",
20
+ "Programming Language :: Python :: 3.11",
21
+ "Programming Language :: Python :: 3.12",
22
+ "Programming Language :: Python :: 3.13",
23
+ "Topic :: Scientific/Engineering",
24
+ "Topic :: Software Development :: Compilers",
25
+ "Typing :: Typed",
26
+ ]
27
+ dependencies = []
28
+
29
+ [project.urls]
30
+ Homepage = "https://github.com/mrkbac/robotic-tools"
31
+ Repository = "https://github.com/mrkbac/robotic-tools"
32
+ Issues = "https://github.com/mrkbac/robotic-tools/issues"
33
+
34
+ [build-system]
35
+ requires = ["uv_build>=0.8.9,<0.9.0"]
36
+ build-backend = "uv_build"
37
+
38
+ [dependency-groups]
39
+ dev = [
40
+ "lark>=1.3.0",
41
+ ]
42
+
43
+ [tool.mypy]
44
+ strict = true
45
+ python_version = "3.10"
46
+ exclude = [
47
+ "^.*/_standalone.*\\.py$",
48
+ "^.*/_lark_standalone.*\\.py$",
49
+ ]
50
+
51
+ [tool.ruff]
52
+ extend = "../pyproject.toml"
53
+ extend-exclude = [
54
+ '**/_standalone*.py',
55
+ '**/_lark_standalone*.py',
56
+ 'tests/reference_parser.py',
57
+ '_generate_standalone.py',
58
+ ]
@@ -0,0 +1,44 @@
1
+ """ROS message, service, and action definition parser.
2
+
3
+ Supports both ROS1 and ROS2 message formats.
4
+
5
+ For ROS2, use:
6
+ from ros_parser.ros2_msg import parse_message_string
7
+ from ros_parser import ros2_msg
8
+
9
+ For ROS1, use:
10
+ from ros_parser.ros1_msg import parse_message_string
11
+ from ros_parser import ros1_msg
12
+
13
+ For shared models:
14
+ from ros_parser.models import MessageDefinition, Field, Type, Constant
15
+ """
16
+
17
+ from . import ros1_msg, ros2_msg
18
+ from .message_path import ValidationError
19
+ from .models import (
20
+ PRIMITIVE_TYPE_NAMES,
21
+ ActionDefinition,
22
+ Constant,
23
+ Field,
24
+ MessageDefinition,
25
+ PrimitiveType,
26
+ ServiceDefinition,
27
+ Type,
28
+ )
29
+ from .ros2_msg.schema_parser import parse_schema_to_definitions
30
+
31
+ __all__ = [
32
+ "PRIMITIVE_TYPE_NAMES",
33
+ "ActionDefinition",
34
+ "Constant",
35
+ "Field",
36
+ "MessageDefinition",
37
+ "PrimitiveType",
38
+ "ServiceDefinition",
39
+ "Type",
40
+ "ValidationError",
41
+ "parse_schema_to_definitions",
42
+ "ros1_msg",
43
+ "ros2_msg",
44
+ ]