Created
April 24, 2015 22:39
-
-
Save m87h/21e71c66dd755c4cd787 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from __future__ import print_function | |
import sys | |
from string import zfill | |
from zipfile import ZipFile | |
def main(path, crc, *args): | |
with ZipFile(path, 'r') as zip: | |
for info in zip.infolist(): | |
if zfill(format(info.CRC, 'x'), 8) == crc.lower(): | |
sys.exit(0) | |
sys.exit(1) | |
if __name__ == '__main__': | |
if len(sys.argv) != 3: | |
print('usage: zip-contains-crc <zipfile> <crc>', file=sys.stderr) | |
sys.exit(2) | |
main(*sys.argv[1:]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment