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

Method read_command

Lib/pdb.py:3187–3215  ·  view source on GitHub ↗
(self, prompt)

Source from the content-addressed store, hash-verified

3185 return input(prompt)
3186
3187 def read_command(self, prompt):
3188 reply = self.read_input(prompt, multiline_block=False)
3189 if self.state == "dumb":
3190 # No logic applied whatsoever, just pass the raw reply back.
3191 return reply
3192
3193 prefix = ""
3194 if self.state == "pdb":
3195 # PDB command entry mode
3196 cmd = self.pdb_instance.parseline(reply)[0]
3197 if cmd in self.pdb_commands or reply.strip() == "":
3198 # Recognized PDB command, or blank line repeating last command
3199 return reply
3200
3201 # Otherwise, explicit or implicit exec command
3202 if reply.startswith("!"):
3203 prefix = "!"
3204 reply = reply.removeprefix(prefix).lstrip()
3205
3206 if codeop.compile_command(reply + "\n", "<stdin>", "single") is not None:
3207 # Valid single-line statement
3208 return prefix + reply
3209
3210 # Otherwise, valid first line of a multi-line statement
3211 more_prompt = "...".ljust(len(prompt))
3212 while codeop.compile_command(reply, "<stdin>", "single") is None:
3213 reply += "\n" + self.read_input(more_prompt, multiline_block=True)
3214
3215 return prefix + reply
3216
3217 @contextmanager
3218 def readline_completion(self, completer):

Callers 1

prompt_for_replyMethod · 0.95

Calls 7

read_inputMethod · 0.95
parselineMethod · 0.80
stripMethod · 0.45
startswithMethod · 0.45
lstripMethod · 0.45
removeprefixMethod · 0.45
ljustMethod · 0.45

Tested by

no test coverage detected