
    e                         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dS )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dS )NotebookNodezA notebook node object.N)__name__
__module____qualname____doc__     2lib/python3.11/site-packages/nbformat/v2/nbbase.pyr   r      s        !!Dr   r   c                     t          | t                    r<t                      }|                                 D ]\  }}t	          |          ||<   |S t          | t
          t          f          rd | D             S | S )z%Create notebook node(s) from a value.c                 ,    g | ]}t          |          S r
   )	from_dict).0is     r   
<listcomp>zfrom_dict.<locals>.<listcomp>-   s    (((	!(((r   )
isinstancedictr   itemsr   tuplelist)dnewdkvs       r   r   r   %   s}    !T ~~GGII 	# 	#DAqllDGG	At}	%	% ((a((((r   Nc                    t                      }| t          |           |_        | dk    r|t          |          |_        |t	          |          |_        |t	          |          |_        |t          |          |_        |t          |          |_        |t          |          |_	        |t          |          |_
        |t          |          |_        | dk    r|	t          |	          |_        | dk    rL|
t          |
          |_        |t          |          |_        |d t!          |          D             |_        |S ),Create a new code cell with input and outputNpyerrpyoutc                 ,    g | ]}t          |          S r
   )str)r   frames     r   r   znew_output.<locals>.<listcomp>a   s    HHHuE

HHHr   )r   r!   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/   r0   r1   outputs                 r   
new_outputr;   2   sN     ^^F --g"k**FK!z**FJ",,FK"k**FK!ZFJ#|,,FL"k**FK( #$5 6 6Fg-";"=11gu::FLKKFM HHYHHHFMr   pythonFc                    t                      }d|_        |t          |          |_        | t          |           |_        |t          |          |_        |g |_        n||_        |t          |          |_	        |S )r   code)
r   	cell_typer!   languageinputr-   r.   outputsbool	collapsed)rA   r.   rB   r@   rD   cells         r   new_code_cellrF   f   s}     >>DDNHZZ
  //iKr   c                     t                      }|t          |          |_        |t          |          |_        | |_        |S )zCreate a new text cell.)r   r!   sourcerenderedr?   )r?   rH   rI   rE   s       r   new_text_cellrJ   |   s=    >>D&kkHDNKr   c                     t                      }| t          |           |_        |g |_        nt	          |          |_        |S )z5Create a worksheet by name with with a list of cells.)r   r!   namecellsr   )rL   rM   wss      r   new_worksheetrO      s>    	Bd))};;Ir   c                     t                      }d|_        |g |_        nt          |          |_        | t	                      |_        nt          |           |_        |S )z7Create a notebook by name, id and a list of worksheets.   )r   nbformat
worksheetsr   new_metadatametadata)rU   rS   nbs      r   new_notebookrW      sW    	BBKZ(("nn"8,,Ir   c                 *   t                      }| t          |           |_        |t          |          |_        |t          |          |_        |t          |          |_        |t          |          |_        |t          |          |_        |S )zCreate a new metadata node.)	r   r!   rL   r   authorscreatedmodifiedlicensegistid)rL   rY   r\   rZ   r[   r]   rU   s          r   rT   rT      s     ~~HD		==w<<MMw<<f++Or   c                     t                      }| t          |           |_        |t          |          |_        |t          |          |_        |t          |          |_        |S )zCreate a new author.)r   r!   rL   emailaffiliationurl)rL   r_   r`   ra   authors        r   
new_authorrc      s^    ^^F$ii5zz --
XX
Mr   )NNNNNNNNNNNNN)NNNr<   F)NN)NNNNNN)NNNN)r	   nbformat._structr   r   r   r;   rF   rJ   rO   rW   rT   rc   r
   r   r   <module>re      s*  
 
. $ # # # # #	 	 	 	 	6 	 	 	
 
 
 
1 1 1 1j PU   ,   	 	 	 	     PT   (     r   