def _decode_data(packet, packet_buff, offset):
 if (len(packet_buff) < (offset + 2)):
  raise InvalidPacketException((u'DATA packet too small (<4): %s' % repr(packet_buff)))
 (block_number,) = struct.unpack_from('!H', packet_buff, offset)
 data = packet_buff[(offset + 2):]
 packet['block_number'] = block_number
 packet['data'] = data
 return packet

def _decode_data ( packet , packet_buff , offset ) : if ( len ( packet_buff ) < ( offset + 2 ) ) : raise InvalidPacketException ( ( u'DATA packet too small (<4): %s' % repr ( packet_buff ) ) ) ( block_number , ) = struct . unpack_from ( '!H' , packet_buff , offset ) data = packet_buff [ ( offset + 2 ) : ] packet [ 'block_number' ] = block_number packet [ 'data' ] = data return packet
decodes a data packet .