U
    kuf¯
  ã                   @  s   d Z ddlmZ ddlZddlmZmZ ddlmZm	Z	m
Z
mZmZmZmZmZ ddlmZ ddlmZ ddlmZ dd	lmZ dd	lmZ ddlmZ ddlmZ ddlmZ dd	lmZ dd	lmZ ddlmZ  ddlmZ! ddlmZ" d
Z#dZ$dd„ Z%dS )zDThe main API for the v2 notebook format.

Authors:

* Brian Granger
é    )ÚannotationsNé   )Ú	downgradeÚupgrade)ÚNotebookNodeÚ
new_authorÚnew_code_cellÚnew_metadataÚnew_notebookÚ
new_outputÚnew_text_cellÚnew_worksheet)Úreads)Úto_notebook)Úwritesé   c                 C  sF   t j | ¡\}}|dkrd}n|dkr,d}n| }| d } d}| ||fS )a÷  Parse a notebook filename.

    This function takes a notebook filename and returns the notebook
    format (json/py) and the notebook name. This logic can be
    summarized as follows:

    * notebook.ipynb -> (notebook.ipynb, notebook, json)
    * notebook.json  -> (notebook.json, notebook, json)
    * notebook.py    -> (notebook.py, notebook, py)
    * notebook       -> (notebook.ipynb, notebook, json)

    Parameters
    ----------
    fname : unicode
        The notebook filename. The filename can use a specific filename
        extension (.ipynb, .json, .py) or none, in which case .ipynb will
        be assumed.

    Returns
    -------
    (fname, name, format) : (unicode, unicode, unicode)
        The filename, notebook name and format.
    )ú.ipynbz.jsonÚjsonz.pyÚpyr   )ÚosÚpathÚsplitext)ÚfnameÚbasenameÚextZformat_© r   ú8/tmp/pip-unpacked-wheel-zj9qk9v2/nbformat/v2/__init__.pyÚparse_filename9   s    r   )&Ú__doc__Ú
__future__r   r   Úconvertr   r   Znbbaser   r   r   r	   r
   r   r   r   Znbjsonr   Ú	read_jsonZ
reads_jsonr   Zto_notebook_jsonr   Ú
write_jsonZwrites_jsonZnbpyZread_pyZreads_pyZto_notebook_pyZwrite_pyZ	writes_pyZnbxmlZread_xmlZ	reads_xmlZto_notebook_xmlZnbformatZnbformat_minorr   r   r   r   r   Ú<module>   s(   (
