Staging
v0.8.1
https://github.com/python/cpython
Revision 3398dcb14f6d43bf1619f7c32fe8d888c354e6b2 authored by Ned Deily on 05 December 2017, 08:26:08 UTC, committed by Ned Deily on 05 December 2017, 08:26:08 UTC
1 parent de4c3f3
Raw File
Tip revision: 3398dcb14f6d43bf1619f7c32fe8d888c354e6b2 authored by Ned Deily on 05 December 2017, 08:26:08 UTC
Bump to 3.6.4rc1
Tip revision: 3398dcb
generate_md5.py
import hashlib
import os
import sys

def main():
    filenames, hashes, sizes = [], [], []

    for file in sys.argv[1:]:
        if not os.path.isfile(file):
            continue

        with open(file, 'rb') as f:
            data = f.read()
            md5 = hashlib.md5()
            md5.update(data)
            filenames.append(os.path.split(file)[1])
            hashes.append(md5.hexdigest())
            sizes.append(str(len(data)))

    print('{:40s}  {:<32s}  {:<9s}'.format('File', 'MD5', 'Size'))
    for f, h, s in zip(filenames, hashes, sizes):
        print('{:40s}  {:>32s}  {:>9s}'.format(f, h, s))



if __name__ == "__main__":
    sys.exit(int(main() or 0))
back to top