
    }c9                         d Z ddlZddlZddlmZmZ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ded	ed
eddddf
dZd dddfded	eded
edddeeegdf         ddfdZdS )z"File utility functions for Sphinx.    N)TYPE_CHECKINGCallableDict)relative_path)copyfile	ensuredir)PathMatcher)BaseRenderersourcedestinationcontextrendererr
   returnc                    t           j                            |           sdS t           j                            |          r=t           j                            |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_tr   SphinxRendererzutf-8)encodingw)ospathexistsisdirjoinbasenamelowerendswithsphinx.util.templater   openwriterender_stringreadr   )r   r   r   r   r   fsrcfdsts          4lib/python3.11/site-packages/sphinx/util/fileutil.pycopy_asset_filer'      s    7>>&!! 	w}}[!! Jgll;0@0@0H0HII||~~t$$ & & 	(;;;;;;%~''H&7+++ 	It  ""++D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 	%%%%%s7   
AE.<E
E.E	E.E	E..E25E2c                     dS )NF )r   s    r&   <lambda>r*   1   s    SX     excludedonerrorc           	      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   r,   r   r   r-   r   rootdirsfilesreldirdirfilenameexcs                 r&   
copy_assetr<   1   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)__doc__r   r2   typingr   r   r   docutils.utilsr   sphinx.util.osutilr   r   sphinx.util.typingr	   r   r
   strr'   r4   r<   r)   r+   r&   <module>rC      sT   ( ( 				     0 0 0 0 0 0 0 0 0 0 ( ( ( ( ( ( 2 2 2 2 2 2 2 2 * * * * * * 2111111 FJ& &C &c &!&4B&NR& & & &B GYFX#;?- -s - - --/=- #y!14!78-DH- - - - - -r+   