diff options
author | Nate Case <ncase@xes-inc.com> | 2008-08-22 15:58:02 -0500 |
---|---|---|
committer | Jeremy Kerr <jk@ozlabs.org> | 2008-08-23 10:51:05 +0800 |
commit | 97d8d152a5f832f6266a33622e25f4ae5f7dc068 (patch) | |
tree | 71de5d5cf6ec9aafadc384a2fd5bd3bf77bb36ae /apps/patchwork/parser.py | |
parent | 8252a61e73126c2b89c97e4195c635bc3d60a3e9 (diff) | |
download | patchwork-97d8d152a5f832f6266a33622e25f4ae5f7dc068.tar.bz2 patchwork-97d8d152a5f832f6266a33622e25f4ae5f7dc068.tar.xz |
Eliminate hashlib requirement
If the hashlib module does not exist, use sha and md5 modules instead
to support Python 2.4. The hashlib module was added to Python 2.5.
Signed-off-by: Nate Case <ncase@xes-inc.com>
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'apps/patchwork/parser.py')
-rw-r--r-- | apps/patchwork/parser.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/apps/patchwork/parser.py b/apps/patchwork/parser.py index ecc1d4b..bb6fce0 100644 --- a/apps/patchwork/parser.py +++ b/apps/patchwork/parser.py @@ -21,7 +21,12 @@ import re -import hashlib +try: + import hashlib + sha1_hash = hashlib.sha1 +except ImportError: + import sha + sha1_hash = sha.sha _hunk_re = re.compile('^\@\@ -\d+(?:,(\d+))? \+\d+(?:,(\d+))? \@\@') _filename_re = re.compile('^(---|\+\+\+) (\S+)') @@ -158,7 +163,7 @@ def patch_hash(str): lines = str.split('\n') prefixes = ['-', '+', ' '] - hash = hashlib.sha1() + hash = sha1_hash() for line in str.split('\n'): |