pyrtma.manager.Message

class Message(header, data)[source]

Bases: object

Message class

Contains message header and data

Methods

copy

Generate a copy of a message structure

from_json

Create message object from JSON string

pretty_print

Generate formatted string for pretty printing of message

to_dict

Convert message to dictionary

to_json

Convert message to JSON string

Attributes

name

type_id

Parameters:
classmethod copy(m)[source]

Generate a copy of a message structure

Parameters:

m (Message) – Message structure to copy

Return type:

Message

classmethod from_json(s)[source]

Create message object from JSON string

Parameters:

s (str) – JSON message string

Raises:

InvalidMessageDefinition – JSON data does not match expected message defintion

Returns:

Message object

Return type:

Message

pretty_print(add_tabs=0)[source]

Generate formatted string for pretty printing of message

Parameters:

add_tabs (int, optional) – Indent level. Defaults to 0.

Returns:

Formatted string

Return type:

str

to_dict()[source]

Convert message to dictionary

Returns:

Message dictionary

Return type:

Dict[str, Any]

to_json(minify=False, **kwargs)[source]

Convert message to JSON string

Parameters:

minify (bool, optional) – Flag to minify (compact format). Defaults to False.

Returns:

JSON message string

Return type:

str