katcp_codec package
Module contents
- class katcp_codec.MessageType(*values)
Bases:
EnumType of katcp message.
- REQUEST = 1
- REPLY = 2
- INFORM = 3
- class katcp_codec.Message(mtype: MessageType, name: bytes, mid: int | None, arguments: List[bytes], validate: dataclasses.InitVar[bool] = True)
Bases:
objectA katcp message.
- Raises:
OverflowError – if the message ID is out of range
ValueError – if the name does not conform to the specification
- mtype: MessageType
Message type
- validate: dataclasses.InitVar[bool] = True
If false, skip validating the name and message ID. This should only be done if they’ve already been checked, as the behaviour is undefined if they’re invalid.
- class katcp_codec.Parser(max_line_length: int)
Bases:
objectMessage parser.
The parser accepts chunks of data from the wire (which need not be aligned to message boundaries) and returns whole messages as they are parsed.
- Parameters:
max_line_length – The maximum number of bytes in a message. Longer messages will not break the parser but will be reported as errors.
- append(data: Buffer) List[Message | ValueError]
Append new data to the parser.
- Returns:
Messages whose end was in the input data. Each message is either an instance of
Messageif it was valid orValueErrorif not.- Return type:
messages