def parse(cls, buff, offset):
        """
        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.
        """
        values = {}

        for name, part in cls.parts:
            value, new_offset = part.parse(buff, offset)

            values[name] = value
            offset = new_offset

        return cls(**values), offset
def parse ( cls , buff , offset ) : values = { } for name , part in cls . parts : value , new_offset = part . parse ( buff , offset ) values [ name ] = value offset = new_offset return cls ( ** values ) , offset
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.