Revision: 5419
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5419&view=rev
Author:   efiring
Date:     2008-06-07 18:23:21 -0700 (Sat, 07 Jun 2008)

Log Message:
-----------
List backends only in rcsetup

Modified Paths:
--------------
    trunk/matplotlib/CHANGELOG
    trunk/matplotlib/examples/tests/backend_driver.py
    trunk/matplotlib/lib/matplotlib/__init__.py
    trunk/matplotlib/lib/matplotlib/backends/__init__.py
    trunk/matplotlib/lib/matplotlib/rcsetup.py

Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG  2008-06-07 21:51:26 UTC (rev 5418)
+++ trunk/matplotlib/CHANGELOG  2008-06-08 01:23:21 UTC (rev 5419)
@@ -1,4 +1,8 @@
-2008-06-06 hist() revision, applied ideas proposed by Erik Tollerud and 
+2008=06-07 Moved list of backends to rcsetup.py; made use of lower
+           case for backend names consistent; use validate_backend
+           when importing backends subpackage - EF
+
+2008-06-06 hist() revision, applied ideas proposed by Erik Tollerud and
            Olle Engdegard: make histtype='step' unfilled by default
            and introduce histtype='stepfilled'; use default color
            cycle; introduce reverse cumulative histogram; new align

Modified: trunk/matplotlib/examples/tests/backend_driver.py
===================================================================
--- trunk/matplotlib/examples/tests/backend_driver.py   2008-06-07 21:51:26 UTC 
(rev 5418)
+++ trunk/matplotlib/examples/tests/backend_driver.py   2008-06-08 01:23:21 UTC 
(rev 5419)
@@ -17,9 +17,10 @@
 
 from __future__ import division
 import os, time, sys, glob
-import matplotlib.backends as mplbe
 
-all_backends = [b.lower() for b in mplbe.all_backends]
+import matplotlib.rcsetup as rcsetup
+
+all_backends = list(rcsetup.all_backends)  # to leave the original list alone
 all_backends.extend(['cairo.png', 'cairo.ps', 'cairo.pdf', 'cairo.svg'])
 
 pylab_dir = os.path.join('..', 'pylab_examples')
@@ -189,7 +190,7 @@
                 line_lstrip.startswith('show')):
                 continue
             tmpfile.write(line)
-        if backend in mplbe.interactive_bk:
+        if backend in rcsetup.interactive_bk:
             tmpfile.write('show()')
         else:
             tmpfile.write('savefig("%s", dpi=150)' % outfile)
@@ -205,12 +206,13 @@
 
 if __name__ == '__main__':
     times = {}
-    default_backends = ['Agg', 'PS', 'SVG', 'PDF', 'Template']
+    default_backends = ['agg', 'ps', 'svg', 'pdf', 'template']
     if len(sys.argv)==2 and sys.argv[1]=='--clean':
         localdirs = [d for d in glob.glob('*') if os.path.isdir(d)]
         all_backends_set = set(all_backends)
         for d in localdirs:
-            if d.lower() not in all_backends_set: continue
+            if d.lower() not in all_backends_set:
+                continue
             print 'removing %s'%d
             for fname in glob.glob(os.path.join(d, '*')):
                 os.remove(fname)

Modified: trunk/matplotlib/lib/matplotlib/__init__.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/__init__.py 2008-06-07 21:51:26 UTC (rev 
5418)
+++ trunk/matplotlib/lib/matplotlib/__init__.py 2008-06-08 01:23:21 UTC (rev 
5419)
@@ -763,14 +763,15 @@
     """
     if 'matplotlib.backends' in sys.modules:
         if warn: warnings.warn(_use_error_msg)
+    arg = arg.lower()
     be_parts = arg.split('.')
     name = validate_backend(be_parts[0])
     rcParams['backend'] = name
-    if name == 'Cairo' and len(be_parts) > 1:
+    if name == 'cairo' and len(be_parts) > 1:
         rcParams['cairo.format'] = validate_cairo_format(be_parts[1])
 
 def get_backend():
-    return rcParams['backend']
+    return rcParams['backend'].lower()
 
 def interactive(b):
     """

Modified: trunk/matplotlib/lib/matplotlib/backends/__init__.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/__init__.py        2008-06-07 
21:51:26 UTC (rev 5418)
+++ trunk/matplotlib/lib/matplotlib/backends/__init__.py        2008-06-08 
01:23:21 UTC (rev 5419)
@@ -1,25 +1,19 @@
-import sys
+
 import matplotlib
-import time
+from matplotlib.rcsetup import interactive_bk
+from matplotlib.rcsetup import validate_backend
 
 __all__ = ['backend','show','draw_if_interactive',
            'new_figure_manager', 'backend_version']
 
-interactive_bk = ['GTK', 'GTKAgg', 'GTKCairo', 'FltkAgg', 'QtAgg', 'Qt4Agg',
-                  'TkAgg', 'WX', 'WXAgg', 'CocoaAgg']
-non_interactive_bk = ['Agg2', 'Agg', 'Cairo', 'EMF', 'GDK',
-                      'Pdf', 'PS', 'SVG', 'Template']
-all_backends = interactive_bk + non_interactive_bk
+backend = matplotlib.get_backend()   # makes sure it is lower case
+validate_backend(backend)
 
-backend = matplotlib.get_backend()
-if backend not in all_backends:
-    raise ValueError, 'Unrecognized backend %s' % backend
-
 def pylab_setup():
     'return new_figure_manager, draw_if_interactive and show for pylab'
     # Import the requested backend into a generic module object
 
-    backend_name = 'backend_'+backend.lower()
+    backend_name = 'backend_'+backend
     backend_mod = __import__('matplotlib.backends.'+backend_name,
                              globals(),locals(),[backend_name])
 
@@ -42,7 +36,7 @@
 
     # Additional imports which only happen for certain backends.  This section
     # should probably disappear once all backends are uniform.
-    if backend in ['WX','WXAgg']:
+    if backend in ['wx','wxagg']:
         Toolbar = backend_mod.Toolbar
         __all__.append('Toolbar')
 

Modified: trunk/matplotlib/lib/matplotlib/rcsetup.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/rcsetup.py  2008-06-07 21:51:26 UTC (rev 
5418)
+++ trunk/matplotlib/lib/matplotlib/rcsetup.py  2008-06-08 01:23:21 UTC (rev 
5419)
@@ -12,6 +12,13 @@
 from matplotlib.fontconfig_pattern import parse_fontconfig_pattern
 from matplotlib.colors import is_color_like
 
+interactive_bk = ['GTK', 'GTKAgg', 'GTKCairo', 'FltkAgg', 'QtAgg', 'Qt4Agg',
+                  'TkAgg', 'WX', 'WXAgg', 'CocoaAgg']
+non_interactive_bk = ['Agg', 'Cairo', 'EMF', 'GDK',
+                      'Pdf', 'PS', 'SVG', 'Template']
+all_backends = interactive_bk + non_interactive_bk
+
+
 class ValidateInStrings:
     def __init__(self, key, valid, ignorecase=False):
         'valid is a list of legal strings'
@@ -80,11 +87,7 @@
             raise ValueError('Supported Postscript/PDF font types are %s' % 
fonttypes.values())
         return fonttype
 
-validate_backend = ValidateInStrings('backend',[
-    'Agg2', 'Agg', 'Aqt', 'Cairo', 'CocoaAgg', 'EMF', 'GD', 'GDK',
-    'GTK', 'GTKAgg', 'GTKCairo', 'FltkAgg', 'Paint', 'Pdf', 'PS',
-    'QtAgg', 'Qt4Agg', 'SVG', 'Template', 'TkAgg', 'WX', 'WXAgg',
-    ], ignorecase=True)
+validate_backend = ValidateInStrings('backend', all_backends, ignorecase=True)
 
 validate_numerix = ValidateInStrings('numerix',[
     'Numeric','numarray','numpy',


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

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to