5 Re-calculate md5 hashes of files only when the file time have changed::
10 The hashes can also reflect either the file contents (STRONGEST=True) or the
11 file time and file size.
13 The performance benefits of this module are usually insignificant.
17 from waflib import Utils, Build, Node
21 Build.SAVED_ATTRS.append('hashes_md5_tstamp')
23 filename = self.abspath()
24 st = os.stat(filename)
26 cache = self.ctx.hashes_md5_tstamp
27 if filename in cache and cache[filename][0] == st.st_mtime:
28 return cache[filename][1]
31 ret = Utils.h_file(filename)
33 if stat.S_ISDIR(st[stat.ST_MODE]):
34 raise IOError('Not a file')
35 ret = Utils.md5(str((st.st_mtime, st.st_size)).encode()).digest()
37 cache[filename] = (st.st_mtime, ret)
39 h_file.__doc__ = Node.Node.h_file.__doc__
40 Node.Node.h_file = h_file