3
T'íc9 ã @ s° d Z ddlZddlZddlmZmZmZ ddlmZ ddl m
Z
mZ ddlm
Z
er`ddlmZ deeeddd d
dZdd
dddfeee
edeeegdf ddddZdS )z"File utility functions for Sphinx.é N)Ú
TYPE_CHECKINGÚCallableÚDict)Ú
relative_path)ÚcopyfileÚ ensuredir)ÚPathMatcher)ÚBaseRendererr )ÚsourceÚdestinationÚcontextÚrendererÚreturnc C sÔ t jj| sdS t jj|r2t jj|t jj| }| j jdrÆ|dk rÆ|dkrbddlm } | }t
| ddP}|j jdr|dd
}t
|ddd}|j|j|j
| W dQ R X W dQ R X n
t| | dS )
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
NZ_tr )ÚSphinxRendererzutf-8)Úencodingé Úwéþÿÿÿ)ÚosÚpathÚexistsÚisdirÚjoinÚbasenameÚlowerÚendswithÚsphinx.util.templater ÚopenÚwriteZ
render_stringÚreadr )r