| 2021 | ''') |
| 2022 | |
| 2023 | def interact(self): |
| 2024 | self.output.write('\n') |
| 2025 | while True: |
| 2026 | try: |
| 2027 | request = self.getline('help> ') |
| 2028 | except (KeyboardInterrupt, EOFError): |
| 2029 | break |
| 2030 | request = request.strip() |
| 2031 | if not request: |
| 2032 | continue # back to the prompt |
| 2033 | |
| 2034 | # Make sure significant trailing quoting marks of literals don't |
| 2035 | # get deleted while cleaning input |
| 2036 | if (len(request) > 2 and request[0] == request[-1] in ("'", '"') |
| 2037 | and request[0] not in request[1:-1]): |
| 2038 | request = request[1:-1] |
| 2039 | if request.lower() in ('q', 'quit', 'exit'): break |
| 2040 | if request == 'help': |
| 2041 | self.intro() |
| 2042 | else: |
| 2043 | self.help(request) |
| 2044 | |
| 2045 | def getline(self, prompt): |
| 2046 | """Read one line, using input() when appropriate.""" |