mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Enable automatic formatting for `sphinx/ext/imgconverter.py
`
This commit is contained in:
parent
437a31d199
commit
f592962b8d
@ -415,7 +415,6 @@ exclude = [
|
||||
"sphinx/domains/python/_object.py",
|
||||
"sphinx/domains/rst.py",
|
||||
"sphinx/domains/std/__init__.py",
|
||||
"sphinx/ext/imgconverter.py",
|
||||
"sphinx/ext/imgmath.py",
|
||||
"sphinx/ext/inheritance_diagram.py",
|
||||
"sphinx/ext/linkcode.py",
|
||||
|
@ -37,18 +37,24 @@ class ImagemagickConverter(ImageConverter):
|
||||
subprocess.run(args, capture_output=True, check=True)
|
||||
return True
|
||||
except OSError as exc:
|
||||
logger.warning(__(
|
||||
"Unable to run the image conversion command %r. "
|
||||
"'sphinx.ext.imgconverter' requires ImageMagick by default. "
|
||||
"Ensure it is installed, or set the 'image_converter' option "
|
||||
"to a custom conversion command.\n\n"
|
||||
"Traceback: %s",
|
||||
), self.config.image_converter, exc)
|
||||
logger.warning(
|
||||
__(
|
||||
'Unable to run the image conversion command %r. '
|
||||
"'sphinx.ext.imgconverter' requires ImageMagick by default. "
|
||||
"Ensure it is installed, or set the 'image_converter' option "
|
||||
'to a custom conversion command.\n\n'
|
||||
'Traceback: %s',
|
||||
),
|
||||
self.config.image_converter,
|
||||
exc,
|
||||
)
|
||||
return False
|
||||
except CalledProcessError as exc:
|
||||
logger.warning(__('convert exited with error:\n'
|
||||
'[stderr]\n%r\n[stdout]\n%r'),
|
||||
exc.stderr, exc.stdout)
|
||||
logger.warning(
|
||||
__('convert exited with error:\n[stderr]\n%r\n[stdout]\n%r'),
|
||||
exc.stderr,
|
||||
exc.stdout,
|
||||
)
|
||||
return False
|
||||
|
||||
def convert(self, _from: str, _to: str) -> bool:
|
||||
@ -58,21 +64,28 @@ class ImagemagickConverter(ImageConverter):
|
||||
# (or first page) of image (ex. Animation GIF, PDF)
|
||||
_from += '[0]'
|
||||
|
||||
args = ([
|
||||
self.config.image_converter, *self.config.image_converter_args, _from, _to,
|
||||
])
|
||||
args = [
|
||||
self.config.image_converter,
|
||||
*self.config.image_converter_args,
|
||||
_from,
|
||||
_to,
|
||||
]
|
||||
logger.debug('Invoking %r ...', args)
|
||||
subprocess.run(args, capture_output=True, check=True)
|
||||
return True
|
||||
except OSError:
|
||||
logger.warning(__('convert command %r cannot be run, '
|
||||
'check the image_converter setting'),
|
||||
self.config.image_converter)
|
||||
logger.warning(
|
||||
__(
|
||||
'convert command %r cannot be run, check the image_converter setting'
|
||||
),
|
||||
self.config.image_converter,
|
||||
)
|
||||
return False
|
||||
except CalledProcessError as exc:
|
||||
raise ExtensionError(__('convert exited with error:\n'
|
||||
'[stderr]\n%r\n[stdout]\n%r') %
|
||||
(exc.stderr, exc.stdout)) from exc
|
||||
raise ExtensionError(
|
||||
__('convert exited with error:\n[stderr]\n%r\n[stdout]\n%r')
|
||||
% (exc.stderr, exc.stdout)
|
||||
) from exc
|
||||
|
||||
|
||||
def setup(app: Sphinx) -> ExtensionMetadata:
|
||||
|
Loading…
Reference in New Issue
Block a user