(InputQueue)
| 26 | |
| 27 | # Stdin reads a possibly multiline input from stdin and queues it for asynchronous processing. |
| 28 | def stdin(InputQueue): |
| 29 | partial_input = "" |
| 30 | try: |
| 31 | for cmd in readLinesFromStdin(): |
| 32 | cmd = cmd.strip() |
| 33 | # Check for continuation symbol \ in the end of the line. |
| 34 | if len(cmd) > 0 and cmd[-1] == "\\": |
| 35 | cmd = cmd[:-1].rstrip() |
| 36 | if cmd: |
| 37 | if partial_input: |
| 38 | partial_input += " " + cmd |
| 39 | else: |
| 40 | partial_input = cmd |
| 41 | |
| 42 | if tn_globals.IsInteractive: |
| 43 | sys.stdout.write("... ") |
| 44 | sys.stdout.flush() |
| 45 | |
| 46 | continue |
| 47 | |
| 48 | # Check if we have cached input from a previous multiline command. |
| 49 | if partial_input: |
| 50 | if cmd: |
| 51 | partial_input += " " + cmd |
| 52 | InputQueue.append(partial_input) |
| 53 | partial_input = "" |
| 54 | continue |
| 55 | |
| 56 | InputQueue.append(cmd) |
| 57 | |
| 58 | # Stop processing input |
| 59 | if cmd == 'exit' or cmd == 'quit' or cmd == '.exit' or cmd == '.quit': |
| 60 | return |
| 61 | |
| 62 | except Exception as ex: |
| 63 | printerr("Exception in stdin", ex) |
| 64 | |
| 65 | InputQueue.append('exit') |
nothing calls this directly
no test coverage detected
searching dependent graphs…