MCPcopy Index your code
hub / github.com/python/cpython / onecmd

Method onecmd

Lib/cmd.py:203–227  ·  view source on GitHub ↗

Interpret the argument as though it had been typed in response to the prompt. This may be overridden, but should not normally need to be; see the precmd() and postcmd() methods for useful execution hooks. The return value is a flag indicating whether interpretation o

(self, line)

Source from the content-addressed store, hash-verified

201 return cmd, arg, line
202
203 def onecmd(self, line):
204 """Interpret the argument as though it had been typed in response
205 to the prompt.
206
207 This may be overridden, but should not normally need to be;
208 see the precmd() and postcmd() methods for useful execution hooks.
209 The return value is a flag indicating whether interpretation of
210 commands by the interpreter should stop.
211
212 """
213 cmd, arg, line = self.parseline(line)
214 if not line:
215 return self.emptyline()
216 if cmd is None:
217 return self.default(line)
218 self.lastcmd = line
219 if line == 'EOF' :
220 self.lastcmd = ''
221 if cmd == '':
222 return self.default(line)
223 else:
224 func = getattr(self, 'do_' + cmd, None)
225 if func is None:
226 return self.default(line)
227 return func(arg)
228
229 def emptyline(self):
230 """Called when an empty line is entered in response to the prompt.

Callers 2

cmdloopMethod · 0.95
emptylineMethod · 0.95

Calls 4

parselineMethod · 0.95
emptylineMethod · 0.95
defaultMethod · 0.95
funcFunction · 0.50

Tested by

no test coverage detected