proto2ros.utilities module

This module provides various utilities used across the proto2ros package.

proto2ros.utilities.fqn(obj: Any) str | None

Computes the fully qualified name of a given object, if any.

proto2ros.utilities.identity_lru_cache(maxsize: int = 128) Callable[[Callable], Callable]

A functools.lru_cache equivalent that uses objects’ id() for result caching.

proto2ros.utilities.pairwise(iterable: Iterable[Any]) Iterable[Tuple[Any, Any]]

Yields an iterable over consecutive pairs.

proto2ros.utilities.rreplace(s: str, old: str, new: str, count: int) str

Replaces a number of string occurrences in reverse.

proto2ros.utilities.to_protobuf_field_name(name: str) str

Transform a given name to be a valid Protobuf message field name.

proto2ros.utilities.to_ros_base_type(type_: str | rosidl_adapter.parser.BaseType) str

Returns base type name for a given ROS type.

proto2ros.utilities.to_ros_field_name(name: str) str

Transform a given name to be a valid ROS message field name.