
    7 f                       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ZddlZddl	Z	ddl
mZ ddlmZ ddlmZmZ ddlmZ erddlmZ d	Zd4dZd5dZd6dZd7dZd8dZd9dZd:d Zd:d!Z ej        d"          Z ej        d#          Zd;d%Z d<d'Z!ej"        fd=d+Z#e#Z$ ej%                    p ej&                    Z'ej(        Z( G d, d-          Z)ej*        d>d0            Z+ G d1 d2          Z,d?d3Z-dS )@z6Operating system-related utility functions for Sphinx.    )annotationsN)StringIOpath)TYPE_CHECKINGAny)_deprecation_warning)Iterator/canonical_pathstrreturnc               L    |                      t          t          j                  S N)replaceSEPr   sep)r   s    H/var/www/equiseq/venv/lib/python3.11/site-packages/sphinx/util/osutil.pyos_pathr      s    !!#tx000    native_pathstr | os.PathLike[str]c               p    t          j        |                               t          j        t
                    S )z"Return path in OS-independent form)osfspathr   r   r   r   )r   s    r   
canon_pathr   !   s$    9[!!))$(C888r   filepathc               J    t          |           }t          j        d|          S )z+Normalize path separator and unicode stringNFC)r   unicodedata	normalize)r   new_paths     r   path_stabilizer#   &   s"    (##H 111r   basetoc                ~   |                     t                    r|S |                     d          d                             t                    }|                    d          d                             t                    }t          |dd         |dd                   D ]7\  }}||k    r n+|                    d           |                    d           8||k    rdS t          |          dk    r|dgk    r
dt          z   S dt          z   t          |          dz
  z  t                              |          z   S )	z.Return a relative URL from ``base`` to ``to``.#r   N    .z..)
startswithr   splitzippoplenjoin)r$   r%   b2t2xys         r   relative_urir6   ,   s   	}}S 		C		!	!#	&	&B	#q				$	$BBssGRW%%  166E
q			
q					Rxx r
2ww!||rd

 Sy3J3r77Q;'#((2,,66r   fileNonec                2    t          j        | d           dS )zEnsure that a path exists.T)exist_okN)r   makedirs)r7   s    r   	ensuredirr<   C   s    Kt$$$$$$r   dirnames	list[str]suffixIterator[float]c           
   #  2  K   | D ]}t          j        |          D ]z\  }}}|D ]q}|                    |          rZt          j        t
                    5  t          j        t          j        ||                    V  d d d            n# 1 swxY w Y   r{d S r   )	r   walkendswith
contextlibsuppressOSErrorr   getmtimer1   )r=   r?   dirnameroot_dirsfilessfiles          r   mtimes_of_filesrM   H   s      D D"$''"2"2 	D 	DD% D D>>&)) D#,W55 D D"mDIdE,B,BCCCCCD D D D D D D D D D D D D D DD	DD Ds   *B			BBsourcedestc                    t          j        |           }t          t           d          r#t          j        ||j        |j        f           dS dS )z!Copy a file's modification times.utimeN)r   stathasattrrQ   st_atimest_mtime)rN   rO   sts      r   	copytimesrW   Q   sL    	Br7 3
R[1222223 3r   c                
   t          j        |          rt          j        | |          sYt	          j        | |           t          j        t                    5  t          | |           ddd           dS # 1 swxY w Y   dS dS )z{Copy a file and its modification times, if possible.

    Note: ``copyfile`` skips copying if the file has not been changedN)
r   existsfilecmpcmpshutilcopyfilerD   rE   rF   rW   )rN   rO   s     r   r]   r]   X   s     ;t $GK$=$= $%%% )) 	$ 	$fd###	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$$ $s   A66A:=A:z[^a-zA-Z0-9_-]z Documentation$stringc                <    t                               d|           pdS )Nr)   sphinx)no_fn_resub)r^   s    r   make_filenamerc   g   s    <<F##/x/r   projectc                v    t          t                              d|                                                     S )Nr)   )rc   project_suffix_rerb   lower)rd   s    r   make_filename_from_projectrh   k   s-    *..r7;;<<BBDDDr   r   startstr | os.PathLike[str] | Nonec                    	 t           j                            | |          S # t          $ r t	          |           cY S w xY w)a  Return a relative filepath to *path* either from the current directory or
    from an optional *start* directory.

    This is an alternative of ``os.path.relpath()``.  This returns original path
    if *path* and *start* are on different drives (for Windows platform).
    )r   r   relpath
ValueErrorr   )r   ri   s     r   rl   rl   o   sJ    wtU+++   4yys   " >>c                  &    e Zd ZdZddZd Zd ZdS )	_chdirz>Remove this fall-back once support for Python 3.10 is removed.
target_dirr   c               "    || _         g | _        d S r   )r   rJ   )selfrp   s     r   __init__z_chdir.__init__   s    	 "


r   c                    | j                             t          j                               t          j        | j                   d S r   )rJ   appendr   getcwdchdirr   rr   s    r   	__enter__z_chdir.__enter__   s6    
")++&&&
r   c               \    t          j        | j                                                   d S r   )r   rw   rJ   r/   )rr   	_exc_type
_exc_value
_tracebacks       r   __exit__z_chdir.__exit__   s$    
!!"""""r   N)rp   r   )__name__
__module____qualname____doc__rs   ry   r~    r   r   ro   ro      sL        HH# # # #  # # # # #r   ro   rp   Iterator[None]c              #     K   t           j        d d         dk    rt          t          ddd           t	          |           5  d V  d d d            d S # 1 swxY w Y   d S )N   )      cdzcontextlib.chdir)   r   )remove)sysversion_infor	   r   ro   )rp   s    r   r   r      s      
w&&Xt-?OOOO	
		                   s   AAAc                  B    e Zd ZdZddZddZdd	Zdd
ZddZddZ	dS )FileAvoidWritea  File-like object that buffers output and only writes if content changed.

    Use this class like when writing to a file to avoid touching the original
    file if the content hasn't changed. This is useful in scenarios where file
    mtime is used to invalidate caches or trigger new behavior.

    When writing to this file handle, all writes are buffered until the object
    is closed.

    Objects can be used as context managers.
    r   r   r   r8   c                "    || _         d | _        d S r   )_path_io)rr   r   s     r   rs   zFileAvoidWrite.__init__   s    
$(r   datac                n    | j         st                      | _         | j                             |           d S r   )r   r   write)rr   r   s     r   r   zFileAvoidWrite.write   s1    x 	"zzDHtr   c                   | j         sd}t          |          |                                 }| j                                          	 t	          | j        d          5 }|                                }||k    r	 ddd           dS 	 ddd           n# 1 swxY w Y   n# t          $ r Y nw xY wt	          | j        dd          5 }|                    |           ddd           dS # 1 swxY w Y   dS )z0Stop accepting writes and write file, if needed.z,FileAvoidWrite does not support empty files.zutf-8)encodingNw)	r   	Exceptiongetvaluecloseopenr   readrF   r   )rr   msgbufold_fold_contentfs         r   r   zFileAvoidWrite.close   s   x 	!@CC.. mmoo	dj7333 u#jjll#%%       %                	 	 	D	 $*cG444 	GGCLLL	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	sN   B B9B B BB BB 
B,+B,C))C-0C-c                    | S r   r   rx   s    r   ry   zFileAvoidWrite.__enter__   s    r   exc_typetype[Exception]	exc_valuer   	tracebackr   boolc                .    |                                   dS )NT)r   )rr   r   r   r   s       r   r~   zFileAvoidWrite.__exit__   s     	

tr   namec                \    | j         sd}t          |          t          | j         |          S )Nz=Must write to FileAvoidWrite before other methods can be used)r   r   getattr)rr   r   r   s      r   __getattr__zFileAvoidWrite.__getattr__   s/    x 	!QCC.. tx&&&r   Nr   r   r   r8   )r   r   r   r8   )r   r8   )r   r   )r   r   r   r   r   r   r   r   )r   r   r   r   )
r   r   r   r   rs   r   r   ry   r~   r   r   r   r   r   r      s        
 
) ) ) )   
   (      ' ' ' ' ' 'r   r   c                    t           j                            |           rt          j        |            d S t          j        |            d S r   )r   r   isdirr\   rmtreer   r   s    r   r   r      s?    	w}}T d
	$r   )r   r   r   r   )r   r   r   r   )r   r   r   r   )r$   r   r%   r   r   r   )r7   r   r   r8   )r=   r>   r?   r   r   r@   )rN   r   rO   r   r   r8   )r^   r   r   r   )rd   r   r   r   )r   r   ri   rj   r   r   )rp   r   r   r   r   ).r   
__future__r   rD   rZ   r   rer\   r   r    ior   r   typingr   r   sphinx.deprecationr	   collections.abcr
   r   r   r   r#   r6   r<   rM   rW   r]   compilera   rf   rc   rh   curdirrl   safe_relpathgetfilesystemencodinggetdefaultencodingfs_encodingabspathro   contextmanagerr   r   r   r   r   r   <module>r      s   < < " " " " " "      				 				  



                 % % % % % % % % 3 3 3 3 3 3 )(((((( 
1 1 1 19 9 9 9
2 2 2 27 7 7 7.% % % %
D D D D3 3 3 3$ $ $ $ 2:'((BJ011 0 0 0 0E E E E
 469     'c'))E-CS-C-E-E ,# # # # # # # #    8' 8' 8' 8' 8' 8' 8' 8'v     r   