| 34 | |
| 35 | |
| 36 | def save_as_ipynb(cells, filename): |
| 37 | notebook = { |
| 38 | "cells": cells, |
| 39 | "metadata": { |
| 40 | "kernelspec": { |
| 41 | "display_name": "Python 3", |
| 42 | "language": "python", |
| 43 | "name": "python3", |
| 44 | }, |
| 45 | "language_info": { |
| 46 | "codemirror_mode": {"name": "ipython", "version": 3}, |
| 47 | "file_extension": ".py", |
| 48 | "mimetype": "text/x-python", |
| 49 | "name": "python", |
| 50 | "nbconvert_exporter": "python", |
| 51 | "pygments_lexer": "ipython3", |
| 52 | "version": "3.7.11", |
| 53 | }, |
| 54 | }, |
| 55 | "nbformat": 4, |
| 56 | "nbformat_minor": 5, |
| 57 | } |
| 58 | |
| 59 | with open(filename, "w") as file: |
| 60 | json.dump(notebook, file, indent=2) |
| 61 | |
| 62 | print(f"Notebook saved as {filename}") |
| 63 | |
| 64 | |
| 65 | if __name__ == "__main__": |