diff options
author | Konstantin Ryabitsev <konstantin@linuxfoundation.org> | 2020-02-24 12:45:37 -0500 |
---|---|---|
committer | Konstantin Ryabitsev <konstantin@linuxfoundation.org> | 2020-02-24 12:45:37 -0500 |
commit | 61aa41d5c8e9220422c09ba16605507dde9a964a (patch) | |
tree | 82a7031d95f4997517d281d9d5522ba6dcd513b1 | |
parent | e88369f0b62def16752491cc62bc57c4a345afd9 (diff) | |
download | korg-helpers-61aa41d5c8e9220422c09ba16605507dde9a964a.tar.gz |
Don't BT when the cover letter is missing
Properly handle cases when the cover letter is missing from the thread.
Reported-by: Rob Herring <robh@kernel.org>
Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
-rwxr-xr-x | get-lore-mbox.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/get-lore-mbox.py b/get-lore-mbox.py index 851248c..a06941c 100755 --- a/get-lore-mbox.py +++ b/get-lore-mbox.py @@ -30,7 +30,7 @@ charset.add_charset('utf-8', None) emlpolicy = email.policy.EmailPolicy(utf8=True, cte_type='8bit', max_line_length=None) logger = logging.getLogger('get-lore-mbox') -VERSION = '0.2.7' +VERSION = '0.2.8' # You can use bash-style globbing here WANTHDRS = [ @@ -119,7 +119,7 @@ class LoreMailbox: for member in lser.patches: if member is not None and member.in_reply_to is not None: potential = self.get_by_msgid(member.in_reply_to) - if potential.has_diffstat and not potential.has_diff: + if potential is not None and potential.has_diffstat and not potential.has_diff: # This is *probably* the cover letter lser.patches[0] = potential lser.has_cover = True @@ -230,7 +230,8 @@ class LoreSeries: self.expected = lmsg.expected if self.patches[lmsg.counter] is not None: # Okay, weird, is the one in there a reply? - if self.patches[lmsg.counter].reply: + omsg = self.patches[lmsg.counter] + if omsg.reply: # Replace that one with this one self.patches[lmsg.counter] = lmsg else: @@ -251,8 +252,7 @@ class LoreSeries: if lmsg is None: return 'undefined' - msgdate = email.utils.parsedate_tz(str(lmsg.msg['Date'])) - prefix = time.strftime('%Y%m%d', msgdate[:9]) + prefix = time.strftime('%Y%m%d', lmsg.date[:9]) authorline = email.utils.getaddresses(lmsg.msg.get_all('from', []))[0] author = re.sub(r'\W+', '_', authorline[1]).strip('_').lower() slug = '%s_%s' % (prefix, author) @@ -319,6 +319,7 @@ class LoreMessage: self.in_reply_to = None self.fromname = None self.fromemail = None + self.date = None # Body and body-based info self.body = None @@ -352,6 +353,8 @@ class LoreMessage: except IndexError: pass + self.date = email.utils.parsedate_tz(str(self.msg['Date'])) + diffre = re.compile(r'^(---.*\n\+\+\+|GIT binary patch)', re.M | re.I) diffstatre = re.compile(r'^\s*\d+ file.*\d+ insertion.*\d+ deletion', re.M | re.I) @@ -402,6 +405,7 @@ class LoreMessage: out.append(' fromname: %s' % self.fromname) out.append(' fromemail: %s' % self.fromemail) + out.append(' date: %s' % self.date) out.append(' in_reply_to: %s' % self.in_reply_to) # Header-based info |