File tree Expand file tree Collapse file tree 1 file changed +19
-7
lines changed Expand file tree Collapse file tree 1 file changed +19
-7
lines changed Original file line number Diff line number Diff line change @@ -27,14 +27,24 @@ def iter_recipes(root, dir):
27
27
curdir = op .realpath (op .dirname (os .path .abspath (__file__ )))
28
28
root = op .realpath (op .join (curdir , '../notebooks' ))
29
29
30
+
31
+ def fix_v3 (path ):
32
+ with open (path , 'r' ) as f :
33
+ nb = json .load (f )
34
+
35
+ for cell in nb ['worksheets' ][0 ]['cells' ]:
36
+ if isinstance (cell .get ('metadata' , {}), list ):
37
+ cell ['metadata' ] = {}
38
+
39
+ with open (path , 'w' ) as f :
40
+ json .dump (f , nb )
41
+
42
+
43
+
30
44
def convert_to_v4 (path ):
31
45
nb = read (path , 3 )
32
46
nb_new = convert (nb , 4 )
33
47
34
- for cell in nb_new ['cells' ]:
35
- if cell .get ('metadata' , {}) == []:
36
- cell ['metadata' ] = {}
37
-
38
48
nb_new ["metadata" ] = {
39
49
"kernelspec" : {
40
50
"display_name" : "Python 3" ,
@@ -55,8 +65,8 @@ def convert_to_v4(path):
55
65
}
56
66
}
57
67
58
- validate (nb_new )
59
- write (nb_new , path )
68
+ # validate(nb_new)
69
+ # write(nb_new, path)
60
70
61
71
if __name__ == '__main__' :
62
72
@@ -69,4 +79,6 @@ def convert_to_v4(path):
69
79
'03_numpy.ipynb' ,):
70
80
continue
71
81
print ("converting" , file )
72
- convert_to_v4 (file )
82
+
83
+ fix_v3 (file )
84
+ # convert_to_v4(file)
You can’t perform that action at this time.
0 commit comments