def _read_until(infile=sys.stdin, maxchars=<NUM_LIT:20>, end=RS):
chars = []<EOL>read = infile.read<EOL>if not isinstance(end, tuple):<EOL><INDENT>end = (end,)<EOL><DEDENT>while maxchars:<EOL><INDENT>char = read(<NUM_LIT:1>)<EOL>if char in end:<EOL><INDENT>break<EOL><DEDENT>chars.append(char)<EOL>maxchars -= <NUM_LIT:1><EOL><DEDENT>return '<STR_LIT>'.join(chars)<EOL>
Read a terminal response of up to a few characters from stdin.