Skip to content

Commit f9a3f7e

Browse files
Update jupyter_sphinx/execute.py
Co-authored-by: Anton Akhmerov <[email protected]>
1 parent 3bf0b14 commit f9a3f7e

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

jupyter_sphinx/execute.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,15 +257,14 @@ def write_notebook_output(notebook, output_dir, notebook_name):
257257
os.path.join(output_dir, notebook_name + ".ipynb"),
258258
)
259259
# Write a script too.
260-
if ntbk.metadata.get("language_info", {}).get("file_extension", None) is None:
260+
ext = notebook.metadata.get("language_info", {}).get("file_extension", None)
261+
if ext is None:
261262
ext = ".txt"
262263
js.logger.warning(
263264
"Notebook code has no file extension metadata, " "defaulting to `.txt`",
264265
# TODO correct location
265266
# location=document.settings.env.docname,
266267
)
267-
else:
268-
ext = notebook.metadata.language_info.file_extension
269268
contents = "\n\n".join(cell.source for cell in notebook.cells)
270269
with open(os.path.join(output_dir, notebook_name + ext), "w") as f:
271270
f.write(contents)

0 commit comments

Comments
 (0)