o $a @sdZddlZddlZddlmZmZddlmZmZddlm Z ddl m Z ddl m Z ddlmZdd lmZeeZGd d d eZd e d eeeffddZdS)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)PIPECalledProcessError)AnyDict)Sphinx)ExtensionError)__)ImageConverter)loggingc@s8eZdZgdZdefddZdededefddZd S) ImagemagickConverter))z image/svg+xml image/png)z image/gifr )zapplication/pdfr )zapplication/illustratorr returnc Csz|jjdg}td|tj|ttddWdSty6}ztt d|jj|WYd}~dSd}~wt yS}ztt d|j |j WYd}~dSd}~ww) z+Confirms the converter is available or not.z-versionInvoking %r ...TstdoutstderrcheckzGconvert command %r cannot be run, check the image_converter setting: %sNF2convert exited with error: [stderr] %r [stdout] %r) configimage_converterloggerdebug subprocessrunrOSErrorwarningrrrr)selfargsexcr9/usr/lib/python3/dist-packages/sphinx/ext/imgconverter.py is_available!s$    z!ImagemagickConverter.is_available_from_toc Csz#|d7}|jjg|jj||g}td|tj|ttddWdSty7t t d|jjYdSt yO}z t t d|j |jf|d}~ww) z#Converts the image to expected one.z[0]rTrzCconvert command %r cannot be run, check the image_converter settingFrN)rrimage_converter_argsrrrrrrrrrrrr)rr"r#rrrrr convert3s.    zImagemagickConverter.convertN)__name__ __module__ __qualname__conversion_rulesboolr!strr%rrrr r sr appr cCs\|ttjdkr|ddd|ddgdn|ddd|dgddddd S) Nwin32rmagickenvr$r%builtinT)versionparallel_read_safeparallel_write_safe)add_post_transformr sysplatformadd_config_value)r,rrr setupKs  r8)__doc__rr5rrtypingrrsphinx.applicationr sphinx.errorsr sphinx.localer(sphinx.transforms.post_transforms.imagesr sphinx.utilr getLoggerr&rr r+r8rrrr s       2