From 8d7ba415fa234e32d422b54e175797ace2b78ac5 Mon Sep 17 00:00:00 2001 From: chrisbroderick Date: Thu, 8 Sep 2022 22:11:24 +0100 Subject: [PATCH] Fix formatting per flake8 --- helpdesk/email.py | 33 ++++++++++++++++++--------------- helpdesk/exceptions.py | 2 +- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/helpdesk/email.py b/helpdesk/email.py index 7e0de522..c753aea5 100644 --- a/helpdesk/email.py +++ b/helpdesk/email.py @@ -212,7 +212,7 @@ def imap_sync(q, logger, server): "Successfully processed message %s, deleted from IMAP server" % num) else: logger.warn( - "Message %s was not successfully processed, and will be left on IMAP server" % num) + "Message %s was not successfully processed, and will be left on IMAP server" % num) except imaplib.IMAP4.error: logger.error( "IMAP retrieve failed. Is the folder '%s' spelled correctly, and does it exist on the server?", @@ -595,20 +595,22 @@ def get_email_body_from_part_payload(part) -> str: part.get_payload(decode=False) ) + def attempt_body_extract_from_html(message: str) -> str: - mail = BeautifulSoup(str(message), "html.parser") - beautiful_body = mail.find('body') - body = None - full_body = None - if beautiful_body: - try: - body = beautiful_body.text - full_body = body - except AttributeError: - pass - if not body: - body = "" - return body, full_body + mail = BeautifulSoup(str(message), "html.parser") + beautiful_body = mail.find('body') + body = None + full_body = None + if beautiful_body: + try: + body = beautiful_body.text + full_body = body + except AttributeError: + pass + if not body: + body = "" + return body, full_body + def extract_part_data( part: Message, @@ -616,7 +618,7 @@ def extract_part_data( ticket_id: int, files: List, logger: logging.Logger - ) -> Tuple[str, str]: +) -> Tuple[str, str]: name = part.get_filename() if name: name = email.utils.collapse_rfc2231_value(name) @@ -682,6 +684,7 @@ def extract_part_data( logger.debug("Found MIME attachment %s", name) return part_body, part_full_body + def object_from_message(message: str, queue: Queue, logger: logging.Logger diff --git a/helpdesk/exceptions.py b/helpdesk/exceptions.py index d87f74fd..4dbf59a5 100644 --- a/helpdesk/exceptions.py +++ b/helpdesk/exceptions.py @@ -10,4 +10,4 @@ class DeleteIgnoredTicketException(Exception): Raised when an email message is received from a sender who is marked to be ignored and the record is tagged to delete the email from the inbox """ - pass \ No newline at end of file + pass