B
    '=[                 @   s6   d Z ddlmZmZmZmZmZ dddZdd ZdS )	zhCode for converting notebooks to and from the v2 format.

Authors:

* Brian Granger
* Jonathan Frederic
   )new_code_cellnew_text_cellnew_worksheetnew_notebook
new_outputc             C   s   |dkrt  }t }xZ| jD ]P}|jdkrDt|d|dd}n|jdkr`td|dd}|j| qW |j| |S t	d| d	S )
zConvert a notebook to the v2 format.

    Parameters
    ----------
    nb : NotebookNode
        The Python representation of the notebook to convert.
    from_version : int
        The version of the notebook to convert from.
    r   codeprompt_number)inputr   textZmarkdown)sourcez(Cannot convert a notebook from v%s to v2N)
r   r   ZcellsZ	cell_typer   getr   appendZ
worksheets
ValueError)nbZfrom_versionZnewnbZwsZcellZnewcell r   2lib/python3.7/site-packages/nbformat/v2/convert.pyupgrade   s    


r   c             C   s   t ddS )zConvert a v2 notebook to v1.

    Parameters
    ----------
    nb : NotebookNode
        The Python representation of the notebook to convert.
    z2Downgrade from notebook v2 to v1 is not supported.N)	Exception)r   r   r   r   	downgrade5   s    r   N)r   )	__doc__Znbbaser   r   r   r   r   r   r   r   r   r   r   <module>   s   
