Skip to main content
Version: 1.2.2

GroupedMessage

ClassPrivateSource

gpm = GroupedMessage(
data: Sequence[str] | Warning | BaseException | None = None,
)

A group of messages.

Used for wrapping muliple str lines (info), a warning object, or an exception object.

This class would be used by mproc.LineProcMirror and host.LineHostMirror automatically. In most cases, users do not need to use this class directly.

Aliases​

This class can be acquired by

import syncstream


syncstream.GroupedMessage
syncstream.base.GroupedMessage

Arguments​

ArgumentTypeRequired
Description
dataSequence[str] | Warning | BaseExceptionThe grouped messages provider. The input value would be parsed as formatted lines. The parsed messages are compatible with serialization.

Methods​

serialize​

jdata: SerializedMessage = gpm.serialize()

Serialize this message item into a JSON compatible dict.

Returns​

ArgumentType
Description
jdataSerializedMessageThe serialized dictionary. This dictionary could be converted back to GroupedMessage object by the deserialize method.

deserialize​

gpm: GroupedMessage = GroupedMessage.deserialize(
jdata: SerializedMessage | GroupedMessage
)

Deserialize the JSON compatible dict into this object.

Requires​

ArgumentTypeRequired
Description
jdataSerializedMessage | GroupedMessageThe serialized dictionary. This dictionary is JSON compatible, and could be transmitted by the web packages. If it is not a serialized dictionary, return as it is.

Returns​

ArgumentType
Description
gpmGroupedMessageThe deserialized object. This object could be converted to formatted strings by str(gpm).

Example​

Catch the error traceback as gruped messages​

use_grouped_messages.py
from syncstream.base import GroupedMessage

try:
raise ImportError('A testing exception object.')
except ImportError as error:
gpm = GroupedMessage(error)

print(gpm)