ó
‹'=[c           @   s  d  Z  d d l Z d d l Z d d l m Z d d l m Z d e f d „  ƒ  YZ d „  Z d d d d d d d d d d d d d d „ Z
 d d d d	 e d
 „ Z d d d „ Z d d d „ Z d d d „ Z d d d d d d d „ Z d d d d d „ Z d S(   s3  The basic dict based notebook format.

The Python representation of a notebook is a nested structure of
dictionary subclasses that support attribute access
(ipython_genutils.ipstruct.Struct). The functions in this module are merely
helpers to build the structs in the right form.

Authors:

* Brian Granger
iÿÿÿÿN(   t   Struct(   t   unicode_typet   NotebookNodec           B   s   e  Z RS(    (   t   __name__t
   __module__(    (    (    s1   lib/python2.7/site-packages/nbformat/v2/nbbase.pyR   "   s   c         C   sƒ   t  |  t ƒ rI t ƒ  } x* |  j ƒ  D] \ } } t | ƒ | | <q% W| St  |  t t f ƒ r{ g  |  D] } t | ƒ ^ qe S|  Sd  S(   N(   t
   isinstancet   dictR   t   itemst	   from_dictt   tuplet   list(   t   dt   newdt   kt   vt   i(    (    s1   lib/python2.7/site-packages/nbformat/v2/nbbase.pyR   &   s    	c         C   sÙ  t  ƒ  } |  d k	 r' t |  ƒ | _ n  |  d k r&| d k	 rQ t | ƒ | _ n  | d k	 ro t | ƒ | _ n  | d k	 r t | ƒ | _ n  | d k	 r« t | ƒ | _ n  | d k	 rÉ t | ƒ | _	 n  | d k	 rç t | ƒ | _
 n  | d k	 rt | ƒ | _ n  | d k	 r&t | ƒ | _ q&n  |  d k rS|	 d k	 rSt |	 ƒ | _ qSn  |  d k rÕ|
 d k	 r}t |
 ƒ | _ n  | d k	 r›t | ƒ | _ n  | d k	 rÕg  t | ƒ D] } t | ƒ ^ q´| _ qÕn  | S(   s,   Create a new code cell with input and outputt   pyerru   pyoutu   pyerrN(   R   t   NoneR   t   output_typet   textt   bytest   pngt   jpegt   htmlt   svgt   latext   jsont
   javascriptt   intt   prompt_numbert   etypet   evalueR
   t	   traceback(   R   t   output_textt
   output_pngt   output_htmlt
   output_svgt   output_latext   output_jsont   output_javascriptt   output_jpegR   R   R   R    t   outputt   frame(    (    s1   lib/python2.7/site-packages/nbformat/v2/nbbase.pyt
   new_output2   s>    	.u   pythonc         C   s¯   t  ƒ  } d | _ | d k	 r0 t | ƒ | _ n  |  d k	 rN t |  ƒ | _ n  | d k	 rl t | ƒ | _ n  | d k r„ g  | _ n	 | | _ | d k	 r« t	 | ƒ | _
 n  | S(   s,   Create a new code cell with input and outputu   codeN(   R   t	   cell_typeR   R   t   languaget   inputR   R   t   outputst   boolt	   collapsed(   R.   R   R/   R-   R1   t   cell(    (    s1   lib/python2.7/site-packages/nbformat/v2/nbbase.pyt   new_code_cell\   s    			c         C   sR   t  ƒ  } | d k	 r' t | ƒ | _ n  | d k	 rE t | ƒ | _ n  |  | _ | S(   s   Create a new text cell.N(   R   R   R   t   sourcet   renderedR,   (   R,   R4   R5   R2   (    (    s1   lib/python2.7/site-packages/nbformat/v2/nbbase.pyt   new_text_cellp   s    		c         C   sR   t  ƒ  } |  d k	 r' t |  ƒ | _ n  | d k r? g  | _ n t | ƒ | _ | S(   s5   Create a worksheet by name with with a list of cells.N(   R   R   R   t   namet   cellsR
   (   R7   R8   t   ws(    (    s1   lib/python2.7/site-packages/nbformat/v2/nbbase.pyt   new_worksheet{   s    	c         C   sg   t  ƒ  } d | _ | d k r* g  | _ n t | ƒ | _ |  d k rT t ƒ  | _ n t  |  ƒ | _ | S(   s7   Create a notebook by name, id and a list of worksheets.i   N(   R   t   nbformatR   t
   worksheetsR
   t   new_metadatat   metadata(   R>   R<   t   nb(    (    s1   lib/python2.7/site-packages/nbformat/v2/nbbase.pyt   new_notebook‡   s    		c         C   sÁ   t  ƒ  } |  d k	 r' t |  ƒ | _ n  | d k	 rE t | ƒ | _ n  | d k	 rc t | ƒ | _ n  | d k	 r t | ƒ | _ n  | d k	 rŸ t | ƒ | _ n  | d k	 r½ t | ƒ | _	 n  | S(   s   Create a new metadata node.N(
   R   R   R   R7   R
   t   authorst   createdt   modifiedt   licenset   gistid(   R7   RA   RD   RB   RC   RE   R>   (    (    s1   lib/python2.7/site-packages/nbformat/v2/nbbase.pyR=   –   s    	c         C   s…   t  ƒ  } |  d k	 r' t |  ƒ | _ n  | d k	 rE t | ƒ | _ n  | d k	 rc t | ƒ | _ n  | d k	 r t | ƒ | _ n  | S(   s   Create a new author.N(   R   R   R   R7   t   emailt   affiliationt   url(   R7   RF   RG   RH   t   author(    (    s1   lib/python2.7/site-packages/nbformat/v2/nbbase.pyt
   new_author¨   s    	(   t   __doc__t   pprintt   uuidt   ipython_genutils.ipstructR    t   ipython_genutils.py3compatR   R   R   R   R+   t   FalseR3   R6   R:   R@   R=   RJ   (    (    (    s1   lib/python2.7/site-packages/nbformat/v2/nbbase.pyt   <module>   s$   			'	