
    f                    :    d Z ddlmZ ddlmZmZmZmZ ddZd Z	y)	zhCode for converting notebooks to and from the v2 format.

Authors:

* Brian Granger
* Jonathan Frederic
    )annotations   )new_code_cellnew_notebooknew_text_cellnew_worksheetc                   |dk(  rt               }t               }| j                  D ]  }|j                  dk(  r,t	        |j                  d      |j                  d            }n+|j                  dk(  rt        d|j                  d            }|j                  j                          |j                  j                  |       |S t        d|z        )	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   textmarkdown)sourcez(Cannot convert a notebook from v%s to v2)
r   r   cells	cell_typer   getr   append
worksheets
ValueError)nbfrom_versionnewnbwscellnewcells         N/var/www/cvtools/html/venv/lib/python3.12/site-packages/nbformat/v2/convert.pyupgrader      s     q_HH 	%D~~''((6*$((?:S 6)'
488F;KLHHOOG$	% 	#
?,N
OO    c                    d}t        |      )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.)	Exception)r   msgs     r   	downgrader"   7   s     ?C
C.r   N)r   )
__doc__
__future__r   nbbaser   r   r   r   r   r"    r   r   <module>r'      s    $ # M MP6	r   