
    Mhi                         d Z ddlZddlZddlZddlZddlZddlZddlmZm	Z	 ddZ
d Z G d de	eef                   Z	 ej        Zn# e$ r d	ZY nw xY wd
 Zd ZdS )zio-related utilities    N)AnyDictstdoutc                     | dv sJ t          t          |           } 	 | j        }n# t          $ r | cY S w xY w t	          j        d          |          S )u   Get a wrapper to write unicode to stdout/stderr as UTF-8.

    This ignores environment variables and default encodings, to reliably write
    unicode to stdout or stderr.

    ::

        unicode_std_stream().write(u'ł@e¶ŧ←')
    )r   stderrutf-8)getattrsysbufferAttributeErrorcodecs	getwriterstreamstream_bs     R/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/nbconvert/utils/io.pyunicode_std_streamr      st     )))))S&!!F=    %6G$$X...s   % 44c                      t           j        } 	 | j        }n# t          $ r | cY S w xY w t	          j        d          |          S )zGet a wrapper to read unicode from stdin as UTF-8.

    This ignores environment variables and default encodings, to reliably read unicode from stdin.

    ::

        totreat = unicode_stdin_stream().read()
    r   )r
   stdinr   r   r   	getreaderr   s     r   unicode_stdin_streamr   %   sZ     YF=    %6G$$X...s    %%c                       e Zd ZdZd ZdS )FormatSafeDictzFormat a dictionary safely.c                     d|z   dz   S )zHandle missing value.{} )selfkeys     r   __missing__zFormatSafeDict.__missing__:   s    Sy3    N)__name__
__module____qualname____doc__r    r   r!   r   r   r   7   s)        %%    r!   r   i  c                     t          t          d          st          S d}	 t          j        | |           n# t          $ r}|j        }Y d}~nd}~ww xY w|S )zHard links ``src`` to ``dst``, returning 0 or errno.

    Note that the special errno ``ENOLINK`` will be returned if ``os.link`` isn't
    supported by the operating system.
    linkr   N)hasattrosENOLINKr'   OSErrorerrno)srcdst
link_errnoes       r   r'   r'   E   sp     2v J
S   W





s   6 
A AAc                    t           j                            |          r=t           j                            |t           j                            |                     }t          | |          }|t          j        k    rt          j        |           j	        t          j        |          j	        k    rdS |dt          j        dd          dz   }	 t          | |           n5# t          $ r( 	 t          j        |           n# t          $ r Y nw xY w w xY wt          j        ||           dS |dk    rt#          j        | |           dS dS )a+  Attempts to hardlink ``src`` to ``dst``, copying if the link fails.

    Attempts to maintain the semantics of ``shutil.copy``.

    Because ``os.link`` does not overwrite files, a unique temporary file
    will be used if the target already exists, then that file will be moved
    into place.
    Nz-temp-   i   04Xr   )r)   pathisdirjoinbasenamer'   r,   EEXISTstatst_inorandomrandintlink_or_copyBaseExceptionremover+   renameshutilcopy)r-   r.   r/   new_dsts       r   r=   r=   V   sU    
w}}S 7gll3 0 0 5 566c3JU\!!73<<"'#,,"555 F?5!9!9????	g&&&& 	 	 		'""""   	 		'3	q 	C 
s0   C! !
D,D D
DDDD)r   )r%   r   r,   r)   r;   rA   r
   typingr   r   r   r   r   r*   r   r'   r=   r   r!   r   <module>rE      s
    
   				   



        / / / /,/ / /$    T#s(^   mGG   GGG  "" " " " "s   A	 	AA