Mercurial > treepkg
changeset 457:b90bb9f2bb77
Use the Hashlib module instead of MD5 if the python version is >=2.5
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Tue, 24 Aug 2010 13:50:17 +0000 |
parents | e7e0ace683c6 |
children | 61e72399914c |
files | treepkg/util.py |
diffstat | 1 files changed, 9 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/treepkg/util.py Tue Aug 24 10:45:31 2010 +0000 +++ b/treepkg/util.py Tue Aug 24 13:50:17 2010 +0000 @@ -14,9 +14,11 @@ import fnmatch import pwd import os.path -import warnings -warnings.simplefilter("ignore", category=DeprecationWarning) -import md5 +import sys +if sys.version_info < (2, 5): + import md5 +else: + import hashlib import run @@ -167,7 +169,10 @@ raise RuntimeError("Could not create md5sum. File not found: %s" % filename) f = file(filename, 'rb') - m = md5.new() + if sys.version_info < (2, 5): + m = md5.new() + else: + m = hashlib.md5() while True: d = f.read(8096) if not d: