o
    i                     @   s   d Z ddlmZ G dd deZdd Z													ddd	ZdddZdddZdddZdddZ	dddZ
d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                   @   s   e Zd ZdZdS )NotebookNodezA notebook node object.N)__name__
__module____qualname____doc__ r   r   M/var/www/edux/Edux_v2/venv/lib/python3.10/site-packages/nbformat/v2/nbbase.pyr      s    r   c                 C   sR   t | trt }|  D ]
\}}t|||< q|S t | ttfr'dd | D S | S )z%Create notebook node(s) from a value.c                 S      g | ]}t |qS r   )	from_dict).0ir   r   r	   
<listcomp>-       zfrom_dict.<locals>.<listcomp>)
isinstancedictr   itemsr   tuplelist)dnewdkvr   r   r	   r   %   s   
r   Nc                 C   s  t  }| durt| |_| dkrX|durt||_|dur"t||_|dur+t||_|dur4t||_|dur=t||_|durFt||_	|durOt||_
|durXt||_| dkre|	duret|	|_| dkr|
durrt|
|_|dur{t||_|durdd t|D |_|S ),Create a new code cell with input and outputNpyerrpyoutc                 S   r
   r   )str)r   framer   r   r	   r   b   r   znew_output.<locals>.<listcomp>)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*   r+   r,   outputr   r   r	   
new_output2   s>   











r6   pythonFc                 C   sn   t  }d|_|durt||_| durt| |_|dur!t||_|du r)g |_n||_|dur5t||_	|S )r   codeN)
r   	cell_typer   languageinputr(   r)   outputsbool	collapsed)r;   r)   r<   r:   r>   cellr   r   r	   new_code_cellg   s   



r@   c                 C   s4   t  }|durt||_|durt||_| |_|S )zCreate a new text cell.N)r   r   sourcerenderedr9   )r9   rA   rB   r?   r   r   r	   new_text_cell{   s   

rC   c                 C   s8   t  }| durt| |_|du rg |_|S t||_|S )z5Create a worksheet by name with with a list of cells.N)r   r   namecellsr   )rD   rE   wsr   r   r	   new_worksheet   s   

rG   c                 C   sH   t  }d|_|du rg |_nt||_| du rt |_|S t | |_|S )z7Create a notebook by name, id and a list of worksheets.r   N)r   nbformat
worksheetsr   new_metadatametadata)rK   rI   nbr   r   r	   new_notebook   s   

rM   c                 C   sv   t  }| durt| |_|durt||_|durt||_|dur't||_|dur0t||_|dur9t||_|S )zCreate a new metadata node.N)	r   r   rD   r   authorscreatedmodifiedlicensegistid)rD   rN   rQ   rO   rP   rR   rK   r   r   r	   rJ      s   





rJ   c                 C   sR   t  }| durt| |_|durt||_|durt||_|dur't||_|S )zCreate a new author.N)r   r   rD   emailaffiliationurl)rD   rS   rT   rU   authorr   r   r	   
new_author   s   



rW   )NNNNNNNNNNNNN)NNNr7   F)NN)NNNNNN)NNNN)r   _structr   r   r   r6   r@   rC   rG   rM   rJ   rW   r   r   r   r	   <module>   s0    

5



