proto2ros.configuration package
Module contents
This module defines configuration data structures for proto2ros generation.
- class proto2ros.configuration.Configuration(drop_deprecated: bool = False, passthrough_unknown: bool = True, package_mapping: ~typing.Dict[str, str] = <factory>, message_mapping: ~typing.Dict[str, str] = <factory>, any_expansions: ~typing.Dict[str, ~typing.Set[str] | str] = <factory>, allow_any_casts: bool = True, package_specifications: ~typing.Set[str] = <factory>, cpp_headers: ~typing.Set[str] = <factory>, inline_cpp_namespaces: ~typing.Set[str] = <factory>, python_imports: ~typing.Set[str] = <factory>, inline_python_imports: ~typing.Set[str] = <factory>, skip_implicit_imports: bool = False)
Bases:
object
Mutable Protobuf <-> ROS configuration.
Attributes:
- drop_deprecated: whether to drop deprecated fields on conversion or not.
If not dropped, deprecated fields are annotated with a comment.
- passthrough_unknown: whether to forward Protobuf messages for which no
equivalent ROS message is known as a type erased,
proto2ros/AnyProto
field or not.- message_mapping: a mapping from fully qualified Protobuf message type names
to fully qualified ROS message type names. This mapping comes first during composite type translation.
- package_mapping: a mapping from Protobuf package names to ROS package names,
to tell where a ROS equivalent for a Protobuf construct will be found. Note that no checks for package existence are performed. This mapping comes second during composite type translation (i.e. when direct message mapping fails).
- any_expansions: a mapping from fully qualified Protobuf field names (i.e. a
fully qualified Protobuf message type name followed by a dot “.” followed by the field name) of
google.protobuf.Any
type to Protobuf message type sets that these fields are expected to pack. A single Protobuf message type may also be specified in lieu of a single element set. All Protobuf message types must be fully qualified.- allow_any_casts: when a single Protobuf message type is specified in an any expansion,
allowing any casts means to allow using the equivalent ROS message type instead of a a type erased,
proto2ros/Any
field.- package_specifications: set of Python modules to gather message specifications from.
Necessary to cascade message generation for interdependent packages.
- cpp_headers: set of C++ headers to be included (as
#include <{header}>
) in generated C++ conversion headers. Typically, Protobuf and ROS message C++ headers.
- inline_cpp_namespaces: set of C++ namespaces bearing conversion overloads, for which
unqualified lookup (
using {namespace}::Convert;
) is necessary in generated C++ conversion sources.- python_imports: set of Python modules to be imported (as
import <module-name>
) in generated Python conversion modules. Typically, Protobuf and ROS message Python modules.
- inline_python_imports: set of Python modules to be imported into moodule scope
(as
from <module-name> import *
) in generated conversion modules. Typically, conversion Python modules.- skip_implicit_imports: whether to skip importing Python modules for Protobuf and ROS
packages known in generated conversion modules or not.
- allow_any_casts: bool = True
- any_expansions: Dict[str, Set[str] | str]
- cpp_headers: Set[str]
- drop_deprecated: bool = False
- classmethod from_file(path: PathLike) Configuration
Reads configuration from a file.
- inline_cpp_namespaces: Set[str]
- inline_python_imports: Set[str]
- message_mapping: Dict[str, str]
- package_mapping: Dict[str, str]
- package_specifications: Set[str]
- passthrough_unknown: bool = True
- python_imports: Set[str]
- skip_implicit_imports: bool = False
- update(**attributes: Any) None
Updates configuration attributes with a shallow merge.
- classmethod updates_from_file(path: PathLike) Dict[str, Any]
Reads configuration attribute updates from a file.