o
    º¼tfÆ  ã                   @  s®   d Z ddlm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
é    )Úannotations)ÚStructc                   @  s   e Zd ZdZdS )ÚNotebookNodezA notebook node object.N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__© r	   r	   ú[/var/www/html/software/conda/envs/catlas/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)ÚdZ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r‰dd„ t|ƒD ƒ|_|S )ú,Create a new code cell with input and outputNZpyerrZpyoutc                 S  r   r	   )Ústr)r   Úframer	   r	   r
   r   _   r   znew_output.<locals>.<listcomp>)r   r   Úoutput_typeÚtextÚbytesZpngZjpegÚhtmlÚsvgÚlatexÚjsonÚ
javascriptÚintÚprompt_numberÚetypeÚevaluer   Ú	traceback)r   Zoutput_textZ
output_pngÚoutput_htmlZ
output_svgZoutput_latexZoutput_jsonZoutput_javascriptZoutput_jpegr%   r&   r'   r(   Úoutputr	   r	   r
   Ú
new_output0   s<   











r+   Ú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)r0   r%   r1   r/   r3   Úcellr	   r	   r
   Únew_code_celld   s   



r5   c                 C  s4   t ƒ }|durt|ƒ|_|durt|ƒ|_| |_|S )zCreate a new text cell.N)r   r   ÚsourceÚrenderedr.   )r.   r6   r7   r4   r	   r	   r
   Únew_text_cell~   s   

r8   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   )r9   r:   Úwsr	   r	   r
   Únew_worksheet‰   s   

ÿr<   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.é   N)r   ZnbformatÚ
worksheetsr   Únew_metadataÚmetadata)r@   r>   Únbr	   r	   r
   Únew_notebook•   s   

ÿrB   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   r9   r   ÚauthorsÚcreatedÚmodifiedÚlicenseÚgistid)r9   rC   rF   rD   rE   rG   r@   r	   r	   r
   r?   ¤   s   	





r?   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   r9   ÚemailÚaffiliationÚurl)r9   rH   rI   rJ   Zauthorr	   r	   r
   Ú
new_author½   s   



rK   )NNNNNNNNNNNNN)NNNr,   F)NN)NNNNNN)NNNN)r   Ú
__future__r   Znbformat._structr   r   r   r+   r5   r8   r<   rB   r?   rK   r	   r	   r	   r
   Ú<module>   sH    
ó5
û



ú