File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change
1
+ from pathlib import Path
2
+ import subprocess
3
+ import sys
4
+
5
+
6
+ def main ():
7
+ path = sys .argv [1 ]
8
+ if path .strip ().lower () == "all" :
9
+ convert_all_notebooks_to_html ()
10
+ else :
11
+ convert_notebook_to_html (path )
12
+
13
+
14
+ def convert_all_notebooks_to_html ():
15
+ notebook_dir = Path (__file__ ).parent .parent / "notebooks"
16
+ for directory in (
17
+ notebook_dir / "beginner" / "notebooks" ,
18
+ notebook_dir / "intermediate" / "notebooks" ,
19
+ ):
20
+ for notebook_path in directory .glob ("*.ipynb" ):
21
+ convert_notebook_to_html (notebook_path )
22
+
23
+
24
+ def convert_notebook_to_html (notebook_path ):
25
+ path = Path (notebook_path )
26
+ if not path .exists ():
27
+ raise SystemExit (f"Invalid path { path } " )
28
+
29
+ output_dir = path .parent .parent / "html"
30
+
31
+ cmd = f"jupyter nbconvert --to html --execute --ExecutePreprocessor.timeout=30 --output-dir { output_dir } { path .absolute ()} "
32
+ subprocess .check_call (cmd .split ())
33
+
34
+
35
+ if __name__ == "__main__" :
36
+ main ()
You can’t perform that action at this time.
0 commit comments