Mercurial > hg > truffle
comparison mxtool/mx.py @ 14156:7668297a2e67
mx: compute sha1 digest blockwise
author | Bernhard Urban <bernhard.urban@jku.at> |
---|---|
date | Wed, 12 Mar 2014 13:36:23 +0100 |
parents | 1ac6195ee586 |
children | 7c36ec150036 |
comparison
equal
deleted
inserted
replaced
14155:1ac6195ee586 | 14156:7668297a2e67 |
---|---|
355 with open(sha1path, 'w') as f: | 355 with open(sha1path, 'w') as f: |
356 f.write(_sha1OfFile()) | 356 f.write(_sha1OfFile()) |
357 | 357 |
358 def _sha1OfFile(): | 358 def _sha1OfFile(): |
359 with open(path, 'rb') as f: | 359 with open(path, 'rb') as f: |
360 return hashlib.sha1(f.read()).hexdigest() | 360 d = hashlib.sha1() |
361 | 361 while True: |
362 buf = f.read(4096) | |
363 if not buf: | |
364 break | |
365 d.update(buf) | |
366 return d.hexdigest() | |
362 | 367 |
363 if resolve and mustExist and not exists(path): | 368 if resolve and mustExist and not exists(path): |
364 assert not len(urls) == 0, 'cannot find required library ' + name + ' ' + path | 369 assert not len(urls) == 0, 'cannot find required library ' + name + ' ' + path |
365 _download_lib() | 370 _download_lib() |
366 | 371 |