mirror of
https://github.com/coddingtonbear/django-mailbox.git
synced 2026-07-09 22:38:19 +02:00
Modernize syntax, drop Python EOL, drop drop Django<1.11, upgrade TravisCI config to v1, add Python 3.8 & Django 3.x
This commit is contained in:
parent
f9b0a27e5f
commit
2b2b7d6392
43 changed files with 228 additions and 349 deletions
|
|
@ -1,19 +1,11 @@
|
|||
import email
|
||||
|
||||
import six
|
||||
|
||||
# Do *not* remove this, we need to use this in subclasses of EmailTransport
|
||||
if six.PY3:
|
||||
from email.errors import MessageParseError # noqa: F401
|
||||
else:
|
||||
from email.Errors import MessageParseError # noqa: F401
|
||||
from email.errors import MessageParseError # noqa: F401
|
||||
|
||||
|
||||
class EmailTransport(object):
|
||||
class EmailTransport:
|
||||
def get_email_from_bytes(self, contents):
|
||||
if six.PY3:
|
||||
message = email.message_from_bytes(contents)
|
||||
else:
|
||||
message = email.message_from_string(contents)
|
||||
message = email.message_from_bytes(contents)
|
||||
|
||||
return message
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import sys
|
||||
import six
|
||||
|
||||
from .base import EmailTransport
|
||||
|
||||
|
|
@ -9,13 +8,8 @@ class GenericFileMailbox(EmailTransport):
|
|||
_path = None
|
||||
|
||||
def __init__(self, path):
|
||||
super(GenericFileMailbox, self).__init__()
|
||||
if six.PY2:
|
||||
self._path = path.encode(
|
||||
sys.getfilesystemencoding()
|
||||
)
|
||||
else:
|
||||
self._path = path
|
||||
super().__init__()
|
||||
self._path = path
|
||||
|
||||
def get_instance(self):
|
||||
return self._variant(self._path)
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ class GmailImapTransport(ImapTransport):
|
|||
)
|
||||
)
|
||||
|
||||
auth_string = 'user=%s\1auth=Bearer %s\1\1' % (
|
||||
auth_string = 'user={}\1auth=Bearer {}\1\1'.format(
|
||||
google_email_address,
|
||||
access_token
|
||||
)
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ class ImapTransport(EmailTransport):
|
|||
safe_message_ids.append(uid)
|
||||
except ValueError as e:
|
||||
logger.warning(
|
||||
"ValueError: %s working on %s" % (e, each_msg[0])
|
||||
"ValueError: {} working on {}".format(e, each_msg[0])
|
||||
)
|
||||
pass
|
||||
return safe_message_ids
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
import six
|
||||
|
||||
from poplib import POP3, POP3_SSL
|
||||
|
||||
from .base import EmailTransport, MessageParseError
|
||||
|
|
@ -24,9 +22,7 @@ class Pop3Transport(EmailTransport):
|
|||
self.server.pass_(password)
|
||||
|
||||
def get_message_body(self, message_lines):
|
||||
if six.PY3:
|
||||
return six.binary_type('\r\n', 'ascii').join(message_lines)
|
||||
return '\r\n'.join(message_lines)
|
||||
return bytes('\r\n', 'ascii').join(message_lines)
|
||||
|
||||
def get_message(self, condition=None):
|
||||
message_count = len(self.server.list()[1])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue