def fromChunk(data):
 (prefix, rest) = data.split('\r\n', 1)
 length = int(prefix, 16)
 if (length < 0):
  raise ValueError(('Chunk length must be >= 0, not %d' % (length,)))
 if (rest[length:(length + 2)] != '\r\n'):
  raise ValueError('chunk must end with CRLF')
 return (rest[:length], rest[(length + 2):])

def fromChunk ( data ) : ( prefix , rest ) = data . split ( '\r\n' , 1 ) length = int ( prefix , 16 ) if ( length < 0 ) : raise ValueError ( ( 'Chunk length must be >= 0, not %d' % ( length , ) ) ) if ( rest [ length : ( length + 2 ) ] != '\r\n' ) : raise ValueError ( 'chunk must end with CRLF' ) return ( rest [ : length ] , rest [ ( length + 2 ) : ] )
convert chunk to string .