

def decode_value(encoded, offset):
    'Decode the value passed in returning the decoded value and the number\n    of bytes read in addition to the starting offset.\n\n    :param str encoded: The binary encoded data to decode\n    :param int offset: The starting byte offset\n    :rtype: tuple\n    :raises: pika.exceptions.InvalidFieldTypeException\n\n    '
    kind = encoded[offset:(offset + 1)]
    offset += 1
    if (kind == b't'):
        value = struct.unpack_from('>B', encoded, offset)[0]
        value = bool(value)
        offset += 1
    elif (kind == b'b'):
        value = struct.unpack_from('>B', encoded, offset)[0]
        offset += 1
    elif (kind == b'B'):
        value = struct.unpack_from('>b', encoded, offset)[0]
        offset += 1
    elif (kind == b'U'):
        value = struct.unpack_from('>h', encoded, offset)[0]
        offset += 2
    elif (kind == b'u'):
        value = struct.unpack_from('>H', encoded, offset)[0]
        offset += 2
    elif (kind == b'I'):
        value = struct.unpack_from('>i', encoded, offset)[0]
        offset += 4
    elif (kind == b'i'):
        value = struct.unpack_from('>I', encoded, offset)[0]
        offset += 4
    elif (kind == b'L'):
        value = long(struct.unpack_from('>q', encoded, offset)[0])
        offset += 8
    elif (kind == b'l'):
        value = long(struct.unpack_from('>Q', encoded, offset)[0])
        offset += 8
    elif (kind == b'f'):
        value = long(struct.unpack_from('>f', encoded, offset)[0])
        offset += 4
    elif (kind == b'd'):
        value = long(struct.unpack_from('>d', encoded, offset)[0])
        offset += 8
    elif (kind == b'D'):
        decimals = struct.unpack_from('B', encoded, offset)[0]
        offset += 1
        raw = struct.unpack_from('>i', encoded, offset)[0]
        offset += 4
        value = (decimal.Decimal(raw) * (decimal.Decimal(10) ** (- decimals)))
    elif (kind == b's'):
        (value, offset) = decode_short_string(encoded, offset)
    elif (kind == b'S'):
        length = struct.unpack_from('>I', encoded, offset)[0]
        offset += 4
        value = encoded[offset:(offset + length)].decode('utf8')
        offset += length
    elif (kind == b'A'):
        length = struct.unpack_from('>I', encoded, offset)[0]
        offset += 4
        offset_end = (offset + length)
        value = []
        while (offset < offset_end):
            (v, offset) = decode_value(encoded, offset)
            value.append(v)
    elif (kind == b'T'):
        value = datetime.utcfromtimestamp(struct.unpack_from('>Q', encoded, offset)[0])
        offset += 8
    elif (kind == b'F'):
        (value, offset) = decode_table(encoded, offset)
    elif (kind == b'V'):
        value = None
    else:
        raise exceptions.InvalidFieldTypeException(kind)
    return (value, offset)

dataset/ETHPy150Open pika/pika/pika/data.py decode_value/original