mirror of https://gitlab.com/ita1024/waf.git
Docs
This commit is contained in:
parent
06c7c09681
commit
6648d3e6e7
|
@ -187,18 +187,16 @@ def writef(fname, data, m='w', encoding='ISO8859-1'):
|
||||||
def h_file(fname):
|
def h_file(fname):
|
||||||
"""
|
"""
|
||||||
Compute a hash value for a file by using md5. This method may be replaced by
|
Compute a hash value for a file by using md5. This method may be replaced by
|
||||||
a faster version if necessary. The following uses the file size and the timestamp value::
|
a faster version if necessary. The following uses the file size and the timestamp value.
|
||||||
|
The performance change can be 0.858s to 0.642s on no-op builds::
|
||||||
|
|
||||||
import stat
|
import stat
|
||||||
from waflib import Utils
|
from waflib import Utils
|
||||||
def h_file(fname):
|
def h_file(fname):
|
||||||
st = os.stat(fname)
|
st = os.stat(fname)
|
||||||
if stat.S_ISDIR(st[stat.ST_MODE]): raise IOError('not a file')
|
if stat.S_ISDIR(st[stat.ST_MODE]): raise IOError('not a file')
|
||||||
m = Utils.md5()
|
s = "%s%s%s" % (st.st_mtime, st.st_size, fname)
|
||||||
m.update(str(st.st_mtime))
|
return Utils.md5(s.encode()).digest()
|
||||||
m.update(str(st.st_size))
|
|
||||||
m.update(fname)
|
|
||||||
return m.digest()
|
|
||||||
Utils.h_file = h_file
|
Utils.h_file = h_file
|
||||||
|
|
||||||
:type fname: string
|
:type fname: string
|
||||||
|
|
Loading…
Reference in New Issue