
    f                        d Z ddlmZ ddlZddlmZ dZdZddiZ G d d	e      Z	d
 Z
d 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dZy)zThe 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.
    )annotationsN)Struct   )r   r   znbformat.v3.schema.jsonc                      e Zd ZdZy)NotebookNodezA notebook node object.N)__name__
__module____qualname____doc__     M/var/www/cvtools/html/venv/lib/python3.12/site-packages/nbformat/v3/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 an object.)
isinstancedictr   items	from_dicttuplelist)dnewdkvis        r   r   r      sk    !T~GGI 	#DAqlDG	#!eT]#&'(	!((H )s   A4c                2    t        | t              st        | S )zY
    Used to be cast_unicode, add this temporarily to make sure no further breakage.
    )r   strAssertionErrorobjs    r   str_passthroughr    +   s     c3Jr   c                    t        | t              r.t        j                  dt        d       | j                  dd      S t        | t              st        | S )zCast an object as a string.zbA notebook got bytes instead of likely base64 encoded values.The content will likely be corrupted.r   )
stacklevelasciireplace)r   byteswarningswarnUserWarningdecoder   r   r   s    r   cast_strr*   4   sM    #u 	4		
 zz'9--c3Jr   c                   t               }t        |       |_        |i }t        |t              sd}t        |      | dv r||_        | 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}|_        | dk(  r|dn
t        |      |_        |S c c}w )zGCreate a new output, to go in the ``cell.outputs`` list of a code cell.zmetadata must be dict>   pyoutdisplay_datapyerrr,   streamstdout)r   r   output_typer   r   	TypeErrormetadatar    textr*   pngjpeghtmlsvglatexjson
javascriptintprompt_numberenameevaluer   	tracebackr/   )r1   output_text
output_pngoutput_html
output_svgoutput_latexoutput_jsonoutput_javascriptoutput_jpegr=   r>   r?   r@   r/   r3   outputmsgframes                     r   
new_outputrL   E   ss   $ ^F[)Fh%%n//"g")+6FK!!*-FJ"";/FK")+6FK!(4FJ#*<8FL")+6FK( /0A BFg-";"=1g*51FL+F3FM DHOT5 6TFh$*N8OM  Us   +E c                   t               }d|_        |t        |      |_        | t        |       |_        |t        |      |_        |g |_        n||_        |t        |      |_	        t        |xs i       |_
        |S )z,Create a new code cell with input and outputcode)r   	cell_typer    languageinputr<   r=   outputsbool	collapsedr3   )rQ   r=   rR   rP   rT   r3   cells          r   new_code_cellrV      s     >DDN'1$U+
  /i R0DMKr   c                    t               }| dk(  rd} |t        |      |_        t        |xs i       |_        | |_        |S )zCreate a new text cell.	plaintextraw)r   r    sourcer3   rO   )rO   rZ   renderedr3   rU   s        r   new_text_cellr\      sF    >D K	%f- R0DMDNKr   c                    t               }d|_        | t        |       |_        t	        |      |_        t        |xs i       |_        |S )z5Create a new section cell with a given integer level.heading)r   rO   r    rZ   r<   levelr3   )rZ   r_   r[   r3   rU   s        r   new_heading_cellr`      sB    >DDN%f-UDJ R0DMKr   c                v    t               }|g |_        nt        |      |_        t        |xs i       |_        |S )z5Create a worksheet by name with with a list of cells.)r   cellsr   r3   )namerb   r3   wss       r   new_worksheetre      s5    	B};x~2.BKIr   c                    t               }t        |_        t        |_        |g |_        nt	        |      |_        |t               |_        nt        |      |_        | t        |       |j                  _        |S )z7Create a notebook by name, id and a list of worksheets.)	r   nbformatnbformat_minor
worksheetsr   new_metadatar3   r    rc   )rc   r3   ri   nbs       r   new_notebookrl      sh    	BBK&BZ("n"8,*40Ir   c                    t               }| t        |       |_        |t        |      |_        |t        |      |_        |t        |      |_        |t        |      |_        |t        |      |_        |S )zCreate a new metadata node.)	r   r    rc   r   authorscreatedmodifiedlicensegistid)rc   rn   rq   ro   rp   rr   r3   s          r   rj   rj      s     ~H'-=*73+H5*73)&1Or   c                    t               }| t        |       |_        |t        |      |_        |t        |      |_        |t        |      |_        |S )zCreate a new author.)r   r    rc   emailaffiliationurl)rc   rt   ru   rv   authors        r   
new_authorrx      sV    ^F%d+&u-,[9
$S)
Mr   )NNNNNNNNNNNNNN)NNNpythonFN)NNN)N   NN)NNNNNN)NNNN)r   
__future__r   r&   nbformat._structr   rg   rh   nbformat_schemar   r   r    r*   rL   rV   r\   r`   re   rl   rj   rx   r   r   r   <module>r~      s    #  # 45"6 "	& 
>D 8& 
2r   