MCPcopy Create free account
hub / github.com/deepnote/vscode-deepnote / wrapPythonStartupBlock

Function wrapPythonStartupBlock

src/kernels/kernel.ts:1165–1180  ·  view source on GitHub ↗
(inputCode: string[], pythonMessage: string)

Source from the content-addressed store, hash-verified

1163
1164// Wrap a block of python code in try except to make sure hat we have n
1165function 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.

Callers 1

Calls 2

mapMethod · 0.80
pushMethod · 0.65

Tested by

no test coverage detected