"""
return new == old
-def hexdigest(s):
- """Return a signature as a string of hex characters.
- """
- # NOTE: This routine is a method in the Python 2.0 interface
- # of the native md5 module, but we want SCons to operate all
- # the way back to at least Python 1.5.2, which doesn't have it.
- h = string.hexdigits
- r = ''
- for c in s:
- i = ord(c)
- r = r + h[(i >> 4) & 0xF] + h[i & 0xF]
- return r
-
try:
- a = md5.new('test').hexdigest()
+ md5.new('').hexdigest
except AttributeError:
- md5sig = lambda c: hexdigest(md5.new(str(c)).digest())
-else:
- md5sig = lambda c: md5.new(str(c)).hexdigest()
+ # The md5 objects created by the module have no native hexdigest()
+ # method (*cough* 1.5.2 *cough*) so provide an equivalent.
+ class new_md5:
+ def __init__(self, s):
+ self.m = md5.new(str(s))
+ #def copy(self):
+ # return self.m.copy()
+ def digest(self):
+ return self.m.digest()
+ def hexdigest(self):
+ h = string.hexdigits
+ r = ''
+ for c in self.m.digest():
+ i = ord(c)
+ r = r + h[(i >> 4) & 0xF] + h[i & 0xF]
+ return r
+ def update(self, s):
+ return self.m.update(s)
+else:
+ new_md5 = lambda s: md5.new(str(s))
def collect(signatures):
"""
returns - the aggregate signature
"""
if len(signatures) == 1:
- return signatures[0]
+ return signatures[0]
else:
- contents = string.join(signatures, ', ')
- return hexdigest(md5.new(contents).digest())
+ return new_md5(string.join(signatures, ', ')).hexdigest()
def signature(obj):
"""Generate a signature for an object
gc = obj.get_contents
except AttributeError:
raise AttributeError, "unable to fetch contents of '%s'" % str(obj)
- return md5sig(gc())
+ return new_md5(gc()).hexdigest()
def to_string(signature):
"""Convert a signature to a string"""