1. Matt McClure
  2. sphinx


Roland Meister  committed d22d42e

Avoid confusing PIL warning for vector graphics (epub builder).

  • Participants
  • Parent commits 674cb6e
  • Branches default

Comments (0)

Files changed (1)

File sphinx/builders/epub.py

View file
     '.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.
                             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,
                 img = Image.open(path.join(self.srcdir, src))
             except IOError:
-                self.warn('cannot read image file %r: copying it instead' %
-                          (path.join(self.srcdir, src), ))
+                if not self.is_vector_graphics(src):
+                    self.warn('cannot read image file %r: copying it instead' %
+                              (path.join(self.srcdir, src), ))
                     copyfile(path.join(self.srcdir, src),
                              path.join(self.outdir, '_images', dest))