o
    ”^©iÆ  ã                   @  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	   úM/home/ubuntu/hpml_nyu/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r‰dd„ t|ƒD ƒ|_|S )ú,Create a new code cell with input and outputNÚpyerrÚpyoutc                 S  r   r	   )Ústr)r   Úframer	   r	   r
   r   _   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_output0   s<   











r7   Ú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_celld   s   



rA   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:   rB   rC   r@   r	   r	   r
   Únew_text_cell~   s   

rD   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   )rE   rF   Úwsr	   r	   r
   Únew_worksheet‰   s   

ÿrH   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   ÚnbformatÚ
worksheetsr   Únew_metadataÚmetadata)rM   rK   Únbr	   r	   r
   Únew_notebook•   s   

ÿrO   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   rE   r   ÚauthorsÚcreatedÚmodifiedÚlicenseÚgistid)rE   rP   rS   rQ   rR   rT   rM   r	   r	   r
   rL   ¤   s   	





rL   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   rE   ÚemailÚaffiliationÚurl)rE   rU   rV   rW   Úauthorr	   r	   r
   Ú
new_author½   s   



rY   )NNNNNNNNNNNNN)NNNr8   F)NN)NNNNNN)NNNN)r   Ú
__future__r   Únbformat._structr   r   r   r7   rA   rD   rH   rO   rL   rY   r	   r	   r	   r
   Ú<module>   sH    
ó5
û



ú