(self, prompt)
| 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): |
no test coverage detected