From 6c6137058464d27acce561c3c1d89e77068a1342 Mon Sep 17 00:00:00 2001 From: Steven Knight Date: Thu, 16 Dec 2004 17:35:43 +0000 Subject: Use the builtin md5 hexdigest routine if it's available. (Kevin Quick) --- src/CHANGES.txt | 4 +++- 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""" -- cgit v0.12