def single_varint(data, index=0):
    """
    The single_varint function processes a Varint and returns the
    length of that Varint.
    :param data: The data containing the Varint (maximum of 9
    bytes in length as that is the maximum size of a Varint).
    :param index: The current index within the data.
    :return: varint, the processed varint value,
    and index which is used to identify how long the Varint was.
    """

    # If the decimal value is => 128 -- then first bit is set and
    # need to process next byte.
    if ord(data[index:index+1]) >= 128:
        # Check if there is a three or more byte varint
        if ord(data[index + 1: index + 2]) >= 128:
            raise ValueError
        varint = (ord(data[index:index+1]) - 128) * 128 + ord(
        data[index + 1: index + 2])
        index += 2
        return varint, index

    # If the decimal value is < 128 -- then first bit is not set
    # and is the only byte of the Varint.
    else:
        varint = ord(data[index:index+1])
        index += 1
        return varint, index