Revision: 7831
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7831&view=rev
Author:   jouni
Date:     2009-09-28 17:40:49 +0000 (Mon, 28 Sep 2009)

Log Message:
-----------
Make it not an error if the system does not have gs

Modified Paths:
--------------
    trunk/matplotlib/lib/matplotlib/testing/compare.py
    trunk/matplotlib/lib/matplotlib/testing/decorators.py

Modified: trunk/matplotlib/lib/matplotlib/testing/compare.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/testing/compare.py  2009-09-27 19:06:37 UTC 
(rev 7830)
+++ trunk/matplotlib/lib/matplotlib/testing/compare.py  2009-09-28 17:40:49 UTC 
(rev 7831)
@@ -3,18 +3,21 @@
 """
 #=======================================================================
 
+import matplotlib
 import math
 import operator
 import os
 import numpy as np
 import shutil
 import subprocess
+import sys
 
 #=======================================================================
 
 __all__ = [
             'compare_float',
             'compare_images',
+            'comparable_formats',
           ]
 
 #-----------------------------------------------------------------------
@@ -77,17 +80,32 @@
 # A dictionary that maps filename extensions to functions that map
 # parameters old and new to a list that can be passed to Popen to
 # convert files with that extension to png format.
-converter = { 'pdf': lambda old, new: \
-                 ['gs', '-q', '-sDEVICE=png16m', '-dNOPAUSE', '-dBATCH',
-                  '-sOutputFile=' + new, old],
-              }
+converter = { }
+
+if matplotlib.checkdep_ghostscript() is not None:
+   # FIXME: make checkdep_ghostscript return the command
+   if sys.platform == 'win32':
+      gs = 'gswin32c'
+   else:
+      gs = 'gs'
+   cmd = lambda old, new: \
+       [gs, '-q', '-sDEVICE=png16m', '-dNOPAUSE', '-dBATCH',
+        '-sOutputFile=' + new, old]
+   converter['pdf'] = cmd
+   converter['eps'] = cmd
+
+def comparable_formats():
+   '''Returns the list of file formats that compare_images can compare
+   on this system.'''
+   return ['png'] + converter.keys()
+
 def convert(filename):
    '''Convert the named file into a png file.
    Returns the name of the created file.
    '''
    base, extension = filename.rsplit('.', 1)
    if extension not in converter:
-      raise KeyError, "Don't know how to convert %s files to png" % extension
+      raise NotImplementedError, "Don't know how to convert %s files to png" % 
extension
    newname = base + '_' + extension + '.png'
    cmd = converter[extension](filename, newname)
    pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

Modified: trunk/matplotlib/lib/matplotlib/testing/decorators.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/testing/decorators.py       2009-09-27 
19:06:37 UTC (rev 7830)
+++ trunk/matplotlib/lib/matplotlib/testing/decorators.py       2009-09-28 
17:40:49 UTC (rev 7831)
@@ -4,7 +4,7 @@
 import nose
 import matplotlib
 import matplotlib.tests
-from matplotlib.testing.compare import compare_images
+from matplotlib.testing.compare import comparable_formats, compare_images
 
 def knownfailureif(fail_condition, msg=None):
     """
@@ -88,6 +88,11 @@
                 for fname in baseline_images:
                     actual = os.path.join(result_dir, fname) + '.' + extension
                     expected = os.path.join(baseline_dir,fname) + '.' + 
extension
+                    if (extension not in comparable_formats()
+                        or not os.path.exists(expected)):
+                        # FIXME: Should it be a known fail if this format
+                        # cannot be compared in this environment?
+                        continue
 
                     # compare the images
                     tol=1e-3 # default tolerance


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to