diff options
author | Kali Kaneko <kali@leap.se> | 2015-01-04 03:37:18 -0400 |
---|---|---|
committer | Kali Kaneko <kali@leap.se> | 2015-02-11 14:05:43 -0400 |
commit | 84888155b09b3af6a755262b28728de2f851c8cb (patch) | |
tree | c45a09f7fee1ce1e83d3c36839993f0f1653d9dd /src/leap/mail/walk.py | |
parent | fa60b76ce9cdf6684945c6bc724f10818104166b (diff) |
tests for mail.mail module: Message
Diffstat (limited to 'src/leap/mail/walk.py')
-rw-r--r-- | src/leap/mail/walk.py | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/leap/mail/walk.py b/src/leap/mail/walk.py index 5172837..8653a5f 100644 --- a/src/leap/mail/walk.py +++ b/src/leap/mail/walk.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # walk.py -# Copyright (C) 2013 LEAP +# Copyright (C) 2013-2015 LEAP # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -56,15 +56,15 @@ get_payloads = lambda msg: ((x.get_payload(), dict(((str.lower(k), v) for k, v in (x.items())))) for x in msg.walk()) -get_body_phash_simple = lambda payloads: first( - [get_hash(payload) for payload, headers in payloads - if payloads]) -get_body_phash_multi = lambda payloads: (first( - [get_hash(payload) for payload, headers in payloads - if payloads - and "text/plain" in headers.get('content-type', '')]) - or get_body_phash_simple(payloads)) +def get_body_phash(msg): + """ + Find the body payload-hash for this message. + """ + for part in msg.walk(): + if part.get_content_type() == "text/plain": + # XXX avoid hashing again + return get_hash(part.get_payload()) """ On getting the raw docs, we get also some of the headers to be able to |