
    fi                         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d	 Zd
 Zy# e$ r dZY w xY w)zio-related utilities    N)AnyDictc                     | dv sJ t        t        |       } 	 | j                  } t	        j
                  d      |      S # t        $ r | cY S w xY w)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¶ŧ←')
    )stdoutstderrutf-8)getattrsysbufferAttributeErrorcodecs	getwriterstreamstream_bs     M/var/www/cvtools/html/venv/lib/python3.12/site-packages/nbconvert/utils/io.pyunicode_std_streamr      s]     ))))S&!F==
 %6G$X..	  s   ? AAc                      t         j                  } 	 | j                  } t	        j
                  d      |      S # t        $ r | cY S w xY w)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   %   sK     YYF== %6G$X..  s   9 AAc                       e Zd ZdZd Zy)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                  | |       |S # t        $ r}|j
                  }Y d}~|S d}~ww xY w)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   sT     2vJ
S   WW
s   2 	AAAc                    t         j                  j                  |      r=t         j                  j                  |t         j                  j	                  |             }t        | |      }|t        j                  k(  rt        j                  |       j                  t        j                  |      j                  k(  ry|dt        j                  dd      dz   }	 t        | |       t        j                   ||       y|dk7  rt#        j$                  | |       yy# t        $ r' 	 t        j                  |        # t        $ r Y  w xY ww xY w)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   s    
ww}}Sggll3 0 0 56c3JU\\!773<"''#,"5"55 &5!9# >??	g& 			'3	q 	C 
  			'"   	s0   D 	E
$D:9E
:	EE
EE
)r   )r%   r   r,   r)   r;   rA   r
   typingr   r   r   r   r   r*   r   r'   r=   r   r!   r   <module>rE      sk    
   	   
 /,/$T#s(^ mmG
""+  Gs   A AA