def raw_input(self, prompt=''):
"""Read the input and delegate if necessary.
"""
line = InteractiveConsole.raw_input(self, prompt)
matches = self.commands_re.match(line)
if matches:
command, args = matches.groups()
line = self.commands[command](args)
elif line.endswith(config['DOC_CMD']):
if line.endswith(config['DOC_CMD']*2):
# search for line in online docs
# - strip off the '??' and the possible tab-completed
# '(' or '.' and replace inner '.' with '+' to create the
# query search string
line = line.rstrip(config['DOC_CMD'] + '.(').replace('.', '+')
webbrowser.open(config['DOC_URL'].format(sys=sys, term=line))
line = ''
else:
line = line.rstrip(config['DOC_CMD'] + '.(')
if not line:
line = 'dir()'
elif keyword.iskeyword(line):
line = 'help("{}")'.format(line)
else:
line = 'print({}.__doc__)'.format(line)
elif line.startswith(self.tab) or self._indent:
if line.strip():
# if non empty line with an indent, check if the indent
# level has been changed
leading_space = line[:line.index(line.lstrip()[0])]
if self._indent != leading_space:
# indent level changed, update self._indent
self._indent = leading_space
else:
# - empty line, decrease indent
self._indent = self._indent[:-len(self.tab)]
line = self._indent
elif line.startswith('%'):
self.writeline('Y U NO LIKE ME?')
return line
return line or ''
评论列表
文章目录