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
commitc5e467a35cac1f1a359f6ac8e14fae3bb90bfd34 (patch)
treedc32f205249b6ae4d05ee35bb3f6e72d2bbfef15
parent6b7924ada499521bd7536ef325a1543cbb0966bc (diff)
add check for none in part_map special case
-rw-r--r--mail/src/leap/mail/walk.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/mail/src/leap/mail/walk.py b/mail/src/leap/mail/walk.py
index 856daa3a..30cb70af 100644
--- a/mail/src/leap/mail/walk.py
+++ b/mail/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)