
    Ud                         d Z ddlmZ  G d de      Zd Z	 	 	 	 	 	 	 	 	 	 	 	 	 ddZ	 ddZdd	Zdd
ZddZ		 ddZ
ddZy)a  The basic dict based notebook format.

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

Authors:

* Brian Granger
    )Structc                       e Zd ZdZy)NotebookNodezA notebook node object.N)__name__
__module____qualname____doc__     4/usr/lib/python3/dist-packages/nbformat/v2/nbbase.pyr   r      s    !r   r   c                     t        | t              r2t               }| j                         D ]  \  }}t	        |      ||<    |S t        | t
        t        f      r| D cg c]  }t	        |       c}S | S c c}w )z%Create notebook node(s) from a value.)
isinstancedictr   items	from_dicttuplelist)dnewdkvis        r   r   r   %   sk    !T~GGI 	#DAqlDG	#	At}	%&'(	!(( )s   A4Nc                 D   t               }| t        |       |_        | dk7  r|t        |      |_        |t	        |      |_        |t	        |      |_        |t        |      |_        |t        |      |_        |t        |      |_	        |t        |      |_
        |t        |      |_        | dk(  r|	t        |	      |_        | dk(  rM|
t        |
      |_        |t        |      |_        |'t!        |      D cg c]  }t        |       c}|_        |S c c}w ),Create a new code cell with input and outputpyerrpyout)r   stroutput_typetextbytespngjpeghtmlsvglatexjson
javascriptintprompt_numberetypeevaluer   	traceback)r   output_text
output_pngoutput_html
output_svgoutput_latexoutput_jsonoutput_javascriptoutput_jpegr)   r*   r+   r,   outputframes                  r   
new_outputr7   2   s'     ^F -g"k*FK!z*FJ",FK"k*FK!ZFJ#|,FL"k*FK( #$5 6Fg-";"=1gu:FLKFM 8<YHuE
HFM  Is   Dc                     t               }d|_        |t        |      |_        | t        |       |_        |t        |      |_        |g |_        n||_        |t        |      |_	        |S )r   code)
r   	cell_typer   languageinputr(   r)   outputsbool	collapsed)r<   r)   r=   r;   r?   cells         r   new_code_cellrA   f   sp     >DDNHZ
  /iKr   c                 p    t               }|t        |      |_        |t        |      |_        | |_        |S )zCreate a new text cell.)r   r   sourcerenderedr:   )r:   rC   rD   r@   s       r   new_text_cellrE   |   s7    >D&kHDNKr   c                 t    t               }| t        |       |_        |	g |_        |S t	        |      |_        |S )z5Create a worksheet by name with with a list of cells.)r   r   namecellsr   )rG   rH   wss      r   new_worksheetrJ      s?    	Bd)} I ;Ir   c                     t               }d|_        |g |_        nt        |      |_        | t	               |_        |S t        |       |_        |S )z7Create a notebook by name, id and a list of worksheets.   )r   nbformat
worksheetsr   new_metadatametadata)rP   rN   nbs      r   new_notebookrR      sR    	BBKZ("n I #8,Ir   c                     t               }| t        |       |_        |t        |      |_        |t        |      |_        |t        |      |_        |t        |      |_        |t        |      |_        |S )zCreate a new metadata node.)	r   r   rG   r   authorscreatedmodifiedlicensegistid)rG   rT   rW   rU   rV   rX   rP   s          r   rO   rO      sz     ~HD	=w<Mw<f+Or   c                     t               }| t        |       |_        |t        |      |_        |t        |      |_        |t        |      |_        |S )zCreate a new author.)r   r   rG   emailaffiliationurl)rG   rZ   r[   r\   authors        r   
new_authorr^      sS    ^F$i5z -
X
Mr   )NNNNNNNNNNNNN)NNNpythonF)NN)NNNNNN)NNNN)r	   nbformat._structr   r   r   r7   rA   rE   rJ   rR   rO   r^   r
   r   r   <module>ra      s{   
. $	6 	
 
1j PU,	  PT(r   