Revision: 5885
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5885&view=rev
Author: ryanmay
Date: 2008-07-26 04:50:56 +0000 (Sat, 26 Jul 2008)
Log Message:
-----------
Change to try to import md5 from hashlib, and fall back to md5. Change the
uses of md5 to work with either.
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/backends/backend_ps.py
trunk/matplotlib/lib/matplotlib/backends/backend_svg.py
trunk/matplotlib/lib/matplotlib/finance.py
trunk/matplotlib/lib/matplotlib/texmanager.py
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_ps.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2008-07-26
00:34:02 UTC (rev 5884)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2008-07-26
04:50:56 UTC (rev 5885)
@@ -3,9 +3,14 @@
"""
from __future__ import division
-import glob, math, md5, os, shutil, sys, time
+import glob, math, os, shutil, sys, time
def _fn_name(): return sys._getframe(1).f_code.co_name
+try:
+ from hashlib import md5
+except ImportError:
+ from md5 import md5 #Deprecated in 2.5
+
from tempfile import gettempdir
from cStringIO import StringIO
from matplotlib import verbose, __version__, rcParams
@@ -892,10 +897,10 @@
passed_in_file_object = False
if is_string_like(outfile):
title = outfile
- tmpfile = os.path.join(gettempdir(), md5.md5(outfile).hexdigest())
+ tmpfile = os.path.join(gettempdir(), md5(outfile).hexdigest())
elif is_writable_file_like(outfile):
title = None
- tmpfile = os.path.join(gettempdir(),
md5.md5(str(hash(outfile))).hexdigest())
+ tmpfile = os.path.join(gettempdir(),
md5(str(hash(outfile))).hexdigest())
passed_in_file_object = True
else:
raise ValueError("outfile must be a path or a file-like object")
@@ -1033,7 +1038,7 @@
title = outfile
# write to a temp file, we'll move it to outfile when done
- tmpfile = os.path.join(gettempdir(), md5.md5(outfile).hexdigest())
+ tmpfile = os.path.join(gettempdir(), md5(outfile).hexdigest())
fh = file(tmpfile, 'w')
self.figure.dpi = 72 # ignore the dpi kwarg
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_svg.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_svg.py 2008-07-26
00:34:02 UTC (rev 5884)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_svg.py 2008-07-26
04:50:56 UTC (rev 5885)
@@ -1,7 +1,12 @@
from __future__ import division
-import os, codecs, base64, tempfile, urllib, gzip, md5, cStringIO
+import os, codecs, base64, tempfile, urllib, gzip, cStringIO
+try:
+ from hashlib import md5
+except ImportError:
+ from md5 import md5 #Deprecated in 2.5
+
from matplotlib import verbose, __version__, rcParams
from matplotlib.backend_bases import RendererBase, GraphicsContextBase,\
FigureManagerBase, FigureCanvasBase
@@ -127,7 +132,7 @@
id = self._clipd.get(path)
if id is None:
- id = 'p%s' % md5.new(path).hexdigest()
+ id = 'p%s' % md5(path).hexdigest()
self._svgwriter.write('<defs>\n <clipPath id="%s">\n' % id)
self._svgwriter.write(path)
self._svgwriter.write('\n </clipPath>\n</defs>')
@@ -191,7 +196,7 @@
key = self._convert_path(marker_path, marker_trans +
Affine2D().scale(1.0, -1.0))
name = self._markers.get(key)
if name is None:
- name = 'm%s' % md5.new(key).hexdigest()
+ name = 'm%s' % md5(key).hexdigest()
write('<defs><path id="%s" d="%s"/></defs>\n' % (name, key))
self._markers[key] = name
@@ -223,7 +228,7 @@
transform = Affine2D(transform.get_matrix()).scale(1.0, -1.0)
d = self._convert_path(path, transform)
name = 'coll%x_%x_%s' % (self._path_collection_id, i,
- md5.new(d).hexdigest())
+ md5(d).hexdigest())
write('<path id="%s" d="%s"/>\n' % (name, d))
path_codes.append(name)
write('</defs>\n')
@@ -412,7 +417,7 @@
if step[0] != 4:
currx, curry = step[-2], -step[-1]
path_data = ''.join(path_data)
- char_num = 'c_%s' % md5.new(path_data).hexdigest()
+ char_num = 'c_%s' % md5(path_data).hexdigest()
path_element = '<path id="%s" d="%s"/>\n' % (char_num,
''.join(path_data))
self._char_defs[char_id] = char_num
return path_element
Modified: trunk/matplotlib/lib/matplotlib/finance.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/finance.py 2008-07-26 00:34:02 UTC (rev
5884)
+++ trunk/matplotlib/lib/matplotlib/finance.py 2008-07-26 04:50:56 UTC (rev
5885)
@@ -4,9 +4,13 @@
"""
#from __future__ import division
-import os, time, warnings, md5
+import os, time, warnings
from urllib import urlopen
+try:
+ from hashlib import md5
+except ImportError:
+ from md5 import md5 #Deprecated in 2.5
try: import datetime
except ImportError:
@@ -111,7 +115,7 @@
if cachename is None:
- cachename = os.path.join(cachedir, md5.md5(url).hexdigest())
+ cachename = os.path.join(cachedir, md5(url).hexdigest())
if os.path.exists(cachename):
fh = file(cachename)
verbose.report('Using cachefile %s for %s'%(cachename, ticker))
Modified: trunk/matplotlib/lib/matplotlib/texmanager.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/texmanager.py 2008-07-26 00:34:02 UTC
(rev 5884)
+++ trunk/matplotlib/lib/matplotlib/texmanager.py 2008-07-26 04:50:56 UTC
(rev 5885)
@@ -33,7 +33,13 @@
"""
-import copy, glob, md5, os, shutil, sys, warnings
+import copy, glob, os, shutil, sys, warnings
+
+try:
+ from hashlib import md5
+except ImportError:
+ from md5 import md5 #Deprecated in 2.5
+
import distutils.version
import numpy as np
import matplotlib as mpl
@@ -166,7 +172,7 @@
self.get_custom_preamble(), str(dpi or '')])
# make sure hash is consistent for all strings, regardless of encoding:
bytes = unicode(s).encode('utf-8')
- return os.path.join(self.texcache, md5.md5(bytes).hexdigest())
+ return os.path.join(self.texcache, md5(bytes).hexdigest())
def get_font_config(self):
"""Reinitializes self if relevant rcParams on have changed."""
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins