From 807f3da880820f87b8db06e8756deda737ea5347 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Tue, 24 Jun 2014 18:07:17 +0100 Subject: [PATCH] addmessageheader(): add debug for header insertion Signed-off-by: Eygene Ryabinkin --- offlineimap/folder/Base.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/offlineimap/folder/Base.py b/offlineimap/folder/Base.py index ff36d5a..e6c21bd 100644 --- a/offlineimap/folder/Base.py +++ b/offlineimap/folder/Base.py @@ -441,10 +441,22 @@ class BaseFolder(object): self.ui.debug('', 'addmessageheader: called to add %s: %s' % (headername, headervalue)) + + insertionpoint = content.find(linebreak * 2) + if insertionpoint == -1: + self.ui.debug('', 'addmessageheader: headers were missing') + else: + self.ui.debug('', 'addmessageheader: headers end at position %d' % insertionpoint) + mark = '==>EOH<==' + contextstart = max(0, insertionpoint - 100) + contextend = min(len(content), insertionpoint + 100) + self.ui.debug('', 'addmessageheader: header/body transition context (marked by %s): %s' % + (mark, repr(content[contextstart:insertionpoint]) + \ + mark + repr(content[insertionpoint:contextend]))) + # Hoping for case #4 prefix = linebreak suffix = '' - insertionpoint = content.find(linebreak * 2) # Case #2 if insertionpoint == 0: prefix = ''