def from_7bit(text):
    if len(text) == 5:
        shift = 31
    elif len(text) == 10:
        shift = 62
    else:
        raise ValueError("text is not 5 or 10 bytes")
    
    x = 0
    for char in text:
        x <<= 7
        char = ord(char)
        if char > 0x7f:
            raise Exception
        x |= char
    x -= (1<<shift)-1
    return x
dataset/ETHPy150Open dokipen/whoosh/src/whoosh/util.py/from_7bit/original