diff options
author | Steven Knight <knight@baldmt.com> | 2004-12-16 17:35:43 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2004-12-16 17:35:43 (GMT) |
commit | 6c6137058464d27acce561c3c1d89e77068a1342 (patch) | |
tree | 52c3479a424822b0953f89f6e03cbfbac152f3f1 | |
parent | 64c24fdd205f1d3fe584990aaf6ae050bb46c431 (diff) | |
download | SCons-6c6137058464d27acce561c3c1d89e77068a1342.zip SCons-6c6137058464d27acce561c3c1d89e77068a1342.tar.gz SCons-6c6137058464d27acce561c3c1d89e77068a1342.tar.bz2 |
Use the builtin md5 hexdigest routine if it's available. (Kevin Quick)
-rw-r--r-- | src/CHANGES.txt | 4 | ||||
-rw-r--r-- | src/engine/SCons/Sig/MD5.py | 14 |
2 files changed, 14 insertions, 4 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 9f6328f..55e74ff 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -332,7 +332,9 @@ RELEASE 0.97 - XXX - Internal cleanups: Remove an unnecessary scan argument. Associate Scanners only with Builders, not nodes. Apply overrides once when a - Builder is called, not in multiple places. + Builder is called, not in multiple places. Cache results from + the Node.FS.get_suffix() and Node.get_build_env() methods. Use + the Python md5 modules' hexdigest() method, if there is one. - Use the correct scanner if the same source file is used for targets in two different environments with the same path but different scanners. diff --git a/src/engine/SCons/Sig/MD5.py b/src/engine/SCons/Sig/MD5.py index 21cb24c..2adcee0 100644 --- a/src/engine/SCons/Sig/MD5.py +++ b/src/engine/SCons/Sig/MD5.py @@ -58,10 +58,18 @@ def hexdigest(s): h = string.hexdigits r = '' for c in s: - i = ord(c) - r = r + h[(i >> 4) & 0xF] + h[i & 0xF] + i = ord(c) + r = r + h[(i >> 4) & 0xF] + h[i & 0xF] return r +try: + a = md5.new('test').hexdigest() +except AttributeError: + md5sig = lambda c: hexdigest(md5.new(str(c)).digest()) +else: + md5sig = lambda c: md5.new(str(c)).hexdigest() + + def collect(signatures): """ Collect a list of signatures into an aggregate signature. @@ -82,7 +90,7 @@ def signature(obj): gc = obj.get_contents except AttributeError: raise AttributeError, "unable to fetch contents of '%s'" % str(obj) - return hexdigest(md5.new(str(gc())).digest()) + return md5sig(gc()) def to_string(signature): """Convert a signature to a string""" |