§
    ŽŸjü  ã                  ó¸   — d Z ddlmZ ddlZddlZddlZddlZddlmZ ddl	m
Z
mZmZmZmZmZ ddlmZ ddlmZ  G d	„ d
e¦  «        Zd„ Z G d„ de¦  «        ZdS )zExport to PDF via latexé    )ÚannotationsN)ÚTemporaryDirectory)ÚBoolÚInstanceÚIntegerÚListÚUnicodeÚdefault)Ú_contextlib_chdiré   )ÚLatexExporterc                  ó$   — e Zd ZdZd„ Zd„ Zd„ ZdS )ÚLatexFailedzRException for failed latex run

    Captured latex output is in error.output.
    c                ó   — || _         dS )zInitialize the error.N©Úoutput)Úselfr   s     úd/var/www/finuniver-perm.ru/html/student/venv/lib/python3.11/site-packages/nbconvert/exporters/pdf.pyÚ__init__zLatexFailed.__init__   s   € àˆŒˆˆó    c                ó   — d| j         z  S )zUnicode representation.z.PDF creating failed, captured latex output:
%sr   ©r   s    r   Ú__unicode__zLatexFailed.__unicode__   s   € à@À4Ä;ÑNÐNr   c                ó*   — |                       ¦   «         S )zString representation.)r   r   s    r   Ú__str__zLatexFailed.__str__"   s   € à×ÒÑ!Ô!Ð!r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   © r   r   r   r      sN   € € € € € ðð ð
ð ð ðOð Oð Oð"ð "ð "ð "ð "r   r   c                ó`   — |sdS |t           j        z   |                     | d¦  «        z   || <   dS )zŽAdd value to the environment variable varname in envdict

    e.g. prepend_to_env_search_path('BIBINPUTS', '/home/sally/foo', os.environ)
    NÚ )ÚosÚpathsepÚget)ÚvarnameÚvalueÚenvdicts      r   Úprepend_to_env_search_pathr)   '   s;   € ð
 ð Øˆà�rœzÑ)¨G¯KªK¸ÀÑ,DÔ,DÑD€GˆGÑÐÐr   c                  ó  ‡ — e Zd ZdZdZ edd¬¦  «                             d¬¦  «        Z eg d¢d	¬¦  «                             d¬¦  «        Z	 ed
dgd¬¦  «                             d¬¦  «        Z
 edd¬¦  «                             d¬¦  «        Z ed¬¦  «        Z eddddi¬¦  «        ZdZ e e¦   «         ¦  «        Z ed¦  «        d„ ¦   «         Z ed¦  «        d„ ¦   «         Zdd„Zefd„Zd d„Zdˆ fd„	Zˆ xZS )!ÚPDFExporterzÐWriter designed to write to PDF files.

    This inherits from `LatexExporter`. It creates a LaTeX file in
    a temporary directory using the template machinery, and then runs LaTeX
    to create a pdf.
    zPDF via LaTeXé   z$How many times latex will be called.)ÚhelpT)Úconfig)Úxelatexú
{filename}z-quietz$Shell command used to compile latex.Úbibtexr0   z!Shell command used to run bibtex.Fz0Whether to display the output of latex commands.z.texinputs dir. A notebook's directory is addedznbconvert.writers.FilesWriterr    Úbuild_directoryú.)ÚargsÚkwzapplication/pdfÚfile_extensionc                ó   — dS )Nú.pdfr    r   s    r   Ú_file_extension_defaultz#PDFExporter._file_extension_defaultO   s   € àˆvr   Útemplate_extensionc                ó   — dS )Nz.tex.j2r    r   s    r   Ú_template_extension_defaultz'PDFExporter._template_extension_defaultS   s   € àˆyr   Nc           
     ó  ‡— ˆfd„|D ¦   «         }t          j        |d         ¦  «        }|€(d}|d         › d|d         › d|› d�}	t          |	¦  «        ‚|dk    rd	nd
}
| j                             d|d         ||
|¦  «         t
          j        dk    }|rt          j        |¦  «        }t          j
                             ¦   «         }t          d| j        |¦  «         t          d| j        |¦  «         t          d| j        |¦  «         t          t          j        d¦  «        5 }| j        st          j        nd}t%          |¦  «        D ]­}t          j        ||t          j        |||¬¦  «        }|                     ¦   «         \  }}|j        ri| j        rd}n|                     dd¦  «        } |||¦  «         | j                             |¦  «         |rd|› d|› �}	 ||	¦  «        ‚ ddd¦  «         dS Œ®	 ddd¦  «         n# 1 swxY w Y   dS )aÐ  Run command_list count times.

        Parameters
        ----------
        command_list : list
            A list of args to provide to Popen. Each element of this
            list will be interpolated with the filename to convert.
        filename : unicode
            The name of the file to convert.
        count : int
            How many times to run the command.
        raise_on_failure: Exception class (default None)
            If provided, will raise the given exception for if an instead of
            returning False on command failure.

        Returns
        -------
        success : bool
            A boolean indicating if the command was successful (True)
            or failed (False).
        c                ó<   •— g | ]}|                      ‰¬ ¦  «        ‘ŒS ))Úfilename)Úformat)Ú.0Úcr?   s     €r   ú
<listcomp>z+PDFExporter.run_command.<locals>.<listcomp>m   s'   ø€ ÐEÐEÐE°1�1—8’8 X�8Ñ.Ô.ÐEÐEÐEr   r   NzFhttps://nbconvert.readthedocs.io/en/latest/install.html#installing-texz. not found on PATH, if you have not installed z5 you may need to do so. Find further instructions at r3   r   ÚtimeÚtimeszRunning %s %i %s: %sÚwin32Ú	TEXINPUTSÚ	BIBINPUTSÚ	BSTINPUTSÚrb)ÚstdoutÚstderrÚstdinÚshellÚenvr"   zutf-8ÚreplacezFailed to run "z" command:
FT)ÚshutilÚwhichÚOSErrorÚlogÚinfoÚsysÚplatformÚ
subprocessÚlist2cmdliner#   ÚenvironÚcopyr)   Ú	texinputsÚopenÚdevnullÚverboseÚPIPEÚrangeÚPopenÚSTDOUTÚcommunicateÚ
returncodeÚdecodeÚ_captured_outputÚappend)r   Úcommand_listr?   ÚcountÚlog_functionÚraise_on_failureÚcommandÚcmdÚlinkÚmsgrE   rN   rO   ÚnullrK   Ú_ÚpÚoutÚout_strs     `                r   Úrun_commandzPDFExporter.run_commandW   s¶  ø€ ð, FÐEÐEÐE¸ÐEÑEÔEˆõ Œl˜<¨œ?Ñ+Ô+ˆØˆ;Ø[ˆDà ”?ð ð Ø ”?ðð àðð ð ð õ
 ˜#‘,”,Ðà 1š*˜*��¨'ˆØŒ�ŠÐ,¨l¸1¬o¸uÀeÈWÑUÔUÐUå” Ò'ˆØð 	7Ý Ô-¨gÑ6Ô6ˆGÝŒj�oŠoÑÔˆÝ" ;°´ÀÑDÔDÐDÝ" ;°´ÀÑDÔDÐDÝ" ;°´ÀÑDÔDÐDå•"”*˜dÑ#Ô#ð 	! tØ,0¬LÐB•Z”_�_¸dˆFÝ˜5‘\”\ð !ð !�ÝÔ$ØØ!Ý%Ô,ØØØðñ ô �ð Ÿš™œ‘��QØ”<ð !Ø”|ð Að #%˜˜à"%§*¢*¨W°iÑ"@Ô"@˜Ø �L ¨#Ñ.Ô.Ð.ØÔ)×0Ò0°Ñ9Ô9Ð9Ø'ð 4ØN°ÐNÐNÀWÐNÐN˜Ø.Ð.¨sÑ3Ô3Ð3Ø ð1	!ð 	!ð 	!ñ 	!ô 	!ð 	!ð 	!ð 	!ð!ð!ð	!ð 	!ð 	!ñ 	!ô 	!ð 	!ð 	!ð 	!ð 	!ð 	!ð 	!øøøð 	!ð 	!ð 	!ð 	!ð2 ˆts   Ä"CHÇ4HÈHÈ	Hc                óT   ‡ — ˆ fd„}‰                       ‰ j        |‰ j        ||¦  «        S )z#Run xelatex self.latex_count times.c                óN   •— ‰j                              d| d         | |¦  «         d S )Nz%s failed: %s
%sr   )rT   Úcritical©rm   rt   r   s     €r   Ú	log_errorz(PDFExporter.run_latex.<locals>.log_error£   s*   ø€ ØŒH×ÒÐ1°7¸1´:¸wÈÑLÔLÐLÐLÐLr   )rv   Úlatex_commandÚlatex_count©r   r?   rl   r{   s   `   r   Ú	run_latexzPDFExporter.run_latex    sM   ø€ ð	Mð 	Mð 	Mð 	Mð 	Mð ×ÒØÔ ¨$Ô*:¸IÐGWñ
ô 
ð 	
r   c                ó”   ‡ — t           j                             |¦  «        d         }ˆ fd„}‰                      ‰ j        |d||¦  «        S )zRun bibtex one time.r   c                ó�   •— ‰j                              d| d         ¦  «         ‰j                              d| d         | |¦  «         d S )Nz<%s had problems, most likely because there were no citationsr   z%s output: %s
%s)rT   ÚwarningÚdebugrz   s     €r   r{   z&PDFExporter.run_bib.<locals>.log_error®   sP   ø€ ØŒH×ÒØNÐPWÐXYÔPZñô ð ð ŒH�NŠNÐ.°¸´
¸GÀSÑIÔIÐIÐIÐIr   r   )r#   ÚpathÚsplitextrv   Úbib_commandr~   s   `   r   Úrun_bibzPDFExporter.run_bibª   s]   ø€ å”7×#Ò# HÑ-Ô-¨aÔ0ˆð	Jð 	Jð 	Jð 	Jð 	Jð ×Ò Ô 0°(¸A¸yÐJZÑ[Ô[Ð[r   c                ó‚  •—  t          ¦   «         j        |fd|i|¤Ž\  }}|rZ|                     di ¦  «                             d¦  «        r1t          j                             |d         d         ¦  «        | _        nt          j        ¦   «         | _        g | _        t          ¦   «         5 }t          j        |¦  «        5  d}d|d<   | j                             |||¬¦  «        }| j                             d¦  «         |                      |¦  «         |                      |¦  «        r|                      |¦  «         |d	z   }t          j                             |¦  «        s't'          d
                     | j        ¦  «        ¦  «        ‚| j                             d¦  «         t-          |d¦  «        5 }	|	                     ¦   «         }
ddd¦  «         n# 1 swxY w Y   ddd¦  «         n# 1 swxY w Y   ddd¦  «         n# 1 swxY w Y   d	|d<   |                     dd¦  «         |                     dd¦  «         |
|fS )zConvert from notebook node.Ú	resourcesÚmetadatar„   Únotebookz.texÚoutput_extension)Únotebook_namezBuilding PDFr8   ú
zPDF successfully createdrJ   NÚoutputsÚattachments)ÚsuperÚfrom_notebook_noder%   r#   r„   Úabspathr\   ÚgetcwdÚ_captured_outputsr   r   ÚchdirÚwriterÚwriterT   rU   r   r‡   Úisfiler   Újoinrg   r]   ÚreadÚpop)r   Únbr‰   r5   ÚlatexÚtdr�   Útex_fileÚpdf_fileÚfÚpdf_dataÚ	__class__s              €r   r’   zPDFExporter.from_notebook_node¶   sÍ  ø€ à5�5™7œ7Ô5°bÐTÐTÀIÐTÐQSÐTÐTÑˆˆyàð 	)˜Ÿš z°2Ñ6Ô6×:Ò:¸6ÑBÔBð 	)ÝœWŸ_š_¨Y°zÔ-BÀ6Ô-JÑKÔKˆDŒNˆNåœY™[œ[ˆDŒNà!#ˆÔÝÑ!Ô!ð 	$ RÕ):Ô)@ÀÑ)DÔ)Dð 	$ð 	$Ø&ˆMØ,2ˆIÐ(Ñ)Ø”{×(Ò(¨°	ÈÐ(ÑWÔWˆHØŒH�MŠM˜.Ñ)Ô)Ð)Ø�NŠN˜8Ñ$Ô$Ð$Ø�|Š|˜HÑ%Ô%ð )Ø—’˜xÑ(Ô(Ð(à$ vÑ-ˆHÝ”7—>’> (Ñ+Ô+ð DÝ! $§)¢)¨DÔ,AÑ"BÔ"BÑCÔCÐCØŒH�MŠMÐ4Ñ5Ô5Ð5Ý�h Ñ%Ô%ð $¨ØŸ6š6™8œ8�ð$ð $ð $ñ $ô $ð $ð $ð $ð $ð $ð $øøøð $ð $ð $ð $ð	$ð 	$ð 	$ñ 	$ô 	$ð 	$ð 	$ð 	$ð 	$ð 	$ð 	$øøøð 	$ð 	$ð 	$ð 	$ð 	$ð 	$ð 	$ñ 	$ô 	$ð 	$ð 	$ð 	$ð 	$ð 	$ð 	$øøøð 	$ð 	$ð 	$ð 	$ð$ )/ˆ	Ð$Ñ%ð 	�Š�i Ñ&Ô&Ð&Ø�Š�m TÑ*Ô*Ð*à˜Ð"Ð"s[   Â*HÂ?C3G*Æ2GÇG*ÇGÇG*ÇGÇG*ÇHÇ*G.	Ç.HÇ1G.	Ç2HÈHÈH)N)F)r   r   r   r   Úexport_from_notebookr   Útagr}   r   r|   r†   r   r_   r	   r\   r   r—   Úoutput_mimetyperg   r
   r9   r<   rv   r   r   r‡   r’   Ú__classcell__)r¤   s   @r   r+   r+   2   sè  ø€ € € € € ðð ð +Ðà�'˜!Ð"HÐIÑIÔI×MÒMÐUYÐMÑZÔZ€Kà�DØ+Ð+Ð+Ð2Xðñ ô ç	‚c�€cÑÔð ð �$˜ ,Ð/Ð6YÐZÑZÔZ×^Ò^Øð _ñ ô €Kð ˆd�5ÐQÐRÑRÔR×VÒVÐ^bÐVÑcÔc€Gà�ÐMÐNÑNÔN€IØˆXÐ5¸BÐDUÐWZÐC[Ð\Ñ\Ô\€Fà'€Oà�t˜G˜G™IœI‘”Ðà€WÐÑÔðð ñ Ôðð €WÐ!Ñ"Ô"ðð ñ #Ô"ððGð Gð Gð GðR 4?ð 
ð 
ð 
ð 
ð
\ð 
\ð 
\ð 
\ð"#ð "#ð "#ð "#ð "#ð "#ð "#ð "#ð "#ð "#r   r+   )r   Ú
__future__r   r#   rQ   rX   rV   Útempfiler   Ú	traitletsr   r   r   r   r	   r
   Únbconvert.utilsr   rž   r   ÚIOErrorr   r)   r+   r    r   r   ú<module>r®      s&  ðØ Ð ð #Ð "Ð "Ð "Ð "Ð "à 	€	€	€	Ø €€€Ø Ð Ð Ð Ø 
€
€
€
Ø 'Ð 'Ð 'Ð 'Ð 'Ð 'à EÐ EÐ EÐ EÐ EÐ EÐ EÐ EÐ EÐ EÐ EÐ EÐ EÐ EÐ EÐ Eà -Ð -Ð -Ð -Ð -Ð -à  Ð  Ð  Ð  Ð  Ð  ð"ð "ð "ð "ð "�'ñ "ô "ð "ð&Eð Eð Eðf#ð f#ð f#ð f#ð f#�-ñ f#ô f#ð f#ð f#ð f#r   