@@ -34,6 +34,8 @@ def parse_args() -> argparse.Namespace:
3434
3535def process_repo (repo , destination_directory ):
3636 """Process a tutorial repository to copy its rendered tutorial(s) into `destination_directory`."""
37+ os .makedirs (destination_directory , exist_ok = True )
38+
3739 repo_name = repo ["full_name" ]
3840 if not repo_name .split ("/" )[1 ].startswith ("tutorial--" ):
3941 return
@@ -53,6 +55,7 @@ def process_repo(repo, destination_directory):
5355 return
5456
5557 repo = Path (tmp )
58+ # os.system(f'tree {repo}')
5659 tutorials = glob .glob (f"{ repo } /_sources/*.ipynb" )
5760 for t in tutorials :
5861 tname = os .path .splitext (os .path .basename (t ))[0 ]
@@ -67,9 +70,14 @@ def process_repo(repo, destination_directory):
6770 print (f"More than 1 tutorial found; also copying index file { index } " )
6871 shutil .copy (index , destination_directory )
6972 # copy images (plots) in notebook for faster page loading
70- try :
71- shutil .copy (f"{ repo } /_images/*.png" , f"{ destination_directory } /nboutput" )
72- except FileNotFoundError :
73+ images = glob .glob (f"{ repo } /_images/*.png" )
74+ if len (images ) > 0 :
75+ print ("Copying notebook cell output images" )
76+ image_dir = f"{ destination_directory } /nboutput"
77+ os .makedirs (image_dir , exist_ok = True )
78+ for i in images :
79+ shutil .copy (i , image_dir )
80+ else :
7381 print ("No notebook cell output images found to copy" )
7482
7583
0 commit comments