
    :Mc;                     V    d Z ddlZddlmZmZ ddlmZ ddlmZ  G d de          Z	dS )	z5Generic script exporter class for any kernel language    N)Dictdefault   )get_exporter)TemplateExporterc                        e Zd Z e            Z e            ZdZ ed          d             Z ed          d             Z	d Z
d	 fd	Z xZS )
ScriptExporterScripttemplate_filec                     dS )Nz	script.j2 selfs    :lib/python3.11/site-packages/nbconvert/exporters/script.py_template_file_defaultz%ScriptExporter._template_file_default   s    {    template_namec                     dS )Nscriptr   r   s    r   _template_name_defaultz%ScriptExporter._template_name_default   s    xr   c                     || j         vrb	 t          j        d|                                          } || j        |           | j         |<   n# t          j        $ r d| j         |<   Y nw xY w| j         |         S )zFind an exporter for the language name from notebook metadata.

        Uses the nbconvert.exporters.script group of entry points.
        Returns None if no exporter is found.
        znbconvert.exporters.scriptconfigparentN)_lang_exportersentrypoints
get_singleloadr   NoSuchEntryPoint)r   	lang_nameExporters      r   _get_language_exporterz%ScriptExporter._get_language_exporter   s     D00 	\\&12NPYZZ__aa
 3;($+VZ2[2[2[$Y//	 / 7 7 726$Y///7
 #I..s   'A A)(A)Nc                    |j                             di           }|                    d          }|ro|dk    ri| j                            d|           || j        vr)t          |          } || j        |           | j        |<   | j        |         } |j        ||fi |S |                    d          }|rA| j                            d|           |                     |          }| |j        ||fi |S |                    dd	          | _	        |                    d
d          | _
         t                      j        ||fi |S )Nlanguage_infonbconvert_exporterr   zLoading script exporter: %sr   namez&Using script exporter for language: %sfile_extensionz.txtmimetypez
text/plain)metadatagetlogdebug
_exportersr   r   from_notebook_noder"   r'   output_mimetypesuper)
r   nb	resourceskwlanginfoexporter_namer!   exporterr    	__class__s
            r   r.   z!ScriptExporter.from_notebook_node+   sy   ;???B77 !%9:: 	D]h6 	DHNN8-HHHDO3 ['6619UY1Z1Z1Z.}5H.8.r9CCCCC LL((	 	HHNNCYOOO229==H H2x22yGGBGGG 'll+;VDD'||JEE)uww)"i>>2>>>r   )N)__name__
__module____qualname__r   r-   r   export_from_notebookr   r   r   r"   r.   __classcell__)r7   s   @r   r	   r	      s        JdffO#W_   W_  / / / ? ? ? ? ? ? ? ? ? ?r   r	   )
__doc__r   	traitletsr   r   baser   templateexporterr   r	   r   r   r   <module>rA      s    ; ;
     # # # # # # # #       . . . . . .7? 7? 7? 7? 7?% 7? 7? 7? 7? 7?r   