def generate_zipfiles(gallery_dir):
 listdir = list_downloadable_sources(gallery_dir)
 for directory in sorted(os.listdir(gallery_dir)):
  if os.path.isdir(os.path.join(gallery_dir, directory)):
   target_dir = os.path.join(gallery_dir, directory)
   listdir.extend(list_downloadable_sources(target_dir))
 py_zipfile = python_zip(listdir, gallery_dir)
 jy_zipfile = python_zip(listdir, gallery_dir, '.ipynb')
 dw_rst = CODE_ZIP_DOWNLOAD.format(os.path.basename(py_zipfile), py_zipfile, os.path.basename(jy_zipfile), jy_zipfile)
 return dw_rst

def generate_zipfiles ( gallery_dir ) : listdir = list_downloadable_sources ( gallery_dir ) for directory in sorted ( os . listdir ( gallery_dir ) ) : if os . path . isdir ( os . path . join ( gallery_dir , directory ) ) : target_dir = os . path . join ( gallery_dir , directory ) listdir . extend ( list_downloadable_sources ( target_dir ) ) py_zipfile = python_zip ( listdir , gallery_dir ) jy_zipfile = python_zip ( listdir , gallery_dir , '.ipynb' ) dw_rst = CODE_ZIP_DOWNLOAD . format ( os . path . basename ( py_zipfile ) , py_zipfile , os . path . basename ( jy_zipfile ) , jy_zipfile ) return dw_rst
collects all python source files and jupyter notebooks in gallery_dir and makes zipfiles of them parameters gallery_dir : string path of the gallery to collect downloadable sources return download_rst: string restructuredtext to include download buttons to the generated files .