File: //usr/lib/python3/dist-packages/sphinx/ext/__pycache__/imgconverter.cpython-310.pyc
o
�$�a�
� @ s� d Z ddlZddlZddlmZmZ ddlmZmZ ddlm Z ddl
mZ ddlm
Z
ddlmZ dd lmZ e�e�ZG d
d� de�Zde d
eeef fdd�ZdS )z�
sphinx.ext.imgconverter
~~~~~~~~~~~~~~~~~~~~~~~
Image converter extension for Sphinx
:copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
� N)�PIPE�CalledProcessError)�Any�Dict)�Sphinx)�ExtensionError)�__)�ImageConverter)�loggingc @ s8 e Zd Zg d�Zdefdd�Zdededefdd�Zd S )
�ImagemagickConverter))z
image/svg+xml� image/png)z image/gifr )zapplication/pdfr )zapplication/illustratorr �returnc
C s� z| j jdg}t�d|� tj|ttdd� W dS ty6 } zt�t d�| j j|� W Y d}~dS d}~w t
yS } zt�t d�|j|j� W Y d}~dS d}~ww ) z+Confirms the converter is available or not.z-version�Invoking %r ...T��stdout�stderr�checkzGconvert command %r cannot be run, check the image_converter setting: %sNF�2convert exited with error:
[stderr]
%r
[stdout]
%r)
�config�image_converter�logger�debug�
subprocess�runr �OSError�warningr r r r )�self�args�exc� r �9/usr/lib/python3/dist-packages/sphinx/ext/imgconverter.py�is_available! s$
��
���z!ImagemagickConverter.is_available�_from�_toc
C s� z#|d7 }| j jg| j j ||g }t�d|� tj|ttdd� W dS ty7 t� t
d�| j j� Y dS tyO } z
tt
d�|j
|jf �|�d}~ww ) z#Converts the image to expected one.z[0]r Tr zCconvert command %r cannot be run, check the image_converter settingFr N)r r �image_converter_argsr r r r r r r r r r r r )r r"