def read_varint()

in scripts/parser.py [0:0]


def read_varint(stream):
    """Read a Base-128 varint from `stream`. Returns (value, bytes_read)."""
    result = 0; shift = 0; count = 0
    while True:
        b = stream.read(1)
        if not b: raise EOFError
        b = b[0]
        result |= (b & 0x7F) << shift
        count += 1
        if not (b & 0x80): break
        shift += 7
    return result, count