
    Ib                     :    d dl Z d dlZd dlZd dlmc mZ d Zd Zy)    Nc                      dddddgS )z&Metadata for notebook bundlerextensionnotebook_zip_downloadzIPython Notebook bundle (.zip)znotebook.bundler.zip_bundlerdownload)namelabelmodule_namegroup r
       >/usr/lib/python3/dist-packages/notebook/bundler/zip_bundler.py_jupyter_bundlerextension_pathsr      s     ,59	  r   c                 (   t         j                  j                  | j                  d   j                  |d         }|d   }t         j                  j                  |      d   }t         j                  j                  |      d   dz   }| j                  |       | j                  dd       t        j                  |d      }t        j                         }t        j                  |d	t        j                  
      }|j                  ||       t         j                  j!                  |      }	|D ]4  }
t         j                  j                  |	|
      }|j                  ||
       6 |j#                          | j%                  |j'                                y)a  Create a zip file containing the original notebook and files referenced
    from it. Retain the referenced files in paths relative to the notebook.
    Return the zip as a file download. 
    
    Assumes the notebook and other files are all on local disk.
    
    Parameters
    ----------
    handler : tornado.web.RequestHandler
        Handler that serviced the bundle request
    model : dict
        Notebook model from the configured ContentManager
    contents_managerpathr   r   z.zipzContent-Typezapplication/zip   w)modecompressionN)osr   joinsettingsroot_dirsplitextset_attachment_header
set_headertoolsget_file_referencesioBytesIOzipfileZipFileZIP_DEFLATEDwritedirnameclosefinishgetvalue)handlermodelabs_nb_pathnotebook_filenamenotebook_namezip_filenameref_filenames
zip_bufferzipfnotebook_dirnb_relative_filenameabs_fns               r   bundler4      sD    '',,w//0BCLLfKfGG$$%67:M 77##M215>L!!,/~'89 --k1=M J??:CW=Q=QRDJJ{-.77??;/L - 1l,@A

6/0	1 	JJL NN:&&()r   )r   r   r    notebook.bundler.toolsbundlerr   r   r4   r
   r   r   <module>r7      s     
 	  & &**r   