zoonado.protocol.part

class zoonado.protocol.part.Part(**kwargs)[source]

Composable building block used to define Zookeeper protocol parts.

Behaves much like the Primitive class but has named “sub parts” stored in a parts class attribute, that can hold any Part or Primitive subclass.

render(parts=None)[source]

Returns a two-element tuple with the struct format and values.

Iterates over the applicable sub-parts and calls render() on them, accumulating the format string and values.

Optionally takes a subset of parts to render, default behavior is to render all sub-parts belonging to the class.

classmethod parse(buff, offset)[source]

Given a buffer and offset, returns the parsed value and new offset.

Calls parse() on the given buffer for each sub-part in order and creates a new instance with the results.