MCPcopy Index your code
hub / github.com/deepnote/deepnote / parseIpynbFile

Function parseIpynbFile

packages/convert/src/jupyter-to-deepnote.ts:183–201  ·  view source on GitHub ↗
(filePath: string)

Source from the content-addressed store, hash-verified

181}
182
183async function parseIpynbFile(filePath: string): Promise<JupyterNotebook> {
184 let ipynbJson: string
185
186 try {
187 ipynbJson = await fs.readFile(filePath, 'utf-8')
188 } catch (error) {
189 const message = error instanceof Error ? error.message : String(error)
190
191 throw new FileReadError(`Failed to read ${filePath}: ${message}`, { cause: error, filePath })
192 }
193
194 try {
195 return JSON.parse(ipynbJson) as JupyterNotebook
196 } catch (error) {
197 const message = error instanceof Error ? error.message : String(error)
198
199 throw new JsonParseError(`Failed to parse ${filePath}: invalid JSON - ${message}`, { cause: error, filePath })
200 }
201}
202
203function convertCellToBlock(cell: JupyterCell, index: number, idGenerator: () => string): DeepnoteBlock {
204 let source = Array.isArray(cell.source) ? cell.source.join('') : cell.source

Callers 1

readAndConvertIpynbFileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected