module documentation

OpenSMI object paths and the rules for building them from OPC UA browse names.

Shared by everything that builds OpenSMI paths (server, client browsing, NodeSet loader, code generation), so the same address space always yields the same paths.

Class ObjectPath Path of an OpenSMI object, e.g. /M1/Components/Gripper/SkillSet/Pick.
Function check_name Check name against the OpenSMI naming rule for browse names.
Function check_segment Check that segment can be a path segment: a non-empty str without /.
Function node_id_order Sort key independent of the server's namespace indexes: namespace URI, OPC UA identifier type, identifier.
Function sanitize_segment Return the path segment for browse_name: / replaced by _, an empty name becomes _.
Function to_pascal_case Convert a snake_case name to PascalCase: split on _, capitalize each part, join.
Function unique_segments Return a sanitized, unique path segment for each sibling, given as (node id, browse name).
Function _split Undocumented
Constant _ANY_DEPTH Undocumented
Constant _GLOB_SPECIAL Undocumented
Constant _LOGGER Undocumented
Constant _NAME_PATTERN Undocumented
Constant _REPLACEMENT Undocumented
Constant _RESERVED_NAMES Undocumented
Constant _SEPARATOR Undocumented
def check_name(name: str):

Check name against the OpenSMI naming rule for browse names.

Browse names of machines, components, resources, skills, checks, methods and variables match ^[A-Z][A-Za-z0-9]*$ and aren't True, False or None, so they are valid identifiers in common languages. Not enforced yet: opensmi-server warns and rejects from 1.0 on.

Two kinds of names are exempt and only need to pass check_segment(): usernames, and instances named from runtime data rather than the model (e.g. one object per diagnostic id or TF frame), which code generation never sees. DataType browse names are outside the rule. Foreign names such as ROS2's snake_case convert with to_pascal_case().

Raises
ValueErrorIf name breaks the rule.
def check_segment(segment: str):

Check that segment can be a path segment: a non-empty str without /.

The hard rule for every name (browse names and usernames); the stricter naming rule is check_name().

Raises
TypeErrorIf segment is no str.
ValueErrorIf segment is empty or contains /.
def node_id_order(node_id: NodeIdDefinition) -> tuple[str, int, int, str]:

Sort key independent of the server's namespace indexes: namespace URI, OPC UA identifier type, identifier.

def sanitize_segment(browse_name: str) -> str:

Return the path segment for browse_name: / replaced by _, an empty name becomes _.

def to_pascal_case(name: str) -> str:

Convert a snake_case name to PascalCase: split on _, capitalize each part, join.

Only the first letter of a part changes, the rest stays as is: child_frame_id → ChildFrameId, max_vel_x → MaxVelX, pose2d → Pose2d. Empty parts (__, leading or trailing _) vanish. The result is not checked, so pass it to check_name(): none becomes the reserved None, 2d_pose becomes 2dPose, and two names may convert to the same one (x_1 and x1).

def unique_segments(siblings: Iterable[tuple[NodeIdDefinition, str]]) -> dict[NodeIdDefinition, str]:

Return a sanitized, unique path segment for each sibling, given as (node id, browse name).

Siblings are processed in NodeId order (namespace URI, then identifier), so the result doesn't depend on browse order or namespace indexes. A segment already used gets the first free suffix _2, _3, ...; a suffixed segment never takes the unchanged segment of another sibling. Sanitized and suffixed segments are logged as warnings.

def _split(text: str) -> tuple[str, ...]:

Undocumented

_ANY_DEPTH: str =

Undocumented

Value
'**'
_GLOB_SPECIAL: re.Pattern[str] =

Undocumented

Value
re.compile(r'([\*\?\[])')
_LOGGER =

Undocumented

Value
structlog.get_logger(('opensmi.' + __name__))
_NAME_PATTERN: re.Pattern[str] =

Undocumented

Value
re.compile(r'[A-Z][A-Za-z0-9]*')
_REPLACEMENT: str =

Undocumented

Value
'_'
_RESERVED_NAMES: frozenset[str] =

Undocumented

Value
frozenset(set(['True', 'False', 'None']))
_SEPARATOR: str =

Undocumented

Value
'/'