1
0
Fork 1
mirror of https://github.com/coddingtonbear/django-mailbox.git synced 2026-07-09 22:38:19 +02:00

Modernize syntax, drop Python<3, drop Django<1.11

This commit is contained in:
Adam Dobrawy 2019-11-09 14:57:35 +01:00
parent d114008645
commit 84c99afa03
42 changed files with 176 additions and 330 deletions

View file

@ -3,8 +3,6 @@ import email.header
import logging
import os
import six
from django.conf import settings
@ -75,11 +73,8 @@ def get_settings():
def convert_header_to_unicode(header):
default_charset = get_settings()['default_charset']
if six.PY2 and isinstance(header, six.text_type):
return header
def _decode(value, encoding):
if isinstance(value, six.text_type):
if isinstance(value, str):
return value
if not encoding or encoding == 'unknown-8bit':
encoding = default_charset
@ -106,7 +101,7 @@ def get_body_from_message(message, maintype, subtype):
"""
Fetchs the body message matching main/sub content type.
"""
body = six.text_type('')
body = ''
for part in message.walk():
if part.get('content-disposition', '').startswith('attachment;'):
continue