Skip to content

Commit 7b4405e

Browse files
Balandatfacebook-github-bot
authored andcommitted
tutorials: Use PythonExporter instead of ScriptExporter (#429)
Summary: We want to export python, so this is what we should do. Also, this replaces the default `#!/usr/bin/env python` shebang in the generated .py files with `#!/usr/bin/env python3`. Pull Request resolved: #429 Test Plan: CircleCI Reviewed By: sdaulton Differential Revision: D21249625 Pulled By: Balandat fbshipit-source-id: d7901e29c8c9362c888bdf1dd0a8901c28c4f019
1 parent 5a2c72d commit 7b4405e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

scripts/parse_tutorials.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
import nbformat
1414
from bs4 import BeautifulSoup
15-
from nbconvert import HTMLExporter, ScriptExporter
15+
from nbconvert import HTMLExporter, PythonExporter
1616

1717

1818
TEMPLATE = """const CWD = process.cwd();
@@ -92,8 +92,10 @@ def gen_tutorials(repo_dir: str) -> None:
9292
)
9393
with open(ipynb_out_path, "w") as ipynb_outfile:
9494
ipynb_outfile.write(nb_str)
95-
exporter = ScriptExporter()
95+
exporter = PythonExporter()
9696
script, meta = exporter.from_notebook_node(nb)
97+
# make sure to use python3 shebang
98+
script = script.replace("#!/usr/bin/env python", "#!/usr/bin/env python3")
9799
py_out_path = os.path.join(
98100
repo_dir, "website", "static", "files", "{}.py".format(tid)
99101
)

0 commit comments

Comments
 (0)