B
    '=[                 @   sb   d Z ddlmZ dZdZ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 )a  Python API for composing notebook elements

The Python representation of a notebook is a nested structure of
dictionary subclasses that support attribute access
(ipython_genutils.ipstruct.Struct). The functions in this module are merely
helpers to build the structs in the right form.
   )NotebookNode   znbformat.v4.schema.jsonNc             C   s   ddl m} || |tdS )zvalidate a v4 noder   )validate)refversion) r   nbformat)Znoder   r    r	   1lib/python3.7/site-packages/nbformat/v4/nbbase.pyr      s    r   c             K   s^   t | d}| dkr d|_d|_n| dkr8t  |_t  |_|| |dk	rP||_t||  |S )zGCreate a new output, to go in the ``cell.outputs`` list of a code cell.)output_typestreamstdoutr   >   execute_resultdisplay_dataN)r   nametextmetadatadata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rt ||d |d |d dS td| dS )zCreate 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   execution_count)r   r   r   r   r   r   r   )r   r   r   r   )r   r   r   errorenameevalue	traceback)r   r   r   r   z Unrecognized output msg type: %rN)r   
ValueError)msgr   r   r	   r	   r
   output_from_msg.   s*    r"   r   c             K   s,   t dt  d| g d}|| t|d |S )zCreate a new code cellcodeN)	cell_typer   r   sourceZoutputsZ	code_cell)r   r   r   )r%   r   cellr	   r	   r
   new_code_cellY   s    

r'   c             K   s(   t d| t  d}|| t|d |S )zCreate a new markdown cellZmarkdown)r$   r%   r   Zmarkdown_cell)r   r   r   )r%   r   r&   r	   r	   r
   new_markdown_cellg   s    


r(   c             K   s(   t d| t  d}|| t|d |S )zCreate a new raw cellraw)r$   r%   r   Zraw_cell)r   r   r   )r%   r   r&   r	   r	   r
   new_raw_cells   s    


r*   c              K   s(   t ttt  g d}||  t| |S )zCreate a new notebook)r   nbformat_minorr   Zcells)r   r   r+   r   r   )r   Znbr	   r	   r
   new_notebook   s    
r,   )N)N)r   )r   )r   )__doc__Znotebooknoder   r   r+   Znbformat_schemar   r   r"   r'   r(   r*   r,   r	   r	   r	   r
   <module>   s   

+


