Revision 716a32cb lib/compat.py
b/lib/compat.py | ||
---|---|---|
31 | 31 |
functools = None |
32 | 32 |
|
33 | 33 |
|
34 |
# compat.md5_hash and compat.sha1_hash can be called to generate and md5 and a |
|
35 |
# sha1 hashing modules, under python 2.4, 2.5 and 2.6, even though some changes |
|
36 |
# went on. compat.sha1 is python-version specific and is used for python |
|
37 |
# modules (hmac, for example) which have changed their behavior as well from |
|
38 |
# one version to the other. |
|
39 |
try: |
|
40 |
# Yes, we're not using the imports in this module. |
|
41 |
# pylint: disable-msg=W0611 |
|
42 |
from hashlib import md5 as md5_hash |
|
43 |
from hashlib import sha1 as sha1_hash |
|
44 |
# this additional version is needed for compatibility with the hmac module |
|
45 |
sha1 = sha1_hash |
|
46 |
except ImportError: |
|
47 |
from md5 import new as md5_hash |
|
48 |
import sha |
|
49 |
sha1 = sha |
|
50 |
sha1_hash = sha.new |
|
51 |
|
|
52 |
|
|
34 | 53 |
def all(seq, pred=bool): # pylint: disable-msg=W0622 |
35 | 54 |
"""Returns True if pred(x) is True for every element in the iterable. |
36 | 55 |
|
Also available in: Unified diff