a
    ø£Be¯  ã                   @   sr   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   úU/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/nbformat/v2/nbbase.pyr      s   r   c                 C   sV   t | tƒr2tƒ }|  ¡ D ]\}}t|ƒ||< q|S t | ttfƒrNdd„ | D ƒS | S dS )z%Create notebook node(s) from a value.c                 S   s   g | ]}t |ƒ‘qS r   )Ú	from_dict)Ú.0Úir   r   r	   Ú
<listcomp>-   ó    zfrom_dict.<locals>.<listcomp>N)Ú
isinstanceÚdictr   Úitemsr
   ÚtupleÚlist)ÚdZnewdÚkÚvr   r   r	   r
   %   s    
r
   Nc                 C   s  t ƒ }| durt| ƒ|_| dkr°|dur2t|ƒ|_|durDt|ƒ|_|durVt|ƒ|_|durht|ƒ|_|durzt|ƒ|_|durŒt|ƒ|_	|duržt|ƒ|_
|dur°t|ƒ|_| dkrÊ|	durÊt|	ƒ|_| dk�r|
duræt|
ƒ|_|durøt|ƒ|_|du�rdd„ t|ƒD ƒ|_|S )ú,Create a new code cell with input and outputNZpyerrZpyoutc                 S   s   g | ]}t |ƒ‘qS r   )Ústr)r   Úframer   r   r	   r   a   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_output2   s<    













r)   ÚpythonFc                 C   sn   t ƒ }d|_|durt|ƒ|_| dur0t| ƒ|_|durBt|ƒ|_|du rRg |_n||_|durjt|ƒ|_	|S )r   ÚcodeN)
r   Ú	cell_typer   ÚlanguageÚinputr"   r#   ÚoutputsÚboolÚ	collapsed)r.   r#   r/   r-   r1   Úcellr   r   r	   Únew_code_cellf   s    



r3   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,   r4   r5   r2   r   r   r	   Únew_text_cell|   s    

r6   c                 C   s6   t ƒ }| durt| ƒ|_|du r(g |_n
t|ƒ|_|S )z5Create a worksheet by name with with a list of cells.N)r   r   ÚnameÚcellsr   )r7   r8   Úwsr   r   r	   Únew_worksheet‡   s    

r:   c                 C   sF   t ƒ }d|_|du rg |_n
t|ƒ|_| du r8tƒ |_n
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    


r@   c                 C   sv   t ƒ }| durt| ƒ|_|dur*t|ƒ|_|dur<t|ƒ|_|durNt|ƒ|_|dur`t|ƒ|_|durrt|ƒ|_|S )zCreate a new metadata node.N)	r   r   r7   r   ÚauthorsÚcreatedÚmodifiedÚlicenseÚgistid)r7   rA   rD   rB   rC   rE   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rNt|ƒ|_|S )zCreate a new author.N)r   r   r7   ÚemailÚaffiliationÚurl)r7   rF   rG   rH   Úauthorr   r   r	   Ú
new_author¶   s    



rJ   )NNNNNNNNNNNNN)NNNr*   F)NN)NN)NN)NNNNNN)NNNN)r   Znbformat._structr   r   r
   r)   r3   r6   r:   r@   r=   rJ   r   r   r   r	   Ú<module>   s2                ó
5 ÿ



 ÿ
