B
    Z[¿  ã               @   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G dd„ deƒZdd	„ Zdd„ Zdd„ ZdS )z/Module containing single call export functions.é    N)Ú
get_logger)Úimport_item)ÚNotebookNode)Ústring_typesé   )ÚExporterÚexportr   Úget_exporterÚget_export_namesÚExporterNameErrorc               @   s   e Zd ZdS )r   N)Ú__name__Ú
__module__Ú__qualname__© r   r   ú7lib/python3.7/site-packages/nbconvert/exporters/base.pyr       s   c             K   s´   | dkrt dƒ‚nt| tƒs.t| tƒs.t dƒ‚|dkr>t dƒ‚| dd¡}t| tƒrZ| }n
| f |Ž}t|tƒr€| ||¡\}}n,t|tƒrœ| ||¡\}}n| 	||¡\}}||fS )a¢  
    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.
    NzExporter is Nonez.exporter does not inherit from Exporter (base)z
nb is NoneÚ	resources)
Ú	TypeErrorÚ
isinstancer   Ú
issubclassÚpopr   Zfrom_notebook_noder   Zfrom_filenameZ	from_file)ÚexporterZnbÚkwr   Zexporter_instanceÚoutputr   r   r   r   #   s     




c             C   sº   | dkrd} yt  d| ¡ ¡ S  t jk
r^   yt  d|  ¡ ¡ ¡ S  t jk
rX   Y nX Y nX d| kržyt| ƒS  tk
rœ   tƒ }|jd|  dd Y nX t	d| d	 
tƒ ¡f ƒ‚d
S )z‡Given an exporter name or import path, return a class ready to be instantiated
    
    Raises ValueError if exporter is not found
    ZipynbZnotebookznbconvert.exportersÚ.zError importing %sT)Úexc_infoz/Unknown exporter "%s", did you mean one of: %s?z, N)ÚentrypointsZ
get_singleÚloadZNoSuchEntryPointÚlowerr   ÚImportErrorr   ÚerrorÚ
ValueErrorÚjoinr
   )ÚnameÚlogr   r   r   r	   X   s"    c               C   s   t t d¡ƒS )z®Return a list of the currently supported export targets
    
    Exporters can be found in external packages by registering
    them as an nbconvert.exporter entrypoint.
    znbconvert.exporters)Úsortedr   Zget_group_namedr   r   r   r   r
   t   s    )Ú__doc__Úwarningsr   Ztraitlets.logr   Ztraitlets.utils.importstringr   Znbformatr   Zipython_genutils.py3compatr   r   r   Ú__all__Ú	NameErrorr   r   r	   r
   r   r   r   r   Ú<module>   s    5