@@ -29,16 +29,12 @@ def iter_chapters(root):
29
29
if _ .startswith ('chapter' )]):
30
30
yield chapter
31
31
32
- def iter_recipes (root , dir ):
32
+ def iter_recipes (root , dir = '' ):
33
33
files = sorted ([_ for _ in os .listdir (op .join (root , dir ))
34
34
if re .match (r'\d{2}\_[^.]+\.ipynb' , _ )])
35
35
for file in files :
36
36
yield file
37
37
38
- curdir = op .realpath (op .dirname (os .path .abspath (__file__ )))
39
- root = op .realpath (op .join (curdir , '../notebooks' ))
40
-
41
-
42
38
def fix_v3 (path ):
43
39
with open (path , 'r' ) as f :
44
40
nb = json .load (f )
@@ -50,8 +46,6 @@ def fix_v3(path):
50
46
with open (path , 'w' ) as f :
51
47
json .dump (nb , f , indent = 2 )
52
48
53
-
54
-
55
49
def convert_to_v4 (path ):
56
50
nb = read (path , 3 )
57
51
nb_new = convert (nb , 4 )
@@ -79,17 +73,35 @@ def convert_to_v4(path):
79
73
validate (nb_new )
80
74
write (nb_new , path )
81
75
76
+ curdir = op .realpath (op .dirname (os .path .abspath (__file__ )))
77
+ root = op .realpath (op .join (curdir , '../notebooks' ))
78
+ featured = op .realpath (op .join (curdir , '../featured' ))
79
+
82
80
if __name__ == '__main__' :
83
81
84
- for chapter in iter_chapters (root ):
85
- for recipe in iter_recipes (root , chapter ):
86
- file = op .join (root , chapter , recipe )
82
+ # Chapter notebooks
83
+ # for chapter in iter_chapters(root):
84
+ # for recipe in iter_recipes(root, chapter):
85
+ # file = op.join(root, chapter, recipe)
86
+
87
+ # if recipe in ('01_notebook.ipynb',
88
+ # '02_pandas.ipynb',
89
+ # '03_numpy.ipynb',):
90
+ # continue
91
+ # print("converting", file)
92
+
93
+ # # fix_v3(file)
94
+ # convert_to_v4(file)
95
+
96
+ # Featured notebooks
97
+ for recipe in iter_recipes (featured ):
98
+ file = op .join (featured , recipe )
87
99
88
- if recipe in ('01_notebook.ipynb' ,
89
- '02_pandas.ipynb' ,
90
- '03_numpy.ipynb' ,):
91
- continue
92
- print ("converting" , file )
100
+ if recipe in ('01_notebook.ipynb' ,
101
+ '02_pandas.ipynb' ,
102
+ '03_numpy.ipynb' ,):
103
+ continue
104
+ print ("converting" , file )
93
105
94
- # fix_v3(file)
95
- convert_to_v4 (file )
106
+ # fix_v3(file)
107
+ convert_to_v4 (file )
0 commit comments