diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 849c31e..4944c77 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -6,8 +6,6 @@ updates: interval: "weekly" target-branch: "master" - package-ecosystem: "github-actions" - # Workflow files stored in the - # default location of `.github/workflows` directory: "/" schedule: interval: "weekly" diff --git a/tracking/email_utils.py b/tracking/email_utils.py index 19cc2c4..4585db0 100644 --- a/tracking/email_utils.py +++ b/tracking/email_utils.py @@ -3,9 +3,8 @@ from imaplib import IMAP4_SSL -def get_imap(mailbox='INBOX'): - """Instantiate a new IMAP object, login, and connect to a mailbox. - """ +def get_imap(mailbox="INBOX"): + """Instantiate a new IMAP object, login, and connect to a mailbox.""" imap = IMAP4_SSL(settings.EMAIL_HOST) imap.login(settings.EMAIL_USER, settings.EMAIL_PASSWORD) imap.select(mailbox) @@ -13,11 +12,10 @@ def get_imap(mailbox='INBOX'): def email_get_unread(imap, from_email_address): - """Returns (status, list of UIDs) of unread emails from a sending email address. - """ + """Returns (status, list of UIDs) of unread emails from a sending email address.""" search = '(UNSEEN UNFLAGGED FROM "{}")'.format(from_email_address) status, response = imap.search(None, search) - if status != 'OK': + if status != "OK": return status, response # Return status and list of unread email UIDs. return status, response[0].split() @@ -28,44 +26,40 @@ def email_fetch(imap, uid): Email is returned as an email.Message class object. """ message = None - status, response = imap.fetch(str(uid), '(BODY.PEEK[])') + status, response = imap.fetch(str(uid), "(BODY.PEEK[])") - if status != 'OK': + if status != "OK": return status, response for i in response: if isinstance(i, tuple): s = i[1] if isinstance(s, bytes): - s = s.decode('utf-8') + s = s.decode("utf-8") message = email.message_from_string(s) return status, message def email_mark_read(imap, uid): - """Flag an email as 'Seen' based on passed-in UID. - """ - status, response = imap.store(str(uid), '+FLAGS', '\Seen') + """Flag an email as 'Seen' based on passed-in UID.""" + status, response = imap.store(str(uid), "+FLAGS", r"\Seen") return status, response def email_mark_unread(imap, uid): - """Remove the 'Seen' flag from an email based on passed-in UID. - """ - status, response = imap.store(str(uid), '-FLAGS', '\Seen') + """Remove the 'Seen' flag from an email based on passed-in UID.""" + status, response = imap.store(str(uid), "-FLAGS", r"\Seen") return status, response def email_delete(imap, uid): - """Flag an email for deletion. - """ - status, response = imap.store(str(uid), '+FLAGS', '\Deleted') + """Flag an email for deletion.""" + status, response = imap.store(str(uid), "+FLAGS", r"\Deleted") return status, response def email_flag(imap, uid): - """Flag an email as unprocessable. - """ - status, response = imap.store(str(uid), '+FLAGS', '\Flagged') + """Flag an email as unprocessable.""" + status, response = imap.store(str(uid), "+FLAGS", r"\Flagged") return status, response