§
    ŽŸjž  ã                   ór   — d 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 ddl	m
Z
 ddlmZ  G d„ d	e¦  «        ZdS )
z;Contains writer for writing nbconvert output to filesystem.é    N)ÚPath)ÚUnicodeÚobserve)Úlink_or_copyé   )Ú
WriterBasec                   óâ   ‡ — e Zd ZdZ edd¬¦  «                             d¬¦  «        Z ed¬¦  «                             d¬¦  «        Z ed¦  «        d	„ ¦   «         Z	ˆ fd
„Z
dd„Zd„ Zdd„Zˆ xZS )ÚFilesWriterz-Consumes nbconvert output and produces files.Ú a  Directory to write output(s) to. Defaults
                              to output to the directory of each notebook. To recover
                              previous default behaviour (outputting to the current
                              working directory) use . as the flag value.)ÚhelpT)ÚconfigaU  When copying files that the notebook depends on, copy them in
        relation to this path, such that the destination filename will be
        os.path.relpath(filename, relpath). If FilesWriter is operating on a
        notebook that already exists elsewhere on disk, then the default will be
        the directory containing that notebook.Úbuild_directoryc                 óH   — |d         }|r|                       |¦  «         d S d S )NÚnew)Ú_makedir)ÚselfÚchanger   s      úd/var/www/finuniver-perm.ru/html/student/venv/lib/python3.11/site-packages/nbconvert/writers/files.pyÚ_build_directory_changedz$FilesWriter._build_directory_changed&   s5   € à�UŒmˆØð 	Ø�MŠM˜#ÑÔÐÐÐð	ð 	ó    c                 ór   •—  t          ¦   «         j        di |¤Ž |                      d| j        i¦  «         dS )zInitialize the writer.r   N© )ÚsuperÚ__init__r   r   )r   ÚkwÚ	__class__s     €r   r   zFilesWriter.__init__,   sB   ø€ à�‰ŒÔÐÐ˜2ÐÐÐØ×%Ò% u¨dÔ.BÐ&CÑDÔDÐDÐDÐDr   éí  c                 ój  — t           j                             |¦  «        sb| j                             d|¦  «         	 t          j        ||¬¦  «         dS # t          $ r!}|j        t          j        k    r‚ Y d}~dS d}~ww xY wt           j         	                    |¦  «        st          d|z  ¦  «        ‚dS )a  ensure that a directory exists

        If it doesn't exist, try to create it and protect against a race condition
        if another process is doing the same.

        The default permissions are 755, which differ from os.makedirs default of 777.
        zMaking directory %s)ÚmodeNz %r exists but is not a directory)
ÚosÚpathÚexistsÚlogÚinfoÚmakedirsÚOSErrorÚerrnoÚEEXISTÚisdir)r   r!   r   Úes       r   r   zFilesWriter._makedir1   sÐ   € õ Œw�~Š~˜dÑ#Ô#ð 	EØŒH�MŠMÐ/°Ñ6Ô6Ð6ðÝ”˜D tÐ,Ñ,Ô,Ð,Ð,Ð,øÝð ð ð Ø”7�eœlÒ*Ð*Øð +Ð*Ð*Ð*Ð*Ð*øøøøðøøøõ ”—’˜tÑ$Ô$ð 	EÝÐ<¸tÑCÑDÔDÐDð	Eð 	Es   ¼A Á
A?ÁA:Á:A?c                 óŠ  — |D ]¿\  }}t           j                             ||¦  «        }t           j                             |¦  «        }|                      |¦  «         | j                             dt          |¦  «        |¦  «         t          |d¦  «        5 }| 	                    |¦  «         ddd¦  «         n# 1 swxY w Y   ŒÀdS )z-Write a dict containing filename->binary dataúWriting %i bytes to %sÚwbN)
r    r!   ÚjoinÚdirnamer   r#   ÚdebugÚlenÚopenÚwrite)r   ÚitemsÚ	build_dirÚfilenameÚdataÚdestr!   Úfs           r   Ú_write_itemszFilesWriter._write_itemsC   sì   € à#ð 		ð 		‰NˆH�då”7—<’< 	¨8Ñ4Ô4ˆDÝ”7—?’? 4Ñ(Ô(ˆDØ�MŠM˜$ÑÔÐð ŒH�NŠNÐ3µS¸±Y´YÀÑEÔEÐEÝ�d˜DÑ!Ô!ð  QØ—’˜‘”�ðð ð ñ ô ð ð ð ð ð ð øøøð ð ð ð øð		ð 		s   ÂB7Â7B;	Â>B;	Nc           	      óÎ  — |€d}t          |¦  «        ‚|                     dd¦  «        }|                     di ¦  «                             dd¦  «        }| j        p|}| j        p|}	|                     di ¦  «                             ¦   «         }
|
rc| j                             dt          j         	                    |                     d	d¦  «        d¦  «        ¦  «         |  
                    |
|	¦  «         |                     d
i ¦  «                             ¦   «         }|rc| j                             dt          j         	                    |                     dd¦  «        d¦  «        ¦  «         |  
                    ||	¦  «         |	�r| j        D �]}t          j        |¦  «        D ]ë}|dk    r!t          j                             ||¦  «        }n|}t          j         	                    |	|¦  «        }t          j                             |¦  «        }|                      |¦  «         t          j                             |¦  «        t          j                             |¦  «        k    r,| j                             d||¦  «         t!          ||¦  «         Œì�Œ|�||z   n|}t#          |	¦  «        |z  }| j                             dt%          |¦  «        |¦  «         t'          |t(          ¦  «        r@t+          |dd¬¦  «        5 }|                     |¦  «         ddd¦  «         n# 1 swxY w Y   n=t+          |d¦  «        5 }|                     |¦  «         ddd¦  «         n# 1 swxY w Y   |S )zÑ
        Consume and write Jinja output to the file system.  Output directory
        is set via the 'build_directory' variable of this instance (a
        configurable).

        See base for more...
        NÚnotebook_nameÚoutput_extensionÚmetadatar!   r   ÚoutputszSupport files will be in %sÚoutput_files_dirÚattachmentszAttachments will be in %sÚattachment_files_dirzCopying %s -> %sr,   Úwzutf-8)Úencodingr-   )Ú	TypeErrorÚgetÚrelpathr   r4   r#   r$   r    r!   r.   r:   ÚfilesÚglobr/   r   Únormpathr   r   r1   Ú
isinstanceÚstrr2   r3   )r   ÚoutputÚ	resourcesr<   r   Úmsgr=   Úresource_pathrG   r   r4   rA   r6   Úmatching_filenameÚdest_filenamer8   r!   Ú	dest_pathr9   s                      r   r3   zFilesWriter.writeP   s²  € ð Ð Ø!ˆCÝ˜C‘.”.Ð ð %Ÿ=š=Ð);¸TÑBÔBÐð "Ÿš j°"Ñ5Ô5×9Ò9¸&À"ÑEÔEˆØ”,Ð/ -ˆØÔ.Ð?°-ˆð —’˜i¨Ñ,Ô,×2Ò2Ñ4Ô4ˆØð 	6ØŒH�MŠMØ-Ý”—’˜YŸ]š]Ð+=¸rÑBÔBÀBÑGÔGñô ð ð ×Ò˜e _Ñ5Ô5Ð5ð  —m’m M°2Ñ6Ô6×<Ò<Ñ>Ô>ˆØð 	<ØŒH�MŠMØ+Ý”—’˜YŸ]š]Ð+AÀ2ÑFÔFÈÑKÔKñô ð ð ×Ò˜k¨?Ñ;Ô;Ð;ð ñ 	>Ø œJð >ñ >�å)-¬°8Ñ)<Ô)<ð >ð >Ð%à "’}�}Ý(*¬¯ªÐ8IÈ7Ñ(SÔ(S˜˜à(9˜õ œ7Ÿ<š<¨¸ÑGÔG�DÝœ7Ÿ?š?¨4Ñ0Ô0�DØ—M’M $Ñ'Ô'Ð'õ ”w×'Ò'¨Ñ-Ô-µ´×1AÒ1AÐBSÑ1TÔ1TÒTÐTØœŸšÐ&8Ð:KÈTÑRÔRÐRÝ$Ð%6¸Ñ=Ô=Ð=øñ>ð$ 4DÐ3Oˆ}Ð/Ñ/Ð/ÐUbˆÝ˜Ñ)Ô)¨DÑ0ˆ	ð 	Œ�ŠÐ.µ°F±´¸YÑGÔGÐGÝ�f�cÑ"Ô"ð 	 Ý�i ¨wÐ7Ñ7Ô7ð  ¸1Ø—’˜‘”�ð ð  ð  ñ  ô  ð  ð  ð  ð  ð  ð  øøøð  ð  ð  ð  øõ �i Ñ&Ô&ð  ¨!Ø—’˜‘”�ð ð  ð  ñ  ô  ð  ð  ð  ð  ð  ð  øøøð  ð  ð  ð  ð Ðs$   Ë:LÌL Ì#L Ì8MÍMÍ!M)r   )N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Útagr   rG   r   r   r   r   r:   r3   Ú__classcell__)r   s   @r   r
   r
      s  ø€ € € € € Ø7Ð7à�gØ
ðMðñ ô ÷ 
‚c�€cÑÔð ð ˆgð3ðñ ô ÷ 
‚c�€cÑÔð ð €WÐÑÔðð ñ  Ôðð
Eð Eð Eð Eð Eð
Eð Eð Eð Eð$ð ð ðNð Nð Nð Nð Nð Nð Nð Nr   r
   )rW   r'   rI   r    Úpathlibr   Ú	traitletsr   r   Únbconvert.utils.ior   Úbaser   r
   r   r   r   ú<module>r^      s´   ðØ AÐ Að
 €€€Ø €€€Ø 	€	€	€	Ø Ð Ð Ð Ð Ð à &Ð &Ð &Ð &Ð &Ð &Ð &Ð &à +Ð +Ð +Ð +Ð +Ð +à Ð Ð Ð Ð Ð ðLð Lð Lð Lð L�*ñ Lô Lð Lð Lð Lr   