<s> import os <EOL> import shutil <EOL> import subprocess <EOL> import glob <EOL> def rstify_notebook ( path , outpath ) : <EOL> cmd = ( '<STR_LIT>' <EOL> . format ( path , outpath ) ) <EOL> print cmd <EOL> subprocess . check_call ( cmd , shell = True ) <EOL> path = '<STR_LIT>' <EOL> notebooks = sorted ( glob . glob ( os . path . join ( path , '<STR_LIT>' ) ) ) <EOL> outdir = '<STR_LIT>' <EOL> if os . path . exists ( outdir ) : <EOL> shutil . rmtree ( outdir ) <EOL> os . mkdir ( outdir ) <EOL> with open ( os . path . join ( outdir , '<STR_LIT>' ) , '<STR_LIT:w>' ) as manifest : <EOL> for i , path in enumerate ( notebooks ) : <EOL> base , tail = os . path . split ( path ) <EOL> root , _ = os . path . splitext ( tail ) <EOL> fpath = '<STR_LIT>' . format ( i ) <EOL> outpath = os . path . join ( outdir , fpath ) <EOL> rstify_notebook ( path , outpath ) <EOL> stub = """<STR_LIT>""" . format ( i + <NUM_LIT:1> , i ) <EOL> manifest . write ( stub ) </s>
