From 2ead849e07f97a0ae95ec301cfe319b48a49df0b Mon Sep 17 00:00:00 2001 From: Magnus Hagander Date: Thu, 3 Jan 2019 21:56:09 +0100 Subject: [PATCH] Fix bad multi-command lines --- django/archives/mailarchives/models.py | 3 ++- loader/clean_date.py | 3 ++- loader/lib/parser.py | 15 ++++++++++----- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/django/archives/mailarchives/models.py b/django/archives/mailarchives/models.py index 6bd047d..88137f8 100644 --- a/django/archives/mailarchives/models.py +++ b/django/archives/mailarchives/models.py @@ -51,7 +51,8 @@ class Message(models.Model): @property def hiddenreason(self): - if not self.hiddenstatus: return None + if not self.hiddenstatus: + return None try: return hide_reasons[self.hiddenstatus] except: diff --git a/loader/clean_date.py b/loader/clean_date.py index 19143cb..2297be6 100755 --- a/loader/clean_date.py +++ b/loader/clean_date.py @@ -28,7 +28,8 @@ def scan_message(messageid, olddate, curs): # Can be either one of them, but we really don't care... ds = None for k, r in list(msg.items()): - if k != 'Received': continue + if k != 'Received': + continue print("Trying on %s" % r) m = re.search(';\s*(.*)$', r) diff --git a/loader/lib/parser.py b/loader/lib/parser.py index cef9468..334fc34 100644 --- a/loader/lib/parser.py +++ b/loader/lib/parser.py @@ -187,7 +187,8 @@ class ArchivesParser(object): # First see if this is a single-part message that we can just # decode and go. b = self.get_payload_as_unicode(self.msg) - if b: return b + if b: + return b if b == '': # We found something, but it was empty. We'll keep looking as # there might be something better available, but make a note @@ -203,7 +204,8 @@ class ArchivesParser(object): # text/html # application/octet-stream (attachment) b = self.recursive_first_plaintext(self.msg) - if b: return b + if b: + return b if b == '': hasempty = True @@ -212,7 +214,8 @@ class ArchivesParser(object): b = self.recursive_first_plaintext(self.msg, True) if b: b = self.html_clean(b) - if b: return b + if b: + return b if b == '' or b is None: hasempty = True @@ -243,7 +246,8 @@ class ArchivesParser(object): return self.get_payload_as_unicode(p) if p.is_multipart(): b = self.recursive_first_plaintext(p, html_instead) - if b or b == '': return b + if b or b == '': + return b # Yikes, nothing here! Hopefully we'll find something when # we continue looping at a higher level. @@ -272,7 +276,8 @@ class ArchivesParser(object): # Try to get the filename for an attachment in the container. # If the standard library can figure one out, use that one. f = container.get_filename() - if f: return self._clean_filename_encoding(f) + if f: + return self._clean_filename_encoding(f) # Failing that, some mailers set Content-Description to the # filename -- 2.39.5