MCPcopy Index your code
hub / github.com/tinode/chat / stdin

Function stdin

tn-cli/input_handler.py:28–65  ·  view source on GitHub ↗
(InputQueue)

Source from the content-addressed store, hash-verified

26
27# Stdin reads a possibly multiline input from stdin and queues it for asynchronous processing.
28def 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')

Callers

nothing calls this directly

Calls 3

printerrFunction · 0.90
readLinesFromStdinFunction · 0.85
appendMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…