From ea33df3f89fc41f216ba2d593f4276c614e325fe Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Sun, 27 May 2012 06:46:08 +0200 Subject: [PATCH] Parse email files and generate hash --- parse | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/parse b/parse index 6e5fc10..2138c02 100755 --- a/parse +++ b/parse @@ -13,5 +13,18 @@ parser.add_argument('-r', '--render', dest='render', action='store_true', args = parser.parse_args() options = vars(args) -filelist = glob.glob(options['pattern']) -print filelist +file_list = glob.glob(options['pattern']) + +for email_file in file_list: + message = email.message_from_file(open(email_file)) + + if message['message-id'] is None: + print "%s is not a valid e-mail file." % email_file + else: + if 'subject' not in message or message['subject'] is None: + subject = "" + else: + subject = message['subject'] + + sha1_hash = hashlib.sha1("%s/%s/%s/%s" % (message['from'], message['to'], message['message-id'], subject)).hexdigest() +