U
    kuf                     @  s   d Z ddlm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 )$zPython 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.
    )annotations)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   6/tmp/pip-unpacked-wheel-zj9qk9v2/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k	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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   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_msgI   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    

r4   c                 K  s,   t t d| t  d}|| t|d |S )zCreate a new markdown cellZmarkdownr,   r-   r.   r   Zmarkdown_cellr0   r2   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_cellr0   r2   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__
__future__r   Znbformat.corpus.wordsr   r1   Znbformat.notebooknoder   r   r9   Znbformat_schemar
   r$   r*   r4   r6   r8   r<   r   r   r   r   <module>   s(   


,


