ó
§‰]c           @   s¸   d  Z  d d l Z d d l 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
 d d d g Z d e f d „  ƒ  YZ d „  Z d „  Z d „  Z d S(   s/   Module containing single call export functions.iÿÿÿÿN(   t
   get_logger(   t   import_item(   t   NotebookNode(   t   string_typesi   (   t   Exportert   exportR   t   get_exportert   get_export_namest   ExporterNameErrorc           B   s   e  Z RS(    (   t   __name__t
   __module__(    (    (    s7   lib/python2.7/site-packages/nbconvert/exporters/base.pyR       s   c         K   s  |  d k r t d ƒ ‚ n/ t |  t ƒ rJ t |  t ƒ rJ t d ƒ ‚ n  | d k re t d ƒ ‚ n  | j d d ƒ } t |  t ƒ r |  } n |  |   } t | t ƒ rÅ | j | | ƒ \ } } nB t | t ƒ rï | j	 | | ƒ \ } } n | j
 | | ƒ \ } } | | f S(   s¢  
    Export a notebook object using specific exporter class.
    
    Parameters
    ----------
    exporter : :class:`~nbconvert.exporters.exporter.Exporter` class or instance
      Class or instance of the exporter that should be used.  If the
      method initializes its own instance of the class, it is ASSUMED that
      the class type provided exposes a constructor (``__init__``) with the same
      signature as the base Exporter class.
    nb : :class:`~nbformat.NotebookNode`
        The notebook to export.
    config : config (optional, keyword arg)
        User configuration instance.
    resources : dict (optional, keyword arg)
        Resources used in the conversion process.

    Returns
    -------
    tuple
        output : str
            The resulting converted notebook.
        resources : dictionary
            Dictionary of resources used prior to and during the conversion 
            process.
    s   Exporter is Nones.   exporter does not inherit from Exporter (base)s
   nb is Nonet	   resourcesN(   t   Nonet	   TypeErrort
   isinstanceR   t
   issubclasst   popR   t   from_notebook_nodeR   t   from_filenamet	   from_file(   t   exportert   nbt   kwR   t   exporter_instancet   output(    (    s7   lib/python2.7/site-packages/nbconvert/exporters/base.pyR   #   s      	c         C   sô   |  d k r d }  n  y t  j d |  ƒ j ƒ  SWnK t  j k
 r| y  t  j d |  j ƒ  ƒ j ƒ  SWq} t  j k
 rx q} Xn Xd |  k rÎ y t |  ƒ SWqÎ t k
 rÊ t ƒ  } | j d |  d t	 ƒqÎ Xn  t
 d |  d j t ƒ  ƒ f ƒ ‚ d	 S(
   s‡   Given an exporter name or import path, return a class ready to be instantiated
    
    Raises ValueError if exporter is not found
    t   ipynbt   notebooks   nbconvert.exporterst   .s   Error importing %st   exc_infos/   Unknown exporter "%s", did you mean one of: %s?s   , N(   t   entrypointst
   get_singlet   loadt   NoSuchEntryPointt   lowerR   t   ImportErrorR    t   errort   Truet
   ValueErrort   joinR   (   t   namet   log(    (    s7   lib/python2.7/site-packages/nbconvert/exporters/base.pyR   X   s"    	 	c           C   s   t  t j d ƒ ƒ S(   s®   Return a list of the currently supported export targets
    
    Exporters can be found in external packages by registering
    them as an nbconvert.exporter entrypoint.
    s   nbconvert.exporters(   t   sortedR   t   get_group_named(    (    (    s7   lib/python2.7/site-packages/nbconvert/exporters/base.pyR   t   s    (   t   __doc__t   warningsR   t   traitlets.logR    t   traitlets.utils.importstringR   t   nbformatR   t   ipython_genutils.py3compatR   R   R   t   __all__t	   NameErrorR   R   R   R   (    (    (    s7   lib/python2.7/site-packages/nbconvert/exporters/base.pyt   <module>   s    		5	