Mercurial > cpython-lru_cache-weakref
view Tools/scripts/md5sum.py @ 22360:c8a6ea00a9e1 legacy-trunk
restructure a bit to not rely on test case execution ordering
add test case for bug #482460
| author | Skip Montanaro <skip@pobox.com> |
|---|---|
| date | Sun, 17 Mar 2002 23:03:42 +0000 |
| parents | 6991ddafe382 |
| children | fde878bc0e3b |
line wrap: on
line source
#! /usr/bin/env python """Python utility to print MD5 checksums of argument files. Works with Python 1.5.2 and later. """ import sys, md5 BLOCKSIZE = 1024*1024 def hexify(s): return ("%02x"*len(s)) % tuple(map(ord, s)) def main(): args = sys.argv[1:] if not args: sys.stderr.write("usage: %s file ...\n" % sys.argv[0]) sys.exit(2) for file in sys.argv[1:]: f = open(file, "rb") sum = md5.new() while 1: block = f.read(BLOCKSIZE) if not block: break sum.update(block) f.close() print hexify(sum.digest()), file if __name__ == "__main__": main()
