| 2068 | ''') |
| 2069 | |
| 2070 | def interact(self): |
| 2071 | self.output.write('\n') |
| 2072 | while True: |
| 2073 | try: |
| 2074 | request = self.getline('help> ') |
| 2075 | except (KeyboardInterrupt, EOFError): |
| 2076 | break |
| 2077 | request = request.strip() |
| 2078 | if not request: |
| 2079 | continue # back to the prompt |
| 2080 | |
| 2081 | # Make sure significant trailing quoting marks of literals don't |
| 2082 | # get deleted while cleaning input |
| 2083 | if (len(request) > 2 and request[0] == request[-1] in ("'", '"') |
| 2084 | and request[0] not in request[1:-1]): |
| 2085 | request = request[1:-1] |
| 2086 | if request.lower() in ('q', 'quit', 'exit'): break |
| 2087 | if request == 'help': |
| 2088 | self.intro() |
| 2089 | else: |
| 2090 | self.help(request) |
| 2091 | |
| 2092 | def getline(self, prompt): |
| 2093 | """Read one line, using input() when appropriate.""" |