mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Avoid confusing PIL warning for vector graphics (epub builder).
This commit is contained in:
parent
f010460438
commit
548325c4e9
@ -155,6 +155,8 @@ _media_types = {
|
||||
'.ttf': 'application/x-font-ttf',
|
||||
}
|
||||
|
||||
_vector_graphics_extensions = ('.svg',)
|
||||
|
||||
# Regular expression to match colons only in local fragment identifiers.
|
||||
# If the URI contains a colon before the #,
|
||||
# it is an external link that should not change.
|
||||
@ -393,6 +395,11 @@ class EpubBuilder(StandaloneHTMLBuilder):
|
||||
subentrylinks[i] = (ismain,
|
||||
self.fix_fragment(m.group(1), m.group(2)))
|
||||
|
||||
def is_vector_graphics(self, filename):
|
||||
"""Does the filename extension indicate a vector graphic format?"""
|
||||
ext = path.splitext(filename)[-1]
|
||||
return ext in _vector_graphics_extensions
|
||||
|
||||
def copy_image_files_pil(self):
|
||||
"""Copy images using the PIL.
|
||||
The method tries to read and write the files with the PIL,
|
||||
@ -405,6 +412,7 @@ class EpubBuilder(StandaloneHTMLBuilder):
|
||||
try:
|
||||
img = Image.open(path.join(self.srcdir, src))
|
||||
except IOError:
|
||||
if not self.is_vector_graphics(src):
|
||||
self.warn('cannot read image file %r: copying it instead' %
|
||||
(path.join(self.srcdir, src), ))
|
||||
try:
|
||||
|
Loading…
Reference in New Issue
Block a user