def read_uint(file):
  """Read a uint from a file."""
  result = 0
  shift = 0
  while True:
    try:
      byte = ord(file.read(1))
    except TypeError:
      raise EOFError
    if byte&128:
      result |= (byte&127)<<shift
      shift += 7
    else:
      return result|(byte<<shift)