File: //lib/python3/dist-packages/sphinx/util/__pycache__/fileutil.cpython-310.pyc
o
�$�a� � @ s� d Z ddlZddlZddlmZmZmZ ddlmZ ddl m
Z
mZ ddlm
Z
er0ddlmZ dded ed
eddd
df
dd�Zdd� dddfded ede
d
edddeeegdf d
dfdd�ZdS )z�
sphinx.util.fileutil
~~~~~~~~~~~~~~~~~~~~
File utility functions for Sphinx.
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
� N)�
TYPE_CHECKING�Callable�Dict)�
relative_path)�copyfile� ensuredir)�PathMatcher)�BaseRenderer�source�destination�context�rendererr �returnc C s t j�| �sdS t j�|�rt j�|t j�| ��}| �� �d�r�|dur�|du r1ddlm } |� }t
| dd��@}|�� �d�rE|dd� }t
|ddd��}|�|�|�
� |�� W d � n1 sbw Y W d � dS W d � dS 1 szw Y dS 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
N�_tr ��SphinxRendererzutf-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�fdst� r$ �6/usr/lib/python3/dist-packages/sphinx/util/fileutil.py�copy_asset_file s$ ��"�r&