42 ############################################################################### |
42 ############################################################################### |
43 |
43 |
44 |
44 |
45 def DebugClientRawInput(prompt="", echo=True): |
45 def DebugClientRawInput(prompt="", echo=True): |
46 """ |
46 """ |
47 Replacement for the standard raw_input builtin. |
47 Replacement for the standard raw_input() builtin (Python 2) and |
|
48 the standard input() builtin (Python 3). |
48 |
49 |
49 This function works with the split debugger. |
50 This function works with the split debugger. |
50 |
51 |
51 @param prompt prompt to be shown. (string) |
52 @param prompt prompt to be shown |
52 @param echo flag indicating echoing of the input (boolean) |
53 @type str |
53 @return result of the raw_input() call |
54 @param echo flag indicating echoing of the input |
|
55 @type bool |
|
56 @return result of the raw_input()/input() call |
|
57 @rtype str |
54 """ |
58 """ |
55 if DebugClientInstance is None or not DebugClientInstance.redirect: |
59 if DebugClientInstance is None or not DebugClientInstance.redirect: |
56 return DebugClientOrigRawInput(prompt) |
60 return DebugClientOrigRawInput(prompt) |
57 |
61 |
58 return DebugClientInstance.raw_input(prompt, echo) |
62 return DebugClientInstance.raw_input(prompt, echo) |
59 |
63 |
60 |
64 |
61 def DebugClientInput(prompt="", echo=True): |
65 def DebugClientInput(prompt=""): |
62 """ |
66 """ |
63 Replacement for the standard input builtin. |
67 Replacement for the standard input() builtin (Python 2). |
64 |
68 |
65 This function works with the split debugger. |
69 This function works with the split debugger. |
66 |
70 |
67 @param prompt prompt to be shown (string) |
71 @param prompt prompt to be shown |
68 @param echo flag indicating to echo the output (boolean) |
72 @type str |
69 @return result of the input() call |
73 @return result of the input() call |
|
74 @rtype str |
70 """ |
75 """ |
71 if DebugClientInstance is None or not DebugClientInstance.redirect: |
76 if DebugClientInstance is None or not DebugClientInstance.redirect: |
72 return DebugClientOrigInput(prompt) |
77 return DebugClientOrigInput(prompt) |
73 |
78 |
74 return DebugClientInstance.input(prompt, echo) |
79 return DebugClientInstance.input(prompt) |
75 |
80 |
76 # Use our own input() and on Python 2 raw_input(). |
81 # Use our own input() and on Python 2 raw_input(). |
77 if sys.version_info[0] == 2: |
82 if sys.version_info[0] == 2: |
78 try: |
83 try: |
79 DebugClientOrigRawInput = __builtins__.__dict__['raw_input'] |
84 DebugClientOrigRawInput = __builtins__.__dict__['raw_input'] |
91 DebugClientOrigInput = __main__.__builtins__.__dict__['input'] |
96 DebugClientOrigInput = __main__.__builtins__.__dict__['input'] |
92 __main__.__builtins__.__dict__['input'] = DebugClientInput |
97 __main__.__builtins__.__dict__['input'] = DebugClientInput |
93 else: |
98 else: |
94 try: |
99 try: |
95 DebugClientOrigInput = __builtins__.__dict__['input'] |
100 DebugClientOrigInput = __builtins__.__dict__['input'] |
96 __builtins__.__dict__['input'] = DebugClientInput |
101 __builtins__.__dict__['input'] = DebugClientRawInput |
97 except (AttributeError, KeyError): |
102 except (AttributeError, KeyError): |
98 import __main__ |
103 import __main__ |
99 DebugClientOrigInput = __main__.__builtins__.__dict__['input'] |
104 DebugClientOrigInput = __main__.__builtins__.__dict__['input'] |
100 __main__.__builtins__.__dict__['input'] = DebugClientInput |
105 __main__.__builtins__.__dict__['input'] = DebugClientRawInput |
101 |
106 |
102 ############################################################################### |
107 ############################################################################### |
103 |
108 |
104 |
109 |
105 def DebugClientFork(): |
110 def DebugClientFork(): |