
    Fh`                       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
JrJr  SSKJrJrJr  SSKJrJrJrJrJrJrJrJr  SSKJrJr  SSK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(J)r)  SSK*J+r+  SSK,J-r-  SSK.J/r/   " S S\5      r00 r1\1Re                  \5        \1Re                  SSSSSSSSSSSS.5        0 r3\3Re                  \5        \3Re                  SSS 00S!4SS"S 00S#4S$S%S 00S&4S$S'S(00S)4S*S+S,.S-S.0S/.S04S*S+S,.S-S.0SS 0S1.S24S*S+S,.S-S.0SS 0S3.S44S5S S S6.0S74S5S S S S8.0S94S:S;S 00S<4S:S=S 00S>4S5S?S*00S@4SASBS 00SC4SASDS 00SE4SF.5         " SG S$\5      r4 " SH SI\45      r5\4Rl                  =r7r8\5Rl                  r9g)JzuNbConvert is a utility for conversion of .ipynb files.

Command-line interface for the NbConvert conversion utility.
    )annotationsN)dedentfill)
JupyterAppbase_aliases
base_flags)BoolDottedObjectNameInstanceListTypeUnicodedefaultobserve)Configurablecatch_config_error)import_item)__version__	exporterspostprocessorspreprocessorswriters)indent   )get_export_namesget_exporter)NbConvertBase)ConversionException)unicode_stdin_streamc                  0   ^  \ rS rSrSrSrU 4S jrSrU =r$ )DottedOrNone%   zbA string holding a valid dotted object name in Python, such as A.b3._c
Also allows for None type.
 c                J   > Ub  [        U5      S:  a  [        TU ]	  X5      $ U$ )zValidate an input.r   )lensupervalidate)selfobjvalue	__class__s      iC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\nbconvert/nbconvertapp.pyr'   DottedOrNone.validate,   s(    Ua7#C//     )	__name__
__module____qualname____firstlineno____doc__default_valuer'   __static_attributes____classcell__r+   s   @r,   r!   r!   %   s     M r.   r!   zNbConvertApp.export_formatzTemplateExporter.template_namezTemplateExporter.template_filezHTMLExporter.themezHTMLExporter.sanitize_htmlzNbConvertApp.writer_classz NbConvertApp.postprocessor_classzNbConvertApp.output_basezFilesWriter.build_directoryz SlidesExporter.reveal_url_prefixz!NotebookExporter.nbformat_version)totemplateztemplate-filethemesanitize_htmlwriterpostoutputz
output-dirzreveal-prefixnbformatExecutePreprocessorenabledTz%Execute the notebook prior to export.allow_errorszContinue notebook execution even if one of the cells throws an error and include the error message in the cell output (the default behaviour is to abort conversion). This flag is only relevant if '--execute' was specified, too.NbConvertApp
from_stdinzgread a single notebook file from stdin. Write the resulting notebook with default basename 'notebook.*'writer_classStdoutWriterz1Write notebook output to stdout instead of files.Fnotebook)use_output_suffixexport_formatbuild_directoryr#   )rD   FilesWriterztRun nbconvert in place, overwriting the existing notebook (only
        relevant when converting to notebook format))rD   rL   ClearOutputPreprocessorz[Clear output of current file and save in place,
        overwriting the existing notebook. )rD   rL   CoalesceStreamsPreprocessorzRCoalesce consecutive stdout and stderr outputs into one stream (within each cell).TemplateExporter)exclude_input_promptexclude_output_promptz9Exclude input and output prompts from converted document.)rQ   exclude_inputrP   z|Exclude input cells and output prompts from converted document.
        This mode is ideal for generating code-free reports.WebPDFExporterallow_chromium_downloadzTWhether to allow downloading chromium if no suitable version is found on the system.disable_sandboxz:Disable chromium security sandbox when converting to PDF..rR   z<Shows code input. This flag is only useful for dejavu users.HTMLExporterembed_imageszoEmbed the images as base64 dataurls in the output. This flag is only useful for the HTML/WebPDF/Slides exports.r<   zIWhether the HTML in Markdown cells and cell outputs should be sanitized..)executezallow-errorsstdinstdoutinplacezclear-outputzcoalesce-streamsz	no-promptzno-inputzallow-chromium-downloadzdisable-chromium-sandboxz
show-inputzembed-imageszsanitize-htmlc                  2  ^  \ rS rSrSr\rSr\r	\
r\" S5      S 5       r\" 5       r\" S5      S 5       r\" S5      r\" S	S
S9R'                  SS9r\" SSS9R'                  SS9r\" SSS9R'                  SS9r\" S\" 5        S35      r\" SSSS9r\" SSS9R'                  SS9rSSSS.r\" SS9r \!" S5      S 5       r"\" SS SS9r#\$" S!S9R'                  SS9r%S"S#0r&\" S$SS9r'\!" S%5      S& 5       r(\" S'S(\" 5        S)3S*9R'                  SS9r)\" \" 5       S+S9R'                  SS9r*\" S'S,S9R'                  SS9r+\" S'S-S9R'                  SS9r,\-S?U 4S. jj5       r.S/ r/S0 r0S1 r1S2 r2U 4S3 jr3S4 r4S5 r5S?S6 jr6S7 r7S8 r8S?S9 jr9S: r:S; r;S< r<S= r=S>r>U =r?$ )@rD      zAApplication used to convert from notebook file type (``*.ipynb``)zjupyter-nbconvert	log_levelc                "    [         R                  $ N)loggingINFOr(   s    r,   _log_level_defaultNbConvertApp._log_level_default   s    ||r.   classesc                   [         /n[        [        [        [        4 H_  n[        U5       HM  n[        X#5      n[        U[        5      (       d  M%  [        U[        5      (       d  M<  UR                  U5        MO     Ma     U$ r`   )r   r   r   r   r   dirgetattr
isinstancetype
issubclassr   append)r(   rf   pkgnameclss        r,   _classes_defaultNbConvertApp._classes_default   sa    &3_}g~FCCc(c4((Z\-J-JNN3' ! G r.   zThis application is used to convert notebook files (*.ipynb)
        to various other formats.

        WARNING: THE COMMANDLINE INTERFACE MAY CHANGE IN FUTURE RELEASES.{notebook_name}zsOverwrite base name use for output files.
            Supports pattern replacements '{notebook_name}'.
            )helpTconfigzWhether to apply a suffix prior to the extension (only relevant
            when converting to notebook format). The suffix is determined by
            the exporter, and is usually '.nbconvert'.z{notebook_name}_fileszDirectory to copy extra files (figures) to.
               '{notebook_name}' in the string will be converted to notebook
               basename.z
        The simplest way to use nbconvert is

        > jupyter nbconvert mynotebook.ipynb --to html

        Options include aG  .

        > jupyter nbconvert --to latex mynotebook.ipynb

        Both HTML and LaTeX support multiple output templates. LaTeX includes
        'base', 'article' and 'report'.  HTML includes 'basic', 'lab' and
        'classic'. You can specify the flavor of the format used.

        > jupyter nbconvert --to html --template lab mynotebook.ipynb

        You can also pipe the output to stdout, rather than a file

        > jupyter nbconvert mynotebook.ipynb --stdout

        PDF is generated via latex

        > jupyter nbconvert mynotebook.ipynb --to pdf

        You can get (and serve) a Reveal.js-powered slideshow

        > jupyter nbconvert myslides.ipynb --to slides --post serve

        Multiple notebooks can be given at the command line in a couple of
        different ways:

        > jupyter nbconvert notebook*.ipynb
        > jupyter nbconvert notebook1.ipynb notebook2.ipynb

        or you can specify the notebooks list in a config file, containing::

            c.NbConvertApp.notebooks = ["my_notebook.ipynb"]

        > jupyter nbconvert --config mycfg.py
        z!nbconvert.writers.base.WriterBasez_Instance of the writer class used to write the
                      results of the conversion.)rt   
allow_nonerL   z\Writer class used to write the
                                    results of the conversionz#nbconvert.writers.files.FilesWriterz#nbconvert.writers.debug.DebugWriterz%nbconvert.writers.stdout.StdoutWriter)fileswriterdebugwriterstdoutwriter)rw   rF   c                    US   nUR                  5       U R                  ;   a  U R                  UR                  5          n[        U5      U l        g Nnew)lowerwriter_aliasesr   writer_factoryr(   changer}   s      r,   _writer_class_changed"NbConvertApp._writer_class_changed3  sB    Um99;$---%%ciik2C)#.r.   z/nbconvert.postprocessors.base.PostProcessorBasezfInstance of the PostProcessor class used to write the
                      results of the conversion.zcPostProcessor class used to write the
                                    results of the conversionservez1nbconvert.postprocessors.serve.ServePostProcessorNpostprocessor_classc                    US   nUR                  5       U R                  ;   a  U R                  UR                  5          nU(       a  [        U5      U l        g g r|   )r~   postprocessor_aliasesr   postprocessor_factoryr   s      r,   _postprocessor_class_changed)NbConvertApp._postprocessor_class_changedI  sJ    Um99;$444,,SYY[9C)4S)9D& r.   FzIThe export format to be used, either one of the built-in formats
        zb
        or a dotted object name that represents the import path for an
        ``Exporter`` class)rw   rt   zList of notebooks to convert.
                     Wildcards are supported.
                     Filenames passed positionally will be added to the list.
                     z"read a single notebook from stdin.z<set the 'recursive' option for glob for searching wildcards.c                  > [         R                  S:  aM  [         R                  R                  S5      (       a)  [        R
                  " [        R                  " 5       5        U R                  5         [        TU ]%  U5        [        U S5      (       a  U R                  5         U R                  5         U R                  5         U R                  5         g)z<Initialize application, notebooks, writer, and postprocessor)      winload_config_environN)sysversion_infoplatform
startswithasyncioset_event_loop_policyWindowsSelectorEventLoopPolicyinit_syspathr&   
initializehasattrr   init_notebooksinit_writerinit_postprocessorr(   argvr+   s     r,   r   NbConvertApp.initializee  s     f$)@)@)G)G))'*P*P*RS4 4.//$$&!r.   c                j    [         R                  R                  S[        R                  " 5       5        g)z)Add the cwd to the sys.path ($PYTHONPATH)r   N)r   pathinsertosgetcwdrc   s    r,   r   NbConvertApp.init_syspatht  s    299;'r.   c                   U R                   (       a  U R                   OU R                  n/ nU H  n[        R                  " X0R                  S9nUR	                  [        R                  " US-   U R                  S95        U(       d  U R
                  R                  SU5        U H  nXR;  d  M
  UR                  U5        M     M     X l        g)zConstruct the list of notebooks.

If notebooks are passed on the command-line,
they override (rather than add) notebooks specified in config files.
Glob each notebook to replace notebook patterns with filenames.
)	recursivez.ipynbzpattern %r matched no filesN)
extra_args	notebooksglobrecursive_globextendlogwarningrm   )r(   patterns	filenamespatternglobbed_filesfilenames         r,   r   NbConvertApp.init_notebooksx  s     '+oo4??4>> 	G !IIg9L9LMM  7X+=I\I\!]^   !>H),$$X. *   #r.   c                   U R                  SU R                  05        U R                  (       aS  U R                  U S9U l        [	        U R                  S5      (       a#  U R                  R
                  S:w  a  SU l        gggg)z*Initialize the writer (which is stateless)r}   parentrK   r#   FN)r   rF   r   r=   r   rK   rI   rc   s    r,   r   NbConvertApp.init_writer  ss    ""E4+<+<#=>--T-:DKt{{$5664;;;V;VZ\;\).& <]6 r.   c                    U R                  SU R                  05        U R                  (       a  U R                  U S9U l        gg)z1Initialize the postprocessor (which is stateless)r}   r   N)r   r   r   postprocessorrc   s    r,   r   NbConvertApp.init_postprocessor  s?    ))5$2J2J*KL%%!%!;!;4!;!HD &r.   c                B   > [         TU ]  5         U R                  5         g)z4Run start after initialization process has completedN)r&   startconvert_notebooks)r(   r+   s    r,   r   NbConvertApp.start  s     r.   c                    [         R                  R                  U5      nUSUR                  S5       nU R                  R                  US9nU$ )zp
Returns the notebook name from the notebook filename by
applying `output_base` pattern and stripping extension
N.notebook_name)r   r   basenamerfindoutput_baseformat)r(   notebook_filenamer   r   s       r,   _notebook_filename_to_name'NbConvertApp._notebook_filename_to_name  sN    
 77##$56 !68>>##67((//m/Lr.   c                    U R                  U5      nU R                  R                  SU5        0 nU R                  US'   X#S'   U R                  R                  US9nXCS'   U$ )a  Step 1: Initialize resources

This initializes the resources dictionary for a single notebook.

Returns
-------
dict
    resources dictionary for a single notebook that MUST include the following keys:
        - config_dir: the location of the Jupyter config directory
        - unique_key: the notebook name
        - output_files_dir: a directory where output files (not
          including the notebook itself) should be saved
zNotebook name is '%s'
config_dir
unique_keyr   output_files_dir)r   r   debugr   r   r   )r(   r   r   	resourcesr   s        r,   init_single_notebook_resources+NbConvertApp.init_single_notebook_resources  sn     778IJ.> 	"&//	,"/,0077m7T(8$%r.   c                    Ub  U R                   R                  X2S9u  pBXB4$ U R                   R                  XS9u  pB XB4$ ! [         a2    U R                  R                  SUSS9  U R                  S5         WU4$ f = f)a  Step 2: Export the notebook

Exports the notebook to a particular format according to the specified
exporter. This function returns the output and (possibly modified)
resources from the exporter.

Parameters
----------
notebook_filename : str
    name of notebook file.
resources : dict
input_buffer :
    readable file-like object returning unicode.
    if not None, notebook_filename is ignored

Returns
-------
output
dict
    resources (possibly modified)
)r   zError while converting '%s'T)exc_infor   )exporter	from_filefrom_filenamer   r   errorexit)r(   r   r   input_bufferr?   s        r,   export_single_notebook#NbConvertApp.export_single_notebook  s    ,		'$(MM$;$;L$;$^!    %)MM$?$?% %@ %!	   	 # 	HHNN8:KVZN[IIaLy  		s   A A 6A>=A>c                   SU;  a  Sn[        U5      eUS   nU R                  (       a$  U R                  S:X  a  XBR                  SS5      -  nU R                  (       d  Sn[        U5      eU R                  R                  XUS9$ )a{  Step 3: Write the notebook to file

This writes output from the exporter to file using the specified writer.
It returns the results from the writer.

Parameters
----------
output :
resources : dict
    resources for a single notebook including name, config directory
    and directory to save output

Returns
-------
file
    results from the specified writer output of exporter
r   z<unique_key MUST be specified in the resources, but it is notrs   output_suffixr#   zNo writer object defined!r   )KeyErrorrI   r   getr=   
ValueErrorwrite)r(   r?   r   msgr   s        r,   write_single_notebook"NbConvertApp.write_single_notebook  s    & y(PC3-!,/!!d&6&6:K&K]]?B??M{{-CS/!{{  - PPr.   c                n    [        U S5      (       a$  U R                  (       a  U R                  U5        ggg)zStep 4: Post-process the written file

Only used if a postprocessor has been specified. After the
converted notebook is written to a file in Step 3, this post-processes
the notebook.
r   N)r   r   )r(   write_resultss     r,   postprocess_single_notebook(NbConvertApp.postprocess_single_notebook  s0     4))d.@.@}- /A)r.   c                .   Uc'  U R                   R                  SXR                  5        O&U R                   R                  SU R                  5        U R                  U5      nU R	                  XUS9u  pCU R                  XC5      nU R                  U5        g)a  Convert a single notebook.

Performs the following steps:

    1. Initialize notebook resources
    2. Export the notebook to a particular format
    3. Write the exported notebook to file
    4. (Maybe) postprocess the written file

Parameters
----------
notebook_filename : str
input_buffer :
    If input_buffer is not None, conversion is done and the buffer is
    used as source into a file basenamed by the notebook_filename
    argument.
NzConverting notebook %s to %szConverting notebook into %sr   )r   inforJ   r   r   r   r   )r(   r   r   r   r?   r   s         r,   convert_single_notebook$NbConvertApp.convert_single_notebook  s    $ HHMM8:KM_M_`HHMM79K9KL778IJ	 77| 8 
 226E((7r.   c                   [        U R                  5      S:X  a7  U R                  (       d&  U R                  5         [        R
                  " S5        U R                  (       d  S[        5        3n[        U5      e[        U R                  5      nU" U R                  S9U l        [        U R                  SS5      (       aJ  [        R                  R                  U R                   5      u  p4X@R                  R"                  :X  a  X0l        U R                  (       d%  U R                   H  nU R%                  U5        M     g	['        5       nU R%                  SUS9  UR)                  5         g	)
z4Convert the notebooks in the self.notebooks traitletr   z[Please specify an output format with '--to <format>'.
The following formats are available: ru   file_extensionFznotebook.ipynbr   N)r%   r   rE   
print_helpr   r   rJ   r   r   r   rv   r   ri   r   r   splitextr   r   r   r   close)r(   r   rp   baseextr   r   s          r,   r   NbConvertApp.convert_notebooks9  s    t~~!#DOOOOHHRL!!::J:L9MO  S/! 4--.4;;/ 4=="2E::(()9)9:IDmm222#'  %)^^!,,->? &4 01L(()9(U r.   c           
         SnU R                   R                  5        HQ  u  nu  p4X S3-  nU[        [        US5      5      S-   -  nU[        [        S[	        U5      -   S5      5      S-   -  nMS     U$ )z;
Return a string containing descriptions of all the flags.
z"The following flags are defined:


P   z

zLong Form: )flagsitemsr   r   str)r(   r   flagcfgfhelps        r,   document_flag_helpNbConvertApp.document_flag_help\  sz     7"&**"2"2"4D,3vR[ EVDO,v55EVDS!92>?&HHE #5 r.   c                h    SnU R                   R                  5        H  u  p#USU SU S3-  nM     U$ )z-Return a string containing all of the aliasesz$The following aliases are defined:

z	**z** (z)

)aliasesr   )r(   r  aliaslongnames       r,   document_alias_help NbConvertApp.document_alias_helpg  s@     ;#||113OEeWD
%88G  4r.   c                b   S VVs0 s HC  nXR                  5        Vs/ s H$  o!UR                  R                  5       ;   d  M"  UPM&     sn_ME     nnnUR                  5        VVs1 s H  o  H  o"iM     M     nnnU R                  5        Vs/ s H  o"U;  d  M
  UPM     snUS'   [	        S5      nSnU HN  nXeR                  UR                  5       S9-  nUS;   a	  USU S3-  nUS	R                  S
 X1    5       5      -  nMP     UR                  SS5      $ s  snf s  snnf s  snnf s  snf )z
Provides a much improves version of the configuration documentation by
breaking the configuration options into app, exporter, writer,
preprocessor, postprocessor, and other sections.
)appr   r=   preprocessorr   otherzt
                        {section} Options
                        -----------------------

                        r#   )section)r   r  r=   z.. image:: _static/z_inheritance.png

r   c              3  @   #    U  H  oR                  5       v   M     g 7fr`   )class_config_rst_doc).0cs     r,   	<genexpr>7NbConvertApp.document_config_options.<locals>.<genexpr>  s     !YDXq"8"8":":DXs   z : z \: )	_classes_inc_parentsr0   r~   valuesr   r   titlejoinreplace)r(   categoryr  
categoriesaccounted_forheadersectionss          r,   document_config_options$NbConvertApp.document_config_optionso  sD    [
Z ";";"=`"=QQZZM]M]M_A_q"=``Z 	 
 ,6+<+<+>Q+>x1+>Q*.*C*C*E`*EQR_I_q*E`
7
 "Hhnn.>??HAA1(;OPP		!YJDX!YYYH	 # w//) a
 R`s.   D !DD	D &D&	D,D,D )r   r   r   r   r   rI   r=   r   r`   )@r0   r1   r2   r3   r4   r   versionro   nbconvert_aliasesr  nbconvert_flagsr   r   rd   r   rf   rq   r   descriptiontagr   r	   rI   r   r   examplesr   r=   r
   rF   r   r   r   r   r   r   r!   r   r   r   r   rJ   r   rE   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r6   r7   r8   s   @r,   rD   rD      s   KGDGE[  fGY  	MK 
 
cc  :
 
cc  
 
cc  
 *+, !-	&	(HV +4	F $A 
cc	  =<?N
 T*N^/ / 94	M 'A 
cc  %&YZ $7"#: $: 			  
cc  	 
cc  e"FGKKSWKXJR	cc  " "(#6/I!
	8!!FQ@	.8<!!F	0 0r.   c                  L   ^  \ rS rSrSrSU 4S jjr\" S5      S 5       rSrU =r	$ )	DejavuAppi  zA deja vu app.c                  > SU R                   R                  l        SU R                   R                  l        SU R                   R                  l        SU R                   R
                  l        SU R                   R                  l        SU R                   R                  l        [        TU ]-  U5        [        U S5      (       a  U R                  5         gg)zInitialize the app.TFr   N)rv   rO   rR   rQ   rP   rA   rB   rS   paginateQtPDFExporterr&   r   r   r   r   s     r,   r   DejavuApp.initialize  s    59$$2=A$$:<@$$926''/.3""+-2!!*4 4.//$$& 0r.   rJ   c                    g)Nhtmlr/   rc   s    r,   _default_export_format DejavuApp._default_export_format  s    r.   r/   r`   )
r0   r1   r2   r3   r4   r   r   r/  r6   r7   r8   s   @r,   r(  r(    s$    ' _ r.   r(  ):r4   
__future__r   r   r   ra   r   r   typingttextwrapr   r   jupyter_core.applicationr   r   r   	traitletsr	   r
   r   r   r   r   r   r   traitlets.configr   r   traitlets.utils.importstringr   	nbconvertr   r   r   r   r   nbconvert.utils.textr   exporters.baser   r   
utils.baser   utils.exceptionsr   utils.ior   r!   r"  updater#  rD   r(  launch_instancemainlaunch_new_instancedejavu_mainr/   r.   r,   <module>rD     s   #    	 
  ! I I ] ] ] = 4 T T ' : % 1 *#       &   *49%5-2,3;7     z "    #Y$563

 #^T$:;F
  $!
 v
 nn=>?
 */%/! !2268

 */%/! !226,5t+</
 7<j Y 126094/@
 e
 #,0-1% H
 #-1%),0%@

 !-t#
 g$
 !%t#
 M%
 ##U%
 O
 "D!
 B
 #T!
 \
[uwtI0: I0X 2 *99 9''r.   