def readVar(value):
    """
    Converts varlength format to integer. Just pass it 0 or more chars that
    might be a varlen and it will only use the relevant chars.
    use varLen(readVar(value)) to see how many bytes the integer value takes.
    asserts len(value) >= 0
    >>> readVar(bytes([64]))
    64
    >>> readVar(bytes([225, 226, 227, 97]))
    205042145
    """
    sum = 0
    for byte in value:
        sum = (sum << 7) + (byte & 127)
        if not 128 & byte:
            break
    return sum
