a
    ø£Beõ  ã                   @   s2   d Z ddl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_notebookÚnew_text_cellÚnew_worksheetc                 C   sŒ   |dkr|t ƒ }tƒ }| jD ]P}|jdkrBt| d¡| d¡d�}n|jdkr^td| d¡d�}|j |¡ q|j |¡ |S t	d| ƒ‚d	S )
zèConvert 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   ÚtextÚmarkdown)Úsourcez(Cannot convert a notebook from v%s to v2N)
r   r   ÚcellsZ	cell_typer   Úgetr   ÚappendZ
worksheetsÚ
ValueError)ÚnbZfrom_versionZnewnbÚwsÚcellZnewcell© r   úV/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/nbformat/v2/convert.pyÚupgrade   s    


ÿ
r   c                 C   s   d}t |ƒ‚dS )z”Convert 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   Úmsgr   r   r   Ú	downgrade6   s    r   N)r   )Ú__doc__Znbbaser   r   r   r   r   r   r   r   r   r   Ú<module>   s   
