
    7 fF                        d Z ddlmZ ddlZddlZddlmZmZ ddlm	Z	 ddl
mZmZ erddlmZ ddlmZ 	 	 dddZd dddfddZdS )z"File utility functions for Sphinx.    )annotationsN)TYPE_CHECKINGCallable)relative_path)copyfile	ensuredir)BaseRenderer)PathMatchersourcestr | os.PathLike[str]destinationcontextdict | NonerendererBaseRenderer | NonereturnNonec                ,   t           j                            |           sdS t           j                            |          r>t           j                            |t           j                            |                     }nt          |          }t           j                            |                               d          r||ddlm	}  |            }t          | d          5 }|                    d          r
|dd         }t          |dd          5 }|                    |                    |                                |                     ddd           n# 1 swxY w Y   ddd           dS # 1 swxY w Y   dS t          | |           dS )	a  Copy an asset file to destination.

    On copying, it expands the template variables if context argument is given and
    the asset is a template file.

    :param source: The path to source file
    :param destination: The path to destination file or directory
    :param context: The template variables.  If not given, template files are simply copied
    :param renderer: The template engine.  If not given, SphinxRenderer is used by default
    N)_t_Tr   SphinxRendererzutf-8)encodingw)ospathexistsisdirjoinbasenamestrendswithsphinx.util.templater   openwriterender_stringreadr   )r   r   r   r   r   fsrcfdsts          J/var/www/equiseq/venv/lib/python3.11/site-packages/sphinx/util/fileutil.pycopy_asset_filer,      s    7>>&!! 	w}}[!! 'gll;0@0@0H0HII+&&	w((66 &7;N;;;;;;%~''H&7+++ 	It##L11 /)#2#.k3999 IT

811$))++wGGHHHI I I I I I I I I I I I I I I	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	%%%%%s6   %2E7<EE7E#	#E7&E#	'E77E;>E;c                    dS )NF )r   s    r+   <lambda>r/   7   s    E     excludedr
   onerror'Callable[[str, Exception], None] | Nonec           	     D   t           j                            |           sdS |ddlm}  |            }t          |           t           j                            |           rt          | |||           dS t          j        | d          D ]\  }}}	t          | |          }
|dd         D ]Y} |t          j        |
|                    r|                    |           6t          t          j        ||
|                     Z|	D ]} |t          j        |
|                    st	 t          t          j        ||          t          j        ||
          ||           Z# t          $ r-}|r  |t          j        ||          |           n Y d}~d}~ww xY wdS )aM  Copy asset files to destination recursively.

    On copying, it expands the template variables if context argument is given and
    the asset is a template file.

    :param source: The path to source file or directory
    :param destination: The path to destination directory
    :param excluded: The matcher to determine the given path should be copied or not
    :param context: The template variables.  If not given, template files are simply copied
    :param renderer: The template engine.  If not given, SphinxRenderer is used by default
    :param onerror: The error handler.
    Nr   r   T)followlinks)r   r   r   r$   r   r   isfiler,   walkr   	posixpathr    remove	Exception)r   r   r1   r   r   r2   r   rootdirsfilesreldirdirfilenameexcs                 r+   
copy_assetrB   6   s     7>>&!! 777777!>##k	w~~f Wh???WV>>>  dEvt,,7 	D 	DCx	vs3344 DC    ).fcBBCCCC 
	 
	H8IN68<<== 	#IN4$B$B$-N;$G$G$+X7 7 7 7 !    	tX > >DDDD EDDDD	
	 s   *8E##
F-#FF)NN)
r   r   r   r   r   r   r   r   r   r   )r   r   r   r   r1   r
   r   r   r   r   r2   r3   r   r   )__doc__
__future__r   r   r8   typingr   r   docutils.utilsr   sphinx.util.osutilr   r   r$   r	   sphinx.util.typingr
   r,   rB   r.   r0   r+   <module>rI      s    ( ( " " " " " " 				     * * * * * * * * ( ( ( ( ( ( 2 2 2 2 2 2 2 2 /111111...... ,048!& !& !& !& !&J (:'9&*DBF. . . . . . .r0   