Skip to content

Commit c05a84a

Browse files
committed
Add kernelspec tool
1 parent 80f4f56 commit c05a84a

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tools/fix_kernelspec.py

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import os
2+
3+
import nbformat
4+
5+
from generate_contents import iter_notebooks, NOTEBOOK_DIR
6+
7+
def fix_kernelspec():
8+
for nb_name in iter_notebooks():
9+
nb_file = os.path.join(NOTEBOOK_DIR, nb_name)
10+
nb = nbformat.read(nb_file, as_version=4)
11+
12+
print("- Updating kernelspec for {0}".format(nb_name))
13+
nb['metadata']['kernelspec']['display_name'] = 'Python 3'
14+
15+
nbformat.write(nb, nb_file)
16+
17+
18+
if __name__ == '__main__':
19+
fix_kernelspec()

0 commit comments

Comments
 (0)