Commits

clach04  committed 60315e4 Draft

Fakepil only complains about missing gfx lib if needed.

  • Participants
  • Parent commits 4c39c38

Comments (0)

Files changed (1)

File src/fakepil.py

 
 import os
 
-import png  # from http://code.google.com/p/pypng/
-import pygif  # from http://emesene.svn.sourceforge.net/viewvc/emesene/trunk/emesene/pygif/
+try:
+    import png  # from http://code.google.com/p/pypng/
+except ImportError:
+    png = None
+try:
+    import pygif  # from http://emesene.svn.sourceforge.net/viewvc/emesene/trunk/emesene/pygif/
+except ImportError:
+    pygif = None
 
 
 class ImagePalette(object):
 
 class PngImageFile(Image):
     def __init__(self, filename=None, fileobj=None):
+        if png is None:
+            raise ImportError('png module not available, obtain from http://code.google.com/p/pypng/')
         self.info = {}
         
         if filename is None:
 
 class GifImageFile(Image):
     def __init__(self, filename=None, fileobj=None):
+        if pygif is None:
+            raise ImportError('pygif module not available, obtain from http://emesene.svn.sourceforge.net/viewvc/emesene/trunk/emesene/pygif/')
+
         if filename:
             giffile = builtins_open(filename, 'rb')  # open is overridden to emulate Image module
             gifdata = giffile.read()