# Path: kiel/protocol/primitives.py
# class Primitive(object):
#     """
# The most basic structure of the protocol.  Subclassed, never used directly.
# 
# Used as a building block for the various actually-used primitives outlined
# in the Kafka wire protcol docs:
# 
# https://cwiki.apache.org/confluence/display/KAFKA/A+Guide+To+The+Kafka+Protocol
#     """
#     fmt = None
# 
#     def __init__(self, value):
#         self.value = value
# 
#     def render(self):
#         """
#         Returns a two-element tuple with the ``struct`` format and list value.
# 
#         The value is wrapped in a list, as there are some primitives that deal
#         with multiple values.  Any caller of `render()` should expect a list.
#         """
#         return self.fmt, [self.value]
# 
#     @classmethod
#     def parse(cls, buff, offset):
#         """
#         Given a buffer and offset, returns the parsed value and new offset.
# 
#         Uses the ``fmt`` class attribute to unpack the data from the buffer
#         and determine the used up number of bytes.
#         """
#         primitive_struct = struct.Struct("!" + cls.fmt)
# 
#         value = primitive_struct.unpack_from(buff, offset)[0]
#         offset += primitive_struct.size
# 
#         return value, offset
# 
#     def __eq__(self, other):
#         """
#         Basic equality method that tests equality of the ``value`` attributes.
#         """
#         return self.value == other.value
# 
#     def __repr__(self):
#         return "%s(%s)" % (self.__class__.__name__, self.value)


from .primitives import Primitive
    `Primitive` subclass.
    """
    parts = ()

    def __init__(self, **kwargs):
        part_names = [item[0] for item in self.parts]

        for name, value in kwargs.items():
            if name not in part_names:
                raise ValueError("Unknown part name: '%s'" % name)

            setattr(self, name, value)

    def render(self, parts=None):
        """
        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.
        """
        if not parts:
            parts = self.parts

        fmt = []
        data = []

        for name, part_class in parts:

# Path: kiel/protocol/primitives.py
# class Primitive(object):
#     """
# The most basic structure of the protocol.  Subclassed, never used directly.
# 
# Used as a building block for the various actually-used primitives outlined
# in the Kafka wire protcol docs:
# 
# https://cwiki.apache.org/confluence/display/KAFKA/A+Guide+To+The+Kafka+Protocol
#     """
#     fmt = None
# 
#     def __init__(self, value):
#         self.value = value
# 
#     def render(self):
#         """
#         Returns a two-element tuple with the ``struct`` format and list value.
# 
#         The value is wrapped in a list, as there are some primitives that deal
#         with multiple values.  Any caller of `render()` should expect a list.
#         """
#         return self.fmt, [self.value]
# 
#     @classmethod
#     def parse(cls, buff, offset):
#         """
#         Given a buffer and offset, returns the parsed value and new offset.
# 
#         Uses the ``fmt`` class attribute to unpack the data from the buffer
#         and determine the used up number of bytes.
#         """
#         primitive_struct = struct.Struct("!" + cls.fmt)
# 
#         value = primitive_struct.unpack_from(buff, offset)[0]
#         offset += primitive_struct.size
# 
#         return value, offset
# 
#     def __eq__(self, other):
#         """
#         Basic equality method that tests equality of the ``value`` attributes.
#         """
#         return self.value == other.value
# 
#     def __repr__(self):
#         return "%s(%s)" % (self.__class__.__name__, self.value)


# Path: kiel/protocol/part.py
from .primitives import Primitive

    `Primitive` subclass.
    """
    parts = ()

    def __init__(self, **kwargs):
        part_names = [item[0] for item in self.parts]

        for name, value in kwargs.items():
            if name not in part_names:
                raise ValueError("Unknown part name: '%s'" % name)

            setattr(self, name, value)

    def render(self, parts=None):
        """
        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.
        """
        if not parts:
            parts = self.parts

        fmt = []
        data = []

        for name, part_class in parts:

            if issubclass(part_class, Primitive):