Created
April 7, 2012 00:03
-
-
Save muelli/2324157 to your computer and use it in GitHub Desktop.
This file contains 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 | |
import argparse | |
import sys | |
from pgpdump import BinaryData | |
def main(args): | |
parser = argparse.ArgumentParser(description='Process OpenPGP files') | |
#parser.add_argument('integers', metavar='N', type=int, nargs='+', | |
# help='an integer for the accumulator') | |
parser.add_argument('files', nargs='+', | |
help='filenames to be processed') | |
args = parser.parse_args() | |
for filename in args.files: | |
with open(filename, 'rb') as infile: | |
data = BinaryData(infile.read()) | |
counter = 0 | |
length = 0 | |
for packet in data.packets(): | |
counter += 1 | |
print("Reading from byte %d" % length) | |
length += packet.length | |
try: | |
print(packet) | |
except: | |
print("Error after reading %d packets, totalling %d bytes" % (counter, length)) | |
raise | |
print(length) | |
print(counter) | |
if __name__ == '__main__': | |
sys.exit(main(sys.argv)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment