ó
‹'=[c           @  sî  d  Z  d d l m Z d d l Z d d l Z e j d ƒ d d l m Z m Z m	 Z	 m
 Z
 m Z m Z 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 m  Z  d d l! m" Z" d d d d d d d d d d d d d d d d d d d d  d! d" d# d$ d% d& g Z# e Z$ e Z% e j& Z' d e( f d' „  ƒ  YZ) d( „  Z* d) „  Z+ d* „  Z, d+ „  Z- d, „  Z. d- „  Z/ d. e$ d/ „ Z d. e$ d0 „ Z0 d. d1 „ Z1 d. d2 „ Z2 d S(3   sŸ   Deprecated API for working with notebooks

- use nbformat for read/write/validate public API
- use nbformat.vX directly for Python API for composing notebooks
iÿÿÿÿ(   t   print_functionNs   nbformat.current is deprecated.

- use nbformat for read/write/validate public API
- use nbformat.vX directly to composing notebooks of a particular version
(   t   NotebookNodet   new_code_cellt   new_text_cellt   new_notebookt
   new_outputt   new_worksheett   parse_filenamet   new_metadatat
   new_authort   new_heading_cellt   nbformatt   nbformat_minort   nbformat_schemat   to_notebook_json(   t   v3i   (   t   reads(   t   versions(   t   convert(   t   validatet   ValidationError(   t
   get_loggerR   R   R   R   R   R   R   R   R	   R
   R   R   R   R   R   R   t   NBFormatErrort   parse_pyt
   reads_jsont   writes_jsont   reads_pyt	   writes_pyR   t   writest   readt   writec           B  s   e  Z RS(    (   t   __name__t
   __module__(    (    (    s/   lib/python2.7/site-packages/nbformat/current.pyR   0   s   c           C  s   t  j d ƒ d  S(   Nsd   Non-JSON file support in nbformat is deprecated.
    Use nbconvert to create files of other formats.(   t   warningst   warn(    (    (    s/   lib/python2.7/site-packages/nbformat/current.pyt   _warn_format4   s    c         K  s   t  } t } d } t j | |  ƒ } | d k	 r€ | j d ƒ j d ƒ } t | d ƒ } t | ƒ d k r€ t | d ƒ } q€ n  | | |  f S(   s/   Parse a string into a (nbformat, string) tuple.s0   # <nbformat>(?P<nbformat>\d+[\.\d+]*)</nbformat>R   t   .i    i   N(	   t   current_nbformatt   current_nbformat_minort   ret   searcht   Nonet   groupt   splitt   intt   len(   t   st   kwargst   nbft   nbmt   patternt   mt   digits(    (    s/   lib/python2.7/site-packages/nbformat/current.pyR   9   s    c         K  s   t  j d ƒ t |  ƒ S(   s   DEPRECATED, use readss#   reads_json is deprecated, use reads(   R!   R"   R   (   t   nbjsonR/   (    (    s/   lib/python2.7/site-packages/nbformat/current.pyR   I   s    c         K  s   t  j d ƒ t |  |  S(   s   DEPRECATED, use writess%   writes_json is deprecated, use writes(   R!   R"   R   (   t   nbR/   (    (    s/   lib/python2.7/site-packages/nbformat/current.pyR   N   s    c         K  sX   t  ƒ  t |  |  \ } } }  | d k rD t | j |  |  } n t d | ƒ ‚ | S(   s   DEPRECATED: use nbconverti   i   s#   Unsupported PY nbformat version: %i(   i   i   (   R#   R   R   t   to_notebook_pyR   (   R.   R/   R0   R1   R6   (    (    s/   lib/python2.7/site-packages/nbformat/current.pyR   S   s    c         K  s   t  ƒ  t d j |  |  S(   s   DEPRECATED: use nbconverti   (   R#   R   R   (   R6   R/   (    (    s/   lib/python2.7/site-packages/nbformat/current.pyR   ]   s    t
   DEPRECATEDc         K  su   | d d h k r t  ƒ  n  t |  |  } t | | ƒ } y t | ƒ Wn& t k
 rp } t ƒ  j d | ƒ n X| S(   sŠ  Read a notebook from a string and return the NotebookNode object.

    This function properly handles notebooks of any version. The notebook
    returned will always be in the current version's format.

    Parameters
    ----------
    s : unicode
        The raw unicode string to read the notebook from.

    Returns
    -------
    nb : NotebookNode
        The notebook that was read.
    R8   t   jsons   Notebook JSON is invalid: %s(   R#   t   reader_readsR   R   R   R   t   error(   R.   t   formatt   versionR/   R6   t   e(    (    s/   lib/python2.7/site-packages/nbformat/current.pyR   f   s    
c         K  sv   | d d h k r t  ƒ  n  t |  | ƒ }  y t |  ƒ Wn& t k
 ra } t ƒ  j d | ƒ n Xt | j |  |  S(   sž  Write a notebook to a string in a given format in the current nbformat version.

    This function always writes the notebook in the current nbformat version.

    Parameters
    ----------
    nb : NotebookNode
        The notebook to write.
    version : int
        The nbformat version to write.
        Used for downgrading notebooks.

    Returns
    -------
    s : unicode
        The notebook string.
    R8   R9   s   Notebook JSON is invalid: %s(   R#   R   R   R   R   R;   R   R   (   R6   R<   R=   R/   R>   (    (    s/   lib/python2.7/site-packages/nbformat/current.pyR      s    
c         K  s   t  |  j ƒ  |  S(   s}  Read a notebook from a file and return the NotebookNode object.

    This function properly handles notebooks of any version. The notebook
    returned will always be in the current version's format.

    Parameters
    ----------
    fp : file
        Any file-like object with a read method.

    Returns
    -------
    nb : NotebookNode
        The notebook that was read.
    (   R   R   (   t   fpR<   R/   (    (    s/   lib/python2.7/site-packages/nbformat/current.pyR      s    c         K  s=   t  |  |  } t | t ƒ r0 | j d ƒ } n  | j | ƒ S(   s5  Write a notebook to a file in a given format in the current nbformat version.

    This function always writes the notebook in the current nbformat version.

    Parameters
    ----------
    nb : NotebookNode
        The notebook to write.
    fp : file
        Any file-like object with a write method.
    t   utf8(   R   t
   isinstancet   bytest   decodeR   (   R6   R?   R<   R/   R.   (    (    s/   lib/python2.7/site-packages/nbformat/current.pyR   °   s    (3   t   __doc__t
   __future__R    R'   R!   R"   t   nbformat.v3R   R   R   R   R   R   R   R   R	   R
   R   R   R   R   R   t	   _v_latestt   readerR   R:   t    R   t	   converterR   t	   validatorR   R   t   traitlets.logR   t   __all__R%   R&   R   t   current_nbformat_modulet
   ValueErrorR   R#   R   R   R   R   R   R   R   R   (    (    (    s/   lib/python2.7/site-packages/nbformat/current.pyt   <module>   s@   ^							
		