ยปCore Development>Code coverage>Tools/msi/generate_md5.py

Python code coverage for Tools/msi/generate_md5.py

#countcontent
1n/aimport hashlib
2n/aimport os
3n/aimport sys
4n/a
5n/adef main():
6n/a filenames, hashes, sizes = [], [], []
7n/a
8n/a for file in sys.argv[1:]:
9n/a if not os.path.isfile(file):
10n/a continue
11n/a
12n/a with open(file, 'rb') as f:
13n/a data = f.read()
14n/a md5 = hashlib.md5()
15n/a md5.update(data)
16n/a filenames.append(os.path.split(file)[1])
17n/a hashes.append(md5.hexdigest())
18n/a sizes.append(str(len(data)))
19n/a
20n/a print('{:40s} {:<32s} {:<9s}'.format('File', 'MD5', 'Size'))
21n/a for f, h, s in zip(filenames, hashes, sizes):
22n/a print('{:40s} {:>32s} {:>9s}'.format(f, h, s))
23n/a
24n/a
25n/a
26n/aif __name__ == "__main__":
27n/a sys.exit(int(main() or 0))