Source

#!/usr/bin/env pythonfromsysimportversion_infoifversion_info[0]<3:fromurllibimportquoteelse:fromurllib.requestimportquotefromglobimportglobimportjsonheader='''Place for everything Pandas.Lessons-------'''format_item='* [{name}]({url})'.formatbb_url='bitbucket.org/hrojas/learn-pandas/raw/master/{}'.formatdefnotebooks():returnglob('lessons/*Lesson.ipynb')deflesson_name(filename):withopen(filename)asfo:returnjson.load(fo)['metadata']['name']defnb_url(filename):# The double quote is not an errorraw_url=bb_url(quote(quote(filename)))return'http://nbviewer.ipython.org/urls/{}'.format(raw_url)defwrite_readme(nblist,fo):fo.write('{}\n'.format(header))fornbinnblist:name=lesson_name(nb)url=nb_url(nb)fo.write('{}\n'.format(format_item(name=name,url=url)))defmain():nblist=notebooks()withopen('README.md','w')asfo:write_readme(nblist,fo)if__name__=='__main__':main()