(inputCode: string[], pythonMessage: string)
| 1163 | |
| 1164 | // Wrap a block of python code in try except to make sure hat we have n |
| 1165 | function wrapPythonStartupBlock(inputCode: string[], pythonMessage: string): string[] { |
| 1166 | if (!inputCode || inputCode.length === 0) { |
| 1167 | return inputCode; |
| 1168 | } |
| 1169 | |
| 1170 | // First space in everything |
| 1171 | inputCode = inputCode.map((codeLine) => { |
| 1172 | return ` ${codeLine}`; |
| 1173 | }); |
| 1174 | |
| 1175 | // Add the try except |
| 1176 | inputCode.unshift(`try:`); |
| 1177 | inputCode.push(`except:`, ` print('${pythonMessage}')`); |
| 1178 | |
| 1179 | return inputCode; |
| 1180 | } |
| 1181 | |
| 1182 | /** |
| 1183 | * From the outputs, get the text/plain or stream outputs as a simple string. |
no test coverage detected