Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions docs/conf_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
master_doc = 'index'

# General information about the project.
project = u'python-emails'
copyright = u'2015-2026, Sergey Lavrinenko'
project = 'python-emails'
copyright = '2015-2026, Sergey Lavrinenko'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down Expand Up @@ -216,8 +216,8 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
('index', 'python-emails.tex', u'python-emails Documentation',
u'Sergey Lavrinenko', 'manual'),
('index', 'python-emails.tex', 'python-emails Documentation',
'Sergey Lavrinenko', 'manual'),
]

# The name of an image file (relative to this directory) to place at the top of
Expand Down Expand Up @@ -246,8 +246,8 @@
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'python-emails', u'python-emails Documentation',
[u'Sergey Lavrinenko'], 1)
('index', 'python-emails', 'python-emails Documentation',
['Sergey Lavrinenko'], 1)
]

# If true, show URL addresses after external links.
Expand All @@ -260,8 +260,8 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', 'python-emails', u'python-emails Documentation',
u'Sergey Lavrinenko', 'python-emails', 'One line description of project.',
('index', 'python-emails', 'python-emails Documentation',
'Sergey Lavrinenko', 'python-emails', 'One line description of project.',
'Miscellaneous'),
]

Expand Down
1 change: 0 additions & 1 deletion emails/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# coding: utf-8
"""
python-emails
~~~~~~~~~~~~~
Expand Down
1 change: 0 additions & 1 deletion emails/backend/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
# encoding: utf-8
from .factory import ObjectFactory
from .smtp import SMTPBackend
1 change: 0 additions & 1 deletion emails/backend/factory.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# encoding: utf-8

def simple_dict2str(d):
# Simple dict serializer
Expand Down
1 change: 0 additions & 1 deletion emails/backend/inmemory/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# encoding: utf-8

__all__ = ['InMemoryBackend', ]

Expand Down
1 change: 0 additions & 1 deletion emails/backend/response.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# encoding: utf-8
from __future__ import annotations

from typing import Any
Expand Down
1 change: 0 additions & 1 deletion emails/backend/smtp/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
# encoding: utf-8

from .backend import SMTPBackend
1 change: 0 additions & 1 deletion emails/backend/smtp/backend.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# encoding: utf-8
from __future__ import annotations

import logging
Expand Down
1 change: 0 additions & 1 deletion emails/backend/smtp/client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# encoding: utf-8
from __future__ import annotations

__all__ = ['SMTPClientWithResponse', 'SMTPClientWithResponse_SSL']
Expand Down
1 change: 0 additions & 1 deletion emails/backend/smtp/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# encoding: utf-8
import socket


Expand Down
1 change: 0 additions & 1 deletion emails/django/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# encoding: utf-8
from django.core.mail import get_connection
from .. message import MessageTransformerMixin, MessageSignMixin, MessageBuildMixin, BaseMessage
from .. utils import sanitize_email
Expand Down
1 change: 0 additions & 1 deletion emails/django_.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# encoding: utf-8
import warnings
warnings.warn("emails.django_ module moved to emails.django", DeprecationWarning)

Expand Down
1 change: 0 additions & 1 deletion emails/exc.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# encoding: utf-8
from __future__ import annotations

from .packages.dkim import DKIMException
Expand Down
1 change: 0 additions & 1 deletion emails/loader/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# encoding: utf-8
import os.path
from email.utils import formataddr

Expand Down
1 change: 0 additions & 1 deletion emails/loader/helpers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# encoding: utf-8
__all__ = ['guess_charset', 'fix_content_type']
from email.message import Message

Expand Down
1 change: 0 additions & 1 deletion emails/loader/local_store.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# encoding: utf-8
from email.utils import parseaddr
import logging
import mimetypes
Expand Down
1 change: 0 additions & 1 deletion emails/message.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# coding: utf-8
from __future__ import annotations

from collections.abc import Callable
Expand Down
1 change: 0 additions & 1 deletion emails/signers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# encoding: utf-8
# This module use pydkim for DKIM signature
from __future__ import annotations

Expand Down
1 change: 0 additions & 1 deletion emails/store/file.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# encoding: utf-8
from __future__ import annotations

import uuid
Expand Down
1 change: 0 additions & 1 deletion emails/store/store.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# encoding: utf-8
from __future__ import annotations

from collections import OrderedDict
Expand Down
1 change: 0 additions & 1 deletion emails/template/base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# encoding: utf-8
import string


Expand Down
1 change: 0 additions & 1 deletion emails/template/jinja_template.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# encoding: utf-8
from .base import BaseTemplate


Expand Down
1 change: 0 additions & 1 deletion emails/template/mako_template.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# encoding: utf-8
from .base import BaseTemplate


Expand Down
1 change: 0 additions & 1 deletion emails/testsuite/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# encoding: utf-8
import logging
import datetime
import pytest
Expand Down
1 change: 0 additions & 1 deletion emails/testsuite/django_/test_django_integrations.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# encoding: utf-8
import warnings
import emails
import emails.message
Expand Down
9 changes: 4 additions & 5 deletions emails/testsuite/loader/test_helpers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# encoding: utf-8

import logging; import cssutils; cssutils.log.setLevel(logging.FATAL)

Expand Down Expand Up @@ -33,16 +32,16 @@ def norma_enc(enc):
assert enc_
return enc_

assert decode_text(u'A')[0] == u'A'
assert decode_text(b'A') == (u'A', 'ascii')
assert decode_text('A')[0] == 'A'
assert decode_text(b'A') == ('A', 'ascii')

for enc in ['utf-8', 'windows-1251', 'cp866']:
t = u'Шла Саша по шоссе и сосала сушку. В огороде бузина, в Киеве дядька.'
t = 'Шла Саша по шоссе и сосала сушку. В огороде бузина, в Киеве дядька.'
text, guessed_encoding = decode_text(t.encode(enc))
print(text, norma_enc(guessed_encoding))
assert (text, norma_enc(guessed_encoding)) == (t, norma_enc(enc))

html = u"""<html><meta http-equiv="Content-Type" content="text/html; charset=%s" />""" % enc
html = """<html><meta http-equiv="Content-Type" content="text/html; charset=%s" />""" % enc
text, guessed_encoding = decode_text(html.encode('utf-8'), is_html=True)
print(text, norma_enc(guessed_encoding))
assert (text, norma_enc(guessed_encoding)) == (html, norma_enc(enc))
1 change: 0 additions & 1 deletion emails/testsuite/loader/test_loaders.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# encoding: utf-8
import os
from lxml.etree import XMLSyntaxError
import pytest
Expand Down
5 changes: 2 additions & 3 deletions emails/testsuite/loader/test_rfc822_loader.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# encoding: utf-8
import glob
import email
import datetime
Expand Down Expand Up @@ -41,8 +40,8 @@ def test_msgloader():

data = {'charset': 'utf-8',
'subject': 'Что-то по-русски',
'mail_from': ('Максим Иванов', 'ivanov@ya.ru'),
'mail_to': [('Полина Сергеева', 'polina@mail.ru'), ('test', 'test@example.com')],
'mail_from': ('Максим Иванов', 'ivanov@ya.r'),
'mail_to': [('Полина Сергеева', 'polina@mail.r'), ('test', 'test@example.com')],
'cc': [('CC User', 'cc@example.com'), ('cc', 'cc.1@example.com')],
'html': '<h1>Привет!</h1><p>В первых строках...',
'text': 'Привет!\nВ первых строках...',
Expand Down
1 change: 0 additions & 1 deletion emails/testsuite/message/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
# encoding: utf-8
3 changes: 1 addition & 2 deletions emails/testsuite/message/helpers.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# coding: utf-8
import os

import emails
from emails.template import JinjaTemplate

TO_EMAIL = os.environ.get('SMTP_TEST_MAIL_TO') or 'python.emails.test.2@yandex.ru'
TO_EMAIL = os.environ.get('SMTP_TEST_MAIL_TO') or 'python.emails.test.2@yandex.r'
FROM_EMAIL = os.environ.get('SMTP_TEST_MAIL_FROM') or 'python-emails@lavr.me'
ROOT = os.path.dirname(__file__)

Expand Down
1 change: 0 additions & 1 deletion emails/testsuite/message/test_dkim.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# coding: utf-8
import os
import email
import pytest
Expand Down
1 change: 0 additions & 1 deletion emails/testsuite/message/test_lazy_gettext.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# encoding: utf-8
import gettext
from emails import Message
from emails.utils import decode_header
Expand Down
1 change: 0 additions & 1 deletion emails/testsuite/message/test_message.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# coding: utf-8
import datetime
from email.utils import parseaddr
from dateutil.parser import parse as dateutil_parse
Expand Down
3 changes: 1 addition & 2 deletions emails/testsuite/message/test_send.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# coding: utf-8
import time
import random
import pytest
Expand All @@ -18,7 +17,7 @@ def get_letters():
yield emails.html(**data), None

# Email with render
yield emails.html(**common_email_data(subject='Render with name=John')), {'name': u'John'}
yield emails.html(**common_email_data(subject='Render with name=John')), {'name': 'John'}

# Email with several inline images
url = 'http://lavr.github.io/python-emails/tests/campaignmonitor-samples/sample-template/template-widgets.html'
Expand Down
29 changes: 0 additions & 29 deletions emails/testsuite/other/test_requests_encoding_detection.py

This file was deleted.

1 change: 0 additions & 1 deletion emails/testsuite/smtp/test_factory.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# encoding: utf-8
import pytest
from emails.backend.factory import ObjectFactory

Expand Down
3 changes: 1 addition & 2 deletions emails/testsuite/smtp/test_smtp_backend.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# encoding: utf-8

import socket

Expand All @@ -11,7 +10,7 @@
SAMPLE_MESSAGE = {'html': '<p>Test from python-emails',
'text': 'Test from python-emails',
'mail_from': 's@lavr.me',
'mail_to': 'sergei-nko@yandex.ru'}
'mail_to': 'sergei-nko@yandex.r'}


def test_send_to_unknown_host():
Expand Down
1 change: 0 additions & 1 deletion emails/testsuite/smtp/test_smtp_response.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# encoding: utf-8
from emails.backend.response import SMTPResponse


Expand Down
3 changes: 1 addition & 2 deletions emails/testsuite/smtp_servers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# encoding: utf-8
import os
import platform
import datetime
Expand Down Expand Up @@ -100,7 +99,7 @@ def patch_message(self, message):
return message

def __str__(self):
return u'SMTPTestParams({user}@{host}:{port})'.format(host=self.params.get('host'),
return 'SMTPTestParams({user}@{host}:{port})'.format(host=self.params.get('host'),
port=self.params.get('port'),
user=self.params.get('user', ''))

Expand Down
1 change: 0 additions & 1 deletion emails/testsuite/store/test_store.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# encoding: utf-8
from io import BytesIO

import pytest
Expand Down
1 change: 0 additions & 1 deletion emails/testsuite/test_templates.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# encoding: utf-8
import pytest
from emails.template import MakoTemplate, StringTemplate, JinjaTemplate
from emails.template.base import BaseTemplate
Expand Down
1 change: 0 additions & 1 deletion emails/testsuite/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# encoding: utf-8
import pytest
import datetime
import time
Expand Down
1 change: 0 additions & 1 deletion emails/testsuite/transformer/test_parser.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# encoding: utf-8
from emails.transformer import HTMLParser


Expand Down
1 change: 0 additions & 1 deletion emails/testsuite/transformer/test_transformer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# encoding: utf-8
import os.path
import emails.loader
from emails.loader.local_store import FileSystemLoader, BaseLoader
Expand Down
1 change: 0 additions & 1 deletion emails/transformer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# encoding: utf-8

import functools
import logging
Expand Down
3 changes: 1 addition & 2 deletions emails/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# encoding: utf-8
from __future__ import annotations

import sys
Expand Down Expand Up @@ -207,7 +206,7 @@ def parse_name_and_email_list(elements: str | tuple[str | None, str] | list[Any]
def parse_name_and_email(obj: str | tuple[str | None, str] | list[str],
encoding: str = 'utf-8') -> AddressPair:
# In: 'john@smith.me' or '"John Smith" <john@smith.me>' or ('John Smith', 'john@smith.me')
# Out: (u'John Smith', u'john@smith.me')
# Out: ('John Smith', 'john@smith.me')

if isinstance(obj, (list, tuple)):
if len(obj) == 2:
Expand Down
1 change: 0 additions & 1 deletion requirements/tests-base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ speaklater
pytest
pytest-cov
html5lib
six
6 changes: 2 additions & 4 deletions scripts/make_rfc822.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/usr/bin/env python
# coding: utf-8

#!/usr/bin/env python3
"""

Simple utility that imports html from url ang print generated rfc822 message to console.
Expand Down Expand Up @@ -65,7 +63,7 @@ def _get_message(self):
args = dict(images_inline=options.inline_images,
message_params=dict(headers=self._headers_from_command_line(),
mail_from=(options.from_name, options.from_email),
subject=T(unicode(options.subject, 'utf-8')),
subject=T(options.subject),
message_id=message_id),
template_cls=T)
if options.url:
Expand Down
2 changes: 0 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""

python-emails
Expand Down
Loading