Revision: 6142
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6142&view=rev
Author:   mdboom
Date:     2008-10-02 13:38:50 +0000 (Thu, 02 Oct 2008)

Log Message:
-----------
Fix all Python 2.6 deprecation warnings.

Modified Paths:
--------------
    trunk/matplotlib/lib/matplotlib/__init__.py
    trunk/matplotlib/lib/matplotlib/backends/backend_cairo.py
    trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py
    trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py
    trunk/matplotlib/lib/matplotlib/backends/backend_ps.py
    trunk/matplotlib/lib/matplotlib/backends/backend_qt.py
    trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py
    trunk/matplotlib/lib/matplotlib/backends/backend_wx.py
    trunk/matplotlib/lib/matplotlib/delaunay/triangulate.py
    trunk/matplotlib/lib/matplotlib/font_manager.py
    trunk/matplotlib/lib/matplotlib/mathtext.py
    trunk/matplotlib/lib/matplotlib/mlab.py
    trunk/matplotlib/lib/matplotlib/transforms.py
    trunk/matplotlib/lib/pytz/tzinfo.py
    trunk/matplotlib/setupext.py

Modified: trunk/matplotlib/lib/matplotlib/__init__.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/__init__.py 2008-10-01 14:20:28 UTC (rev 
6141)
+++ trunk/matplotlib/lib/matplotlib/__init__.py 2008-10-02 13:38:50 UTC (rev 
6142)
@@ -93,7 +93,7 @@
 __revision__ = '$Revision$'
 __date__     = '$Date$'
 
-import md5, os, re, shutil, sys, warnings
+import os, re, shutil, sys, warnings
 import distutils.sysconfig
 
 
@@ -234,7 +234,7 @@
         if always is True, the report will occur on every function
         call; otherwise only on the first time the function is called
         """
-        assert(callable, func)
+        assert callable(func)
         def wrapper(*args, **kwargs):
             ret = func(*args, **kwargs)
 

Modified: trunk/matplotlib/lib/matplotlib/backends/backend_cairo.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_cairo.py   2008-10-01 
14:20:28 UTC (rev 6141)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_cairo.py   2008-10-02 
13:38:50 UTC (rev 6142)
@@ -25,7 +25,11 @@
 
 def _fn_name(): return sys._getframe(1).f_code.co_name
 
-import cairo
+try:
+   import cairo
+except ImportError:
+   raise ImportError("Cairo backend requires that pycairo is installed.")
+
 _version_required = (1,2,0)
 if cairo.version_info < _version_required:
    raise ImportError ("Pycairo %d.%d.%d is installed\n"

Modified: trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py     2008-10-01 
14:20:28 UTC (rev 6141)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py     2008-10-02 
13:38:50 UTC (rev 6142)
@@ -3,9 +3,13 @@
 import os, sys
 def fn_name(): return sys._getframe(1).f_code.co_name
 
-import gobject
-import gtk; gdk = gtk.gdk
-import pango
+try:
+    import gobject
+    import gtk; gdk = gtk.gdk
+    import pango
+except ImportError:
+    raise ImportError("Gtk* backend requires pygtk to be installed.")
+
 pygtk_version_required = (2,2,0)
 if gtk.pygtk_version < pygtk_version_required:
     raise ImportError ("PyGTK %d.%d.%d is installed\n"

Modified: trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py     2008-10-01 
14:20:28 UTC (rev 6141)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py     2008-10-02 
13:38:50 UTC (rev 6142)
@@ -17,7 +17,10 @@
 from cStringIO import StringIO
 from datetime import datetime
 from math import ceil, cos, floor, pi, sin
-from sets import Set
+try:
+    set
+except NameError:
+    from sets import Set as set
 
 import matplotlib
 from matplotlib import __version__, rcParams, get_data_path
@@ -692,7 +695,7 @@
             cmap = font.get_charmap()
             glyph_ids = []
             differences = []
-            multi_byte_chars = Set()
+            multi_byte_chars = set()
             for c in characters:
                 ccode = c
                 gind = cmap.get(ccode) or 0
@@ -1215,14 +1218,14 @@
             fname = font.fname
         realpath, stat_key = get_realpath_and_stat(fname)
         used_characters = self.used_characters.setdefault(
-            stat_key, (realpath, Set()))
+            stat_key, (realpath, set()))
         used_characters[1].update([ord(x) for x in s])
 
     def merge_used_characters(self, other):
-        for stat_key, (realpath, set) in other.items():
+        for stat_key, (realpath, charset) in other.items():
             used_characters = self.used_characters.setdefault(
-                stat_key, (realpath, Set()))
-            used_characters[1].update(set)
+                stat_key, (realpath, set()))
+            used_characters[1].update(charset)
 
     def draw_image(self, x, y, im, bbox, clippath=None, clippath_trans=None):
         #print >>sys.stderr, "draw_image called"

Modified: trunk/matplotlib/lib/matplotlib/backends/backend_ps.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_ps.py      2008-10-01 
14:20:28 UTC (rev 6141)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_ps.py      2008-10-02 
13:38:50 UTC (rev 6142)
@@ -36,7 +36,10 @@
 import numpy as npy
 import binascii
 import re
-from sets import Set
+try:
+    set
+except NameError:
+    from sets import Set as set
 
 if sys.platform.startswith('win'): cmd_split = '&'
 else: cmd_split = ';'
@@ -173,14 +176,14 @@
         each font."""
         realpath, stat_key = get_realpath_and_stat(font.fname)
         used_characters = self.used_characters.setdefault(
-            stat_key, (realpath, Set()))
+            stat_key, (realpath, set()))
         used_characters[1].update([ord(x) for x in s])
 
     def merge_used_characters(self, other):
-        for stat_key, (realpath, set) in other.items():
+        for stat_key, (realpath, charset) in other.items():
             used_characters = self.used_characters.setdefault(
-                stat_key, (realpath, Set()))
-            used_characters[1].update(set)
+                stat_key, (realpath, set()))
+            used_characters[1].update(charset)
 
     def set_color(self, r, g, b, store=1):
         if (r,g,b) != self.color:

Modified: trunk/matplotlib/lib/matplotlib/backends/backend_qt.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_qt.py      2008-10-01 
14:20:28 UTC (rev 6141)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_qt.py      2008-10-02 
13:38:50 UTC (rev 6142)
@@ -13,7 +13,10 @@
 from matplotlib.mathtext import MathTextParser
 from matplotlib.widgets import SubplotTool
 
-import qt
+try:
+    import qt
+except ImportError:
+    raise ImportError("Qt backend requires pyqt to be installed.")
 
 backend_version = "0.9.1"
 def fn_name(): return sys._getframe(1).f_code.co_name

Modified: trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py     2008-10-01 
14:20:28 UTC (rev 6141)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py     2008-10-02 
13:38:50 UTC (rev 6142)
@@ -13,7 +13,10 @@
 from matplotlib.mathtext import MathTextParser
 from matplotlib.widgets import SubplotTool
 
-from PyQt4 import QtCore, QtGui, Qt
+try:
+    from PyQt4 import QtCore, QtGui, Qt
+except ImportError:
+    raise ImportError("Qt4 backend requires that PyQt4 is installed.")
 
 backend_version = "0.9.1"
 def fn_name(): return sys._getframe(1).f_code.co_name

Modified: trunk/matplotlib/lib/matplotlib/backends/backend_wx.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_wx.py      2008-10-01 
14:20:28 UTC (rev 6141)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_wx.py      2008-10-02 
13:38:50 UTC (rev 6142)
@@ -112,8 +112,7 @@
     import wx
     backend_version = wx.VERSION_STRING
 except:
-    print >>sys.stderr, "Matplotlib backend_wx requires wxPython be installed"
-    sys.exit()
+    raise ImportError("Matplotlib backend_wx requires wxPython be installed")
 
 #!!! this is the call that is causing the exception swallowing !!!
 #wx.InitAllImageHandlers()

Modified: trunk/matplotlib/lib/matplotlib/delaunay/triangulate.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/delaunay/triangulate.py     2008-10-01 
14:20:28 UTC (rev 6141)
+++ trunk/matplotlib/lib/matplotlib/delaunay/triangulate.py     2008-10-02 
13:38:50 UTC (rev 6142)
@@ -1,10 +1,8 @@
 import warnings
-# 2.3 compatibility
 try:
     set
 except NameError:
-    import sets
-    set = sets.Set
+    from sets import Set as set
 
 import numpy as np
 
@@ -98,7 +96,7 @@
         # Find the indices of the unique entries
         j_sorted = np.lexsort(keys=(self.x, self.y))
         mask_unique = np.hstack([
-            True, 
+            True,
             (np.diff(self.x[j_sorted]) != 0) | (np.diff(self.y[j_sorted]) != 
0),
         ])
         return j_sorted[mask_unique]

Modified: trunk/matplotlib/lib/matplotlib/font_manager.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/font_manager.py     2008-10-01 14:20:28 UTC 
(rev 6141)
+++ trunk/matplotlib/lib/matplotlib/font_manager.py     2008-10-02 13:38:50 UTC 
(rev 6142)
@@ -34,7 +34,10 @@
 """
 
 import os, sys, glob
-from sets import Set
+try:
+    set
+except NameError:
+    from sets import Set as set
 import matplotlib
 from matplotlib import afm
 from matplotlib import ft2font
@@ -1036,7 +1039,7 @@
                 verbose.report('findfont returning %s'%fname, 'debug')
             return fname
 
-        font_family_aliases = Set(['serif', 'sans-serif', 'cursive',
+        font_family_aliases = set(['serif', 'sans-serif', 'cursive',
                                    'fantasy', 'monospace', 'sans'])
 
         for name in prop.get_family():

Modified: trunk/matplotlib/lib/matplotlib/mathtext.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/mathtext.py 2008-10-01 14:20:28 UTC (rev 
6141)
+++ trunk/matplotlib/lib/matplotlib/mathtext.py 2008-10-02 13:38:50 UTC (rev 
6142)
@@ -175,7 +175,10 @@
 import os
 from cStringIO import StringIO
 from math import ceil
-from sets import Set
+try:
+    set
+except NameError:
+    from sets import Set as set
 import unicodedata
 from warnings import warn
 
@@ -531,7 +534,7 @@
         info = self._get_info(facename, font_class, sym, fontsize, dpi)
         realpath, stat_key = get_realpath_and_stat(info.font.fname)
         used_characters = self.used_characters.setdefault(
-            stat_key, (realpath, Set()))
+            stat_key, (realpath, set()))
         used_characters[1].add(info.num)
         self.mathtext_backend.render_glyph(ox, oy, info)
 
@@ -704,7 +707,7 @@
                 self.fontmap[val] = fullpath
 
 
-    _slanted_symbols = Set(r"\int \oint".split())
+    _slanted_symbols = set(r"\int \oint".split())
 
     def _get_glyph(self, fontname, font_class, sym, fontsize):
         symbol_name = None
@@ -816,7 +819,7 @@
             font = findfont(prop)
             self.fontmap['ex'] = font
 
-    _slanted_symbols = Set(r"\int \oint".split())
+    _slanted_symbols = set(r"\int \oint".split())
 
     def _map_virtual_font(self, fontname, font_class, uniindex):
         return fontname, uniindex
@@ -1967,7 +1970,7 @@
     return empty
 
 class Parser(object):
-    _binary_operators = Set(r'''
+    _binary_operators = set(r'''
       + *
       \pm             \sqcap                   \rhd
       \mp             \sqcup                   \unlhd
@@ -1982,7 +1985,7 @@
       \cup            \triangleright           \ddagger
       \uplus          \lhd                     \amalg'''.split())
 
-    _relation_symbols = Set(r'''
+    _relation_symbols = set(r'''
       = < > :
       \leq            \geq             \equiv           \models
       \prec           \succ            \sim             \perp
@@ -1995,7 +1998,7 @@
       \in             \ni              \propto
       \vdash          \dashv'''.split())
 
-    _arrow_symbols = Set(r'''
+    _arrow_symbols = set(r'''
       \leftarrow              \longleftarrow           \uparrow
       \Leftarrow              \Longleftarrow           \Uparrow
       \rightarrow             \longrightarrow          \downarrow
@@ -2010,32 +2013,32 @@
 
     _spaced_symbols = _binary_operators | _relation_symbols | _arrow_symbols
 
-    _punctuation_symbols = Set(r', ; . ! \ldotp \cdotp'.split())
+    _punctuation_symbols = set(r', ; . ! \ldotp \cdotp'.split())
 
-    _overunder_symbols = Set(r'''
+    _overunder_symbols = set(r'''
        \sum \prod \coprod \bigcap \bigcup \bigsqcup \bigvee
        \bigwedge \bigodot \bigotimes \bigoplus \biguplus
        '''.split())
 
-    _overunder_functions = Set(
+    _overunder_functions = set(
         r"lim liminf limsup sup max min".split())
 
-    _dropsub_symbols = Set(r'''\int \oint'''.split())
+    _dropsub_symbols = set(r'''\int \oint'''.split())
 
-    _fontnames = Set("rm cal it tt sf bf default bb frak circled scr".split())
+    _fontnames = set("rm cal it tt sf bf default bb frak circled scr".split())
 
-    _function_names = Set("""
+    _function_names = set("""
       arccos csc ker min arcsin deg lg Pr arctan det lim sec arg dim
       liminf sin cos exp limsup sinh cosh gcd ln sup cot hom log tan
       coth inf max tanh""".split())
 
-    _ambiDelim = Set(r"""
+    _ambiDelim = set(r"""
       | \| / \backslash \uparrow \downarrow \updownarrow \Uparrow
       \Downarrow \Updownarrow .""".split())
 
-    _leftDelim = Set(r"( [ { \lfloor \langle \lceil".split())
+    _leftDelim = set(r"( [ { \lfloor \langle \lceil".split())
 
-    _rightDelim = Set(r") ] } \rfloor \rangle \rceil".split())
+    _rightDelim = set(r") ] } \rfloor \rangle \rceil".split())
 
     def __init__(self):
         # All forward declarations are here
@@ -2381,7 +2384,7 @@
         r'^'     : r'\circumflexaccent'
         }
 
-    _wide_accents = Set(r"widehat widetilde".split())
+    _wide_accents = set(r"widehat widetilde".split())
 
     def accent(self, s, loc, toks):
         assert(len(toks)==1)

Modified: trunk/matplotlib/lib/matplotlib/mlab.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/mlab.py     2008-10-01 14:20:28 UTC (rev 
6141)
+++ trunk/matplotlib/lib/matplotlib/mlab.py     2008-10-02 13:38:50 UTC (rev 
6142)
@@ -96,7 +96,8 @@
 
 # set is a new builtin function in 2.4; delete the following when
 # support for 2.3 is dropped.
-try: set
+try:
+    set
 except NameError:
     from sets import Set as set
 

Modified: trunk/matplotlib/lib/matplotlib/transforms.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/transforms.py       2008-10-01 14:20:28 UTC 
(rev 6141)
+++ trunk/matplotlib/lib/matplotlib/transforms.py       2008-10-02 13:38:50 UTC 
(rev 6142)
@@ -36,7 +36,10 @@
 
 from weakref import WeakKeyDictionary
 import warnings
-import sets
+try:
+    set
+except NameError:
+    from sets import Set as set
 
 import cbook
 from path import Path
@@ -161,7 +164,7 @@
 
             fobj: A Python file-like object
             """
-            seen = sets.Set()
+            seen = set()
 
             def recurse(root):
                 if root in seen:

Modified: trunk/matplotlib/lib/pytz/tzinfo.py
===================================================================
--- trunk/matplotlib/lib/pytz/tzinfo.py 2008-10-01 14:20:28 UTC (rev 6141)
+++ trunk/matplotlib/lib/pytz/tzinfo.py 2008-10-02 13:38:50 UTC (rev 6142)
@@ -2,7 +2,10 @@
 
 from datetime import datetime, timedelta, tzinfo
 from bisect import bisect_right
-from sets import Set
+try:
+    set
+except NameError:
+    from sets import Set as set
 
 import pytz
 
@@ -71,7 +74,7 @@
     def fromutc(self, dt):
         '''See datetime.tzinfo.fromutc'''
         return (dt + self._utcoffset).replace(tzinfo=self)
-    
+
     def utcoffset(self,dt):
         '''See datetime.tzinfo.utcoffset'''
         return self._utcoffset
@@ -101,16 +104,16 @@
 
     def __reduce__(self):
         # Special pickle to zone remains a singleton and to cope with
-        # database changes. 
+        # database changes.
         return pytz._p, (self.zone,)
 
 
 class DstTzInfo(BaseTzInfo):
     '''A timezone that has a variable offset from UTC
-   
+
     The offset might change if daylight savings time comes into effect,
-    or at a point in history when the region decides to change their 
-    timezone definition. 
+    or at a point in history when the region decides to change their
+    timezone definition.
 
     '''
     # Overridden in subclass
@@ -191,13 +194,13 @@
 
     def localize(self, dt, is_dst=False):
         '''Convert naive time to local time.
-        
+
         This method should be used to construct localtimes, rather
         than passing a tzinfo argument to a datetime constructor.
 
         is_dst is used to determine the correct timezone in the ambigous
         period at the end of daylight savings time.
-        
+
         >>> from pytz import timezone
         >>> fmt = '%Y-%m-%d %H:%M:%S %Z (%z)'
         >>> amdam = timezone('Europe/Amsterdam')
@@ -226,7 +229,7 @@
         AmbiguousTimeError: 2004-10-31 02:00:00
 
         is_dst defaults to False
-        
+
         >>> amdam.localize(dt) == amdam.localize(dt, False)
         True
 
@@ -238,7 +241,7 @@
         # but we might end up with two if we are in the end-of-DST
         # transition period. Or possibly more in some particularly confused
         # location...
-        possible_loc_dt = Set()
+        possible_loc_dt = set()
         for tzinfo in self._tzinfos.values():
             loc_dt = tzinfo.normalize(dt.replace(tzinfo=tzinfo))
             if loc_dt.replace(tzinfo=None) == dt:
@@ -281,7 +284,7 @@
                     )
         filtered_possible_loc_dt.sort(mycmp)
         return filtered_possible_loc_dt[0]
-        
+
     def utcoffset(self, dt):
         '''See datetime.tzinfo.utcoffset'''
         return self._utcoffset
@@ -328,11 +331,11 @@
 
     See DstTzInfo.normalize() for more info
     '''
-       
 
+
 def unpickler(zone, utcoffset=None, dstoffset=None, tzname=None):
     """Factory function for unpickling pytz tzinfo instances.
-    
+
     This is shared for both StaticTzInfo and DstTzInfo instances, because
     database changes could cause a zones implementation to switch between
     these two base classes and we can't break pickles on a pytz version

Modified: trunk/matplotlib/setupext.py
===================================================================
--- trunk/matplotlib/setupext.py        2008-10-01 14:20:28 UTC (rev 6141)
+++ trunk/matplotlib/setupext.py        2008-10-02 13:38:50 UTC (rev 6142)
@@ -43,8 +43,8 @@
 
 import os
 import re
+import subprocess
 
-
 basedir = {
     'win32'  : ['win32_static',],
     'linux2' : ['/usr/local', '/usr'],
@@ -64,7 +64,6 @@
 import sys, os, stat
 if sys.platform != 'win32':
     import commands
-from sets import Set
 from textwrap import fill
 from distutils.core import Extension
 import glob
@@ -188,6 +187,14 @@
         pass
     print_status = print_message = print_raw = print_line
 
+def run_child_process(cmd):
+    p = subprocess.Popen(cmd, shell=True,
+                         stdin=subprocess.PIPE,
+                         stdout=subprocess.PIPE,
+                         stderr=subprocess.STDOUT,
+                         close_fds=True)
+    return p.stdin, p.stdout
+
 class CleanUpFile:
     """CleanUpFile deletes the specified filename when self is destroyed."""
     def __init__(self, name):
@@ -499,7 +506,7 @@
 
 def check_for_dvipng():
     try:
-        stdin, stdout = os.popen4('dvipng -version')
+        stdin, stdout = run_child_process('dvipng -version')
         print_status("dvipng", stdout.readlines()[1].split()[-1])
         return True
     except (IndexError, ValueError):
@@ -512,7 +519,7 @@
             command = 'gswin32c --version'
         else:
             command = 'gs --version'
-        stdin, stdout = os.popen4(command)
+        stdin, stdout = run_child_process(command)
         print_status("ghostscript", stdout.read()[:-1])
         return True
     except (IndexError, ValueError):
@@ -521,7 +528,7 @@
 
 def check_for_latex():
     try:
-        stdin, stdout = os.popen4('latex -version')
+        stdin, stdout = run_child_process('latex -version')
         line = stdout.readlines()[0]
         pattern = '3\.1\d+'
         match = re.search(pattern, line)
@@ -533,7 +540,7 @@
 
 def check_for_pdftops():
     try:
-        stdin, stdout = os.popen4('pdftops -v')
+        stdin, stdout = run_child_process('pdftops -v')
         for line in stdout.readlines():
             if 'version' in line:
                 print_status("pdftops", line.split()[-1])


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

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Matplotlib-checkins mailing list
Matplotlib-checkins@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to