
    ^hM2                        S r SSKJr  SSKrSSKrSSKrSSKrSSKrSSKr	SSK
r
SSK
JrJr  SSKJrJrJrJrJr  SSKJr  SSKJr  SSKJr   " S	 S
\R2                  5      r " S S\5      r " S S\5      rg)zeThis module defines a base Exporter class. For Jinja template-based export,
see templateexporter.py.
    )annotationsN)NotebookNode	validator)Bool	HasTraitsList
TraitErrorUnicodeConfig)LoggingConfigurable)import_itemc                      \ rS rSrSrS rSrg)ResourcesDict   zA default dict for resources.c                    g)zHandle missing value.  )selfkeys     V/home/james-whalen/.local/lib/python3.13/site-packages/nbconvert/exporters/exporter.py__missing__ResourcesDict.__missing__   s        r   N)__name__
__module____qualname____firstlineno____doc__r   __static_attributes__r   r   r   r   r      s
    'r   r   c                  4   ^  \ rS rSrSrSrSrU 4S jrSrU =r	$ )FilenameExtension    z A trait for filename extensions.r   z*a filename extension, beginning with a dotc                   > [         TU ]  X5      nU(       a=  UR                  S5      (       d'  Sn[        UR	                  U R
                  U5      5      eU$ )zValidate the file name..z8FileExtension trait '{}' does not begin with a dot: {!r})supervalidate
startswithr	   formatname)r   objvaluemsg	__class__s       r   r'   FilenameExtension.validate&   sM      , ))#..LCSZZ		59::r   r   )
r   r   r   r   r   default_value	info_textr'   r    __classcell__r.   s   @r   r"   r"       s    *M<I
 
r   r"   c                    ^  \ rS rSr% Sr\" SSS9R                  SS9r\" SS9R                  SS9r	\" SS	S9R                  SS9r
S
rSrS\S'   \" SS9R                  SS9rS\S'   \" 5       rS\S'   \" / SQSS9R                  SS9rS\S'   S U 4S jjr\S 5       r S        S!S jjr S        S"S jjr S        S#S jjrS$S jrS rS rS rS rSrU =r$ )%Exporter3   z
Class containing methods that sequentially run a list of preprocessors on a
NotebookNode object and then return the modified NotebookNode object and
accompanying resources dict.
Tz<Disable this exporter (and any exporters inherited from it).)help)configz4Extension of the file that should be written to diskFz^Reduces the number of validation steps so that it only occurs after all preprocesors have run.r   Nstrexport_from_notebookz7List of preprocessors, by name or namespace, to enable.zList[t.Any]preprocessors_preprocessors)z-nbconvert.preprocessors.TagRemovePreprocessorz/nbconvert.preprocessors.RegexRemovePreprocessorz/nbconvert.preprocessors.ClearOutputPreprocessorz3nbconvert.preprocessors.CoalesceStreamsPreprocessorz+nbconvert.preprocessors.ExecutePreprocessorz+nbconvert.preprocessors.SVG2PDFPreprocessorz)nbconvert.preprocessors.LatexPreprocessorz3nbconvert.preprocessors.HighlightMagicsPreprocessorz1nbconvert.preprocessors.ExtractOutputPreprocessorz6nbconvert.preprocessors.ExtractAttachmentsPreprocessorz1nbconvert.preprocessors.ClearMetadataPreprocessorzZList of preprocessors available by default, by name, namespace,
        instance, or type.default_preprocessorsc                   > U R                   nU(       a  UR                  U5        [        TU ]  " SSU0UD6  U R	                  5         0 U l        g)z
Public constructor

Parameters
----------
config : ``traitlets.config.Config``
    User configuration instance.
`**kw`
    Additional keyword arguments passed to parent __init__

r8   Nr   )default_configmerger&   __init___init_preprocessors_nb_metadata)r   r8   kwwith_default_configr.   s       r   rA   Exporter.__init__i   sL     #11%%f-: 3:r:  "r   c                    [        5       $ Nr   )r   s    r   r?   Exporter.default_config~   s	    xr   c                   [         R                  " U5      nU R                  U5      nSUS   ;   a  US   S   R                  5       US'   U R	                  XB5      u  pBSnUbc  UR                  S0 5      R                  SS5      nUR                  S0 5      R                  SS5      n[        R                  R                  Xv5      nUR                  U R                  U'   XB4$ )a  
Convert a notebook from a notebook node instance.

Parameters
----------
nb : :class:`~nbformat.NotebookNode`
    Notebook node (dict-like with attr-access)
resources : dict
    Additional resources that can be accessed read/write by
    preprocessors and filters.
`**kw`
    Ignored

languagemetadatar   r*   path)copydeepcopy_init_resourceslower_preprocessgetosrM   joinrL   rC   )r   nb	resourcesrD   nb_copynotebook_namer*   rM   s           r   from_notebook_nodeExporter.from_notebook_node   s    " --#((3	J'$&zN:$>$D$D$FIj! "--gA ==R044VR@D==R044VR@DGGLL4M+2+;+;-(!!r   c                p   Uc
  [        5       nSU;  d	  US   S:X  a  [        5       US'   [        R                  R                  U5      u  pE[        R                  R	                  U5      S   nXbS   S'   XBS   S'   [
        R
                  R                  [        R                  R                  U5      [
        R                  R                  S9n[        R                  S:X  a  S	nOS
nUR                  U5      US   S'   [        USS9 n	U R                  " U	4SU0UD6sSSS5        $ ! , (       d  f       g= f)a  
Convert a notebook from a notebook file.

Parameters
----------
filename : str
    Full filename of the notebook file to open and convert.
resources : dict
    Additional resources that can be accessed read/write by
    preprocessors and filters.
`**kw`
    Ignored

NrL   r   r   r*   rM   )tzwin32z	%B %d, %Yz
%B %-d, %Ymodified_datezutf-8)encodingrW   )r   rT   rM   splitsplitextdatetimefromtimestampgetmtimetimezoneutcsysplatformstrftimeopen	from_file)
r   filenamerW   rD   rM   basenamerY   r_   date_formatfs
             r   from_filenameExporter.from_filename   s   $ %IY&)J*?2*E$1OIj!x0((215(5*f%(,*f% ))77GGX&8+<+<+@+@ 8 
 <<7"%K&K1>1G1G1T	*o.(W->>!?y?B? .--s   D''
D5c                R    U R                   " [        R                  " USS94SU0UD6$ )a
  
Convert a notebook from a notebook file.

Parameters
----------
file_stream : file-like object
    Notebook file-like object to convert.
resources : dict
    Additional resources that can be accessed read/write by
    preprocessors and filters.
`**kw`
    Ignored

   )
as_versionrW   )rZ   nbformatread)r   file_streamrW   rD   s       r   rl   Exporter.from_file   s5    " &&MM+!4
@I
MO
 	
r   c                   Uc  Sn[        U5      e[        U[        5      nU(       + nU(       a1  [        U[        5      (       a  [	        U5      nU R                  Xb5      $ U(       a;  [        U5      (       a+  U(       a  SUl        U R                  R                  U5        U$ U(       a,  [        U[        5      (       a  U R                  U" U S9U5        gU(       a  U R                  U" 5       U5        g[        SU-  5      e)a  
Register a preprocessor.
Preprocessors are classes that act upon the notebook before it is
passed into the Jinja templating engine. Preprocessors are also
capable of passing additional information to the Jinja
templating engine.

Parameters
----------
preprocessor : `nbconvert.preprocessors.Preprocessor`
    A dotted module name, a type, or an instance
enabled : bool
    Mark the preprocessor as enabled

Nzpreprocessor must not be NoneT)parentzBpreprocessor must be callable or an importable constructor, got %r)	TypeError
isinstancetyper9   r   register_preprocessorcallableenabledr<   append
issubclassr   )r   preprocessorr   r-   isclassconstructedpreprocessor_clss          r   r   Exporter.register_preprocessor   s      1CC. \40!k :
 
  +<8--.>HH8L11 '+$&&|4z,	:: &&|4'@'J&&|~w? PS__
 	
r   c                    / U l         U R                   H  nU R                  U5        M     U R                   H  nU R                  USS9  M     g)zc
Register all of the preprocessors needed for this exporter, disabled
unless specified explicitly.
T)r   N)r<   r=   r   r;   )r   r   s     r   rB   Exporter._init_preprocessors  sQ    
 ! !66L&&|4 7 !..L&&|T&B /r   c                h   Uc
  [        5       n[        U[         5      (       d  [        5       nUR                  U5        UnSU;   a;  [        US   [         5      (       d"  [        5       nUR                  US   5        X1S'   O"[        5       US'   US   S   (       d  SUS   S'   U R                  US'   U$ )NrL   r*   Notebookoutput_extension)r   r}   updatefile_extension)r   rW   new_resourcesnew_metadatas       r   rP   Exporter._init_resources(  s    %I)]33)OM  +%I "i
3]CC,##Ij$9:(4*%$1OIj!Z(00:	*%f- )-(;(;	$%r   c                     [         R                  " USS9  g ! [         R                   a    U R                  R	                  SU5        e f = f)NT)relax_add_propsz)Notebook is invalid after preprocessor %s)rv   r'   ValidationErrorlogerror)r   nbcr   s      r   _validate_preprocessorExporter._validate_preprocessor@  sB    	c48'' 	HHNNFU	s	    2A
c                   [         R                  " U5      n[         R                  " U5      n[        [        S5      (       a  [        R                  " U5      u  pSU R
                   H1  nU" X45      u  p4U R                  (       a  M   U R                  X65        M3     U R                  (       a  U R                  UW5        X44$ )a  
Preprocess the notebook before passing it into the Jinja engine.
To preprocess the notebook is to successively apply all the
enabled preprocessors. Output from each preprocessor is passed
along to the next one.

Parameters
----------
nb : notebook node
    notebook that is being exported.
resources : a dict of additional resources that
    can be accessed read/write by preprocessors
	normalize)rN   rO   hasattrr   r   r<   optimistic_validationr   )r   rV   rW   r   resc_r   s          r   rR   Exporter._preprocessG  s    " mmB}}Y'9k**((-FA !//L$S/IC---++C> 0
 %%''\:yr   )rC   r<   rH   )rV   r   rW   zt.Any | NonerD   t.Anyreturn%tuple[NotebookNode, dict[str, t.Any]])rm   r9   rW   dict[str, t.Any] | NonerD   r   r   r   )rx   r   rW   r   rD   r   r   r   )F)r   r   r   r   r   r   tagr   r"   r   r   output_mimetyper:   __annotations__r   r;   r<   r=   rA   propertyr?   rZ   rq   rl   r   rB   rP   r   rR   r    r2   r3   s   @r   r5   r5   3   s    4\]aa b G 'C	cc  !m 
cc  O !%#$ "&J"	cc ;  #'&NK()-	
*  
cc! ; $*   ;?""+7"FK"	."D CG&@&@(?&@NS&@	.&@R HL
 
-D
SX
	.
*7
rC0! !r   r5   )r   
__future__r   collectionsrN   rc   rT   rh   typingtrv   r   r   	traitletsr   r   r   r	   r
   traitlets.configr   traitlets.config.configurabler   traitlets.utils.importstringr   defaultdictr   r"   r5   r   r   r   <module>r      sc    #    	 
   , @ @ # = 4K++  &u" ur   