From 90b870c48c0c27e3a366902c5b76986a5140258c Mon Sep 17 00:00:00 2001 From: Kali Kaneko Date: Thu, 23 Jan 2014 10:49:52 -0400 Subject: add check for none in part_map special case --- src/leap/mail/walk.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/leap/mail/walk.py') diff --git a/src/leap/mail/walk.py b/src/leap/mail/walk.py index 856daa3..30cb70a 100644 --- a/src/leap/mail/walk.py +++ b/src/leap/mail/walk.py @@ -151,12 +151,13 @@ def walk_msg_tree(parts, body_phash=None): if all(x == 1 for x in pv): # special case in the rightmost element - main_pmap = parts[0]['part_map'] - last_part = max(main_pmap.keys()) - main_pmap[last_part]['part_map'] = {} - for partind in range(len(pv) - 1): - print partind+1, len(parts) - main_pmap[last_part]['part_map'][partind] = parts[partind+1] + main_pmap = parts[0].get(PART_MAP, None) + if main_pmap is not None: + last_part = max(main_pmap.keys()) + main_pmap[last_part][PART_MAP] = {} + for partind in range(len(pv) - 1): + print partind+1, len(parts) + main_pmap[last_part][PART_MAP][partind] = parts[partind + 1] outer = parts[0] outer.pop(HEADERS) -- cgit v1.2.3