(filePath: string)
| 181 | } |
| 182 | |
| 183 | async 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 | |
| 203 | function convertCellToBlock(cell: JupyterCell, index: number, idGenerator: () => string): DeepnoteBlock { |
| 204 | let source = Array.isArray(cell.source) ? cell.source.join('') : cell.source |
no outgoing calls
no test coverage detected