def encode(self):
        #Ident
        output = pack('ubyte', self.ident)
        
        #Extension
        if self.ident in packet_extensions.extensions:
            append = packet_extensions.extensions[self.ident].encode_extra(self)
        else:
            append = ''
        
        #Payload
        for data_type, name in structs[self.ident][self.direction]:
            output += pack(data_type, self.data[name])
        
        return output + append
dataset/ETHPy150Open barneygale/barneymc/barneymc/protocol/packet.py/Packet.encode/original