diff options
author | bnewbold <bnewbold@robocracy.org> | 2017-05-26 00:13:59 -0700 |
---|---|---|
committer | bnewbold <bnewbold@robocracy.org> | 2017-05-26 00:19:40 -0700 |
commit | e41e8ab92d038a99c97439e489071211da3329cb (patch) | |
tree | 543809ef23d75ffc4062c63230cebbe39a13bb23 /tests/tarsum.py | |
parent | 4b0a50b25f72a5b2d693379f9693b37131c12371 (diff) | |
download | bad-hashish-e41e8ab92d038a99c97439e489071211da3329cb.tar.gz bad-hashish-e41e8ab92d038a99c97439e489071211da3329cb.zip |
add some very basic test files
Diffstat (limited to 'tests/tarsum.py')
-rwxr-xr-x | tests/tarsum.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/tarsum.py b/tests/tarsum.py new file mode 100755 index 0000000..23d397d --- /dev/null +++ b/tests/tarsum.py @@ -0,0 +1,25 @@ +#!/usr/bin/python +""" +From: https://gist.github.com/DaveCTurner/8765561 + +Modified to print with an extra space between fields +""" + +import sys +import tarfile +import hashlib + +for filename in sys.argv[1:]: + print filename + with tarfile.open(filename, 'r') as tar: + for tarinfo in tar: + if tarinfo.isreg(): + flo = tar.extractfile(tarinfo) # NB doesn't really extract the file, just gives you a stream (file-like-object) for reading it + hash = hashlib.sha1() + while True: + data = flo.read(2**20) + if not data: + break + hash.update(data) + flo.close() + print hash.hexdigest(), '', tarinfo.name |