a
    ø£Be¸  ã                   @   s~   d Z ddlmZ ddlmZ dZdZdddd	d
dddœZddd„Z	ddd„Z
dd„ Zd dd„Zd!dd„Zd"dd„Zdd„ ZdS )#zúPython API for composing notebook elements

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.
é    )Úgenerate_corpus_id)ÚNotebookNodeé   é   znbformat.v4.schema.jsonznbformat.v4.0.schema.jsonznbformat.v4.1.schema.jsonznbformat.v4.2.schema.jsonznbformat.v4.3.schema.jsonznbformat.v4.4.schema.jsonznbformat.v4.5.schema.json))NN)r   r   )r   é   )r   é   )r   é   )r   r   )r   r   Nc                 C   s   ddl m} || |t d�S )zvalidate a v4 noder   )Úvalidate)ÚrefÚversion)Únbformatr	   )Únoder
   Zvalidate_orig© r   úU/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/nbformat/v4/nbbase.pyr	   $   s    r	   c                 K   sš   t | d�}| dkr d|_d|_nT| dkr:t ƒ |_t ƒ |_n:| dkrZt ƒ |_t ƒ |_d|_n| dkrtd	|_d|_g |_| 	|¡ |durŒ||_t
|| ƒ |S )
zGCreate a new output, to go in the ``cell.outputs`` list of a code cell.)Úoutput_typeÚstreamÚstdoutÚ Údisplay_dataÚexecute_resultNÚerrorÚNotImplementedError)r   ÚnameÚtextÚmetadataÚdataÚexecution_countÚenameÚevalueÚ	tracebackÚupdater	   )r   r   ÚkwargsÚoutputr   r   r   Ú
new_output+   s(    



r#   c                 C   s¨   | d d }| d }|dkr8t ||d |d |d d�S |d	krVt ||d
 |d d�S |dkrtt ||d |d d�S |dkr˜t ||d |d |d d�S td| ƒ‚dS )zâCreate a NotebookNode for an output from a kernel's IOPub message.

    Returns
    -------
    NotebookNode: the output as a notebook node.

    Raises
    ------
    ValueError: if the message is not an output message.

    ÚheaderÚmsg_typeÚcontentr   r   r   r   )r   r   r   r   r   r   r   )r   r   r   r   )r   r   r   r   r   r   r   )r   r   r   r   z Unrecognized output msg type: %rN)r#   Ú
ValueError)Úmsgr%   r&   r   r   r   Úoutput_from_msgH   s:    üýýür)   r   c                 K   s0   t tƒ dt ƒ d| g d�}| |¡ t|dƒ |S )zCreate a new code cellÚcodeN)ÚidÚ	cell_typer   r   ÚsourceÚoutputsZ	code_cell©r   Úrandom_cell_idr    r	   ©r-   r!   Úcellr   r   r   Únew_code_cellu   s    ú

r3   c                 K   s,   t tƒ d| t ƒ d�}| |¡ t|dƒ |S )zCreate a new markdown cellÚmarkdown©r+   r,   r-   r   Zmarkdown_cellr/   r1   r   r   r   Únew_markdown_cell…   s    ü

r6   c                 K   s,   t tƒ d| t ƒ d�}| |¡ t|dƒ |S )zCreate a new raw cellÚrawr5   Zraw_cellr/   r1   r   r   r   Únew_raw_cell“   s    ü

r8   c                  K   s(   t ttt ƒ g d�}| | ¡ t|ƒ |S )zCreate a new notebook)r   Únbformat_minorr   Úcells)r   r   r9   r    r	   )r!   Únbr   r   r   Únew_notebook¡   s    ü
r<   )N)N)r   )r   )r   )Ú__doc__Znbformat.corpus.wordsr   r0   Znbformat.notebooknoder   r   r9   Znbformat_schemar	   r#   r)   r3   r6   r8   r<   r   r   r   r   Ú<module>   s&   ù

-


