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',
|
'.ttf': 'application/x-font-ttf',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_vector_graphics_extensions = ('.svg',)
|
||||||
|
|
||||||
# Regular expression to match colons only in local fragment identifiers.
|
# Regular expression to match colons only in local fragment identifiers.
|
||||||
# If the URI contains a colon before the #,
|
# If the URI contains a colon before the #,
|
||||||
# it is an external link that should not change.
|
# it is an external link that should not change.
|
||||||
@ -393,6 +395,11 @@ class EpubBuilder(StandaloneHTMLBuilder):
|
|||||||
subentrylinks[i] = (ismain,
|
subentrylinks[i] = (ismain,
|
||||||
self.fix_fragment(m.group(1), m.group(2)))
|
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):
|
def copy_image_files_pil(self):
|
||||||
"""Copy images using the PIL.
|
"""Copy images using the PIL.
|
||||||
The method tries to read and write the files with the PIL,
|
The method tries to read and write the files with the PIL,
|
||||||
@ -405,8 +412,9 @@ class EpubBuilder(StandaloneHTMLBuilder):
|
|||||||
try:
|
try:
|
||||||
img = Image.open(path.join(self.srcdir, src))
|
img = Image.open(path.join(self.srcdir, src))
|
||||||
except IOError:
|
except IOError:
|
||||||
self.warn('cannot read image file %r: copying it instead' %
|
if not self.is_vector_graphics(src):
|
||||||
(path.join(self.srcdir, src), ))
|
self.warn('cannot read image file %r: copying it instead' %
|
||||||
|
(path.join(self.srcdir, src), ))
|
||||||
try:
|
try:
|
||||||
copyfile(path.join(self.srcdir, src),
|
copyfile(path.join(self.srcdir, src),
|
||||||
path.join(self.outdir, '_images', dest))
|
path.join(self.outdir, '_images', dest))
|
||||||
|
Loading…
Reference in New Issue
Block a user