6. Other noteworthy APIs

class trainlib.messages.SnapCommand(iterable=(), /)

Snap command is a tuple of 4 colors (SnapColorValue).

It always starts with white or cyan. If the snap sequence is shorter, it is padded with black. Since white and cyan always start a new snap command, these colors will never appear on other position.

__eq__(o: object) bool

Compare (exact match) the snap command to a tuple of colors.

Since snap commands are always 4 colors, this allows to exact match with shorter tuples.

Example

Note: SnapColorValue is imported as C in this example.

>>> msg.colors == (C.WHITE, C.RED, C.BLACK, C.BLACK)
>>> # exact match with implicit blacks
>>> msg.colors == (C.WHITE, C.RED)
start_with(colors: Union[Tuple[intelino.trainlib_async.enums.enums.SnapColorValue, ...], intelino.trainlib_async.enums.enums.SnapColorValue], *args: intelino.trainlib_async.enums.enums.SnapColorValue)

Partial / prefix match.

This function is aliased as start_with() and starts_with() to be used depending on the context.

Example

Note: SnapColorValue is imported as C in this example.

>>> snap_command.starts_with(C.WHITE, C.RED)
>>> msg.colors.start_with(C.CYAN, C.BLUE)
Parameters

colors (SnapColorValue) – It accepts either tuples or multiple parameters of SnapColorValue.

starts_with(colors: Union[Tuple[intelino.trainlib_async.enums.enums.SnapColorValue, ...], intelino.trainlib_async.enums.enums.SnapColorValue], *args: intelino.trainlib_async.enums.enums.SnapColorValue)

Partial / prefix match.

This function is aliased as start_with() and starts_with() to be used depending on the context.

Example

Note: SnapColorValue is imported as C in this example.

>>> snap_command.starts_with(C.WHITE, C.RED)
>>> msg.colors.start_with(C.CYAN, C.BLUE)
Parameters

colors (SnapColorValue) – It accepts either tuples or multiple parameters of SnapColorValue.