B
    '=[                 @   s(   d Z ddlmZ ddlmZ dd ZdS )z.API for converting notebooks between versions.   )versions)get_versionc             C   s   t | \}}||kr| S |tkr||kr<|d }t| j}n|d }t| j}|| }|dd|krvtd||f t||S td| dS )a  Convert a notebook node object to a specific version.  Assumes that
    all the versions starting from 1 to the latest major X are implemented.
    In other words, there should never be a case where v1 v2 v3 v5 exist without
    a v4.  Also assumes that all conversions can be made in one step increments
    between major versions and ignores minor revisions.

    Parameters
    ----------
    nb : NotebookNode
    to_version : int
        Major revision to convert the notebook to.  Can either be an upgrade or
        a downgrade.
    r   Znbformatz+Failed to convert notebook from v%d to v%d.zACannot convert notebook to v%d because that version doesn't existN)r   r   ZupgradeZ	downgradeget
ValueErrorconvert)ZnbZ
to_versionversionZversion_minorZstep_versionZconvert_functionZ	converted r   1lib/python3.7/site-packages/nbformat/converter.pyr   
   s    

r   N)__doc__ r   readerr   r   r   r   r   r	   <module>   s   