summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKali Kaneko <kali@leap.se>2014-01-23 10:49:52 -0400
committerKali Kaneko <kali@leap.se>2014-01-23 10:49:52 -0400
commit90b870c48c0c27e3a366902c5b76986a5140258c (patch)
treea8075fefec62a819632f0c012fe3fb34f26ae0f7
parentbded9833da985034a11c30b342388c397798a585 (diff)
add check for none in part_map special case
-rw-r--r--src/leap/mail/walk.py13
1 files changed, 7 insertions, 6 deletions
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)