Skip to content

Commit

Permalink
Merge pull request #21 from zopefoundation/flake8
Browse files Browse the repository at this point in the history
Fix flake8 errors, remove deprecation warnings about assertRaisesRegexp()
  • Loading branch information
mgedmin committed Feb 7, 2019
2 parents 3f64175 + b79b94b commit 2ee8b0a
Show file tree
Hide file tree
Showing 18 changed files with 275 additions and 214 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Expand Up @@ -12,6 +12,10 @@ matrix:
- python: "3.7"
dist: xenial
sudo: true
- name: "flake8"
install: pip install flake8
script: flake8 src setup.py
after_success:
install:
- pip install -U pip setuptools
- pip install -U coverage coveralls coverage-python-version
Expand Down
3 changes: 3 additions & 0 deletions setup.cfg
@@ -1,2 +1,5 @@
[bdist_wheel]
universal = 1

[flake8]
doctests = yes
101 changes: 51 additions & 50 deletions setup.py
Expand Up @@ -28,7 +28,7 @@

EXTRAS_REQUIRE = {
'test': TESTS_REQUIRE,
#':sys_platform == "win32"': ['pywin32'],
# ':sys_platform == "win32"': ['pywin32'],
# Because https://sourceforge.net/p/pywin32/bugs/680/
':sys_platform == "win32"': ['pypiwin32'],
'docs': [
Expand All @@ -50,55 +50,56 @@ def read(*rnames):
read('CHANGES.rst')
)

setup(name='zope.sendmail',
version='4.2.2.dev0',
url='https://github.com/zopefoundation/zope.sendmail',
license='ZPL 2.1',
description='Zope sendmail',
author='Zope Foundation and Contributors',
author_email='zope-dev@zope.org',
long_description=LONG_DESCRIPTION,
classifiers=[
'Development Status :: 5 - Production/Stable',
'Environment :: Web Environment',
'Intended Audience :: Developers',
'License :: OSI Approved :: Zope Public License',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
'Operating System :: OS Independent',
'Topic :: Internet :: WWW/HTTP',
'Topic :: Communications :: Email',
'Framework :: Zope :: 3',
],
packages=find_packages('src'),
package_dir={'': 'src'},
namespace_packages=['zope'],
extras_require=EXTRAS_REQUIRE,
install_requires=[
'setuptools',
'transaction',
'zope.i18nmessageid',
'zope.interface',
'zope.schema',
# it's only needed for vocabulary, zcml and tests
'zope.component>=3.8.0',
# these are only needed for zcml
'zope.configuration',
],
tests_require=TESTS_REQUIRE,
test_suite='zope.sendmail.tests',
include_package_data=True,
zip_safe=False,
entry_points="""
setup(
name='zope.sendmail',
version='4.2.2.dev0',
url='https://github.com/zopefoundation/zope.sendmail',
license='ZPL 2.1',
description='Zope sendmail',
author='Zope Foundation and Contributors',
author_email='zope-dev@zope.org',
long_description=LONG_DESCRIPTION,
classifiers=[
'Development Status :: 5 - Production/Stable',
'Environment :: Web Environment',
'Intended Audience :: Developers',
'License :: OSI Approved :: Zope Public License',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
'Operating System :: OS Independent',
'Topic :: Internet :: WWW/HTTP',
'Topic :: Communications :: Email',
'Framework :: Zope :: 3',
],
packages=find_packages('src'),
package_dir={'': 'src'},
namespace_packages=['zope'],
extras_require=EXTRAS_REQUIRE,
install_requires=[
'setuptools',
'transaction',
'zope.i18nmessageid',
'zope.interface',
'zope.schema',
# it's only needed for vocabulary, zcml and tests
'zope.component>=3.8.0',
# these are only needed for zcml
'zope.configuration',
],
tests_require=TESTS_REQUIRE,
test_suite='zope.sendmail.tests',
include_package_data=True,
zip_safe=False,
entry_points="""
[console_scripts]
zope-sendmail = zope.sendmail.queue:run
"""
"""
)
2 changes: 1 addition & 1 deletion src/zope/__init__.py
@@ -1 +1 @@
__import__('pkg_resources').declare_namespace(__name__) # pragma: no cover
__import__('pkg_resources').declare_namespace(__name__) # pragma: no cover
6 changes: 4 additions & 2 deletions src/zope/sendmail/delivery.py
Expand Up @@ -34,10 +34,12 @@

# BBB: this import is needed for backward compatibility with older versions of
# zope.sendmail which defined QueueProcessorThread in this module
from zope.sendmail.queue import QueueProcessorThread
from zope.sendmail.queue import QueueProcessorThread # noqa: F401


log = logging.getLogger("MailDataManager")


@implementer(IDataManager)
class MailDataManager(object):

Expand Down Expand Up @@ -80,7 +82,7 @@ def tpc_vote(self, txn):
def tpc_finish(self, txn):
try:
self.callable(*self.args)
except Exception as e:
except Exception:
# Any exceptions here can cause database corruption.
# Better to protect the data and potentially miss emails than
# leave a database in an inconsistent state which requires a
Expand Down
9 changes: 4 additions & 5 deletions src/zope/sendmail/interfaces.py
Expand Up @@ -112,7 +112,7 @@ class IMailQueueProcessor(Interface):
pollingInterval = Int(
title=_(u"Polling Interval"),
description=_(u"How often the queue is checked for new messages"
" (in milliseconds)"),
u" (in milliseconds)"),
default=5000)

mailer = Attribute("IMailer that is used for message delivery")
Expand All @@ -134,12 +134,12 @@ def send(fromaddr, toaddrs, message):
Messages are sent immediately.
"""

def abort():
"""Abort sending the message for asynchronous subclasses."""

def vote(fromaddr, toaddrs, message):
"""Raise an exception if there is a known reason why the message
"""Raise an exception if there is a known reason why the message
cannot be sent."""


Expand Down Expand Up @@ -253,4 +253,3 @@ def abort():
Calling ``abort()`` more than once is allowed.
"""

5 changes: 3 additions & 2 deletions src/zope/sendmail/maildir.py
Expand Up @@ -25,6 +25,7 @@
IMaildirFactory, IMaildir, IMaildirMessageWriter
from zope.sendmail._compat import text_type


@provider(IMaildirFactory)
@implementer(IMaildir)
class Maildir(object):
Expand Down Expand Up @@ -91,7 +92,8 @@ def newMessage(self):
random.randrange(randmax))
filename = join(subdir_tmp, unique)
try:
fd = os.open(filename, os.O_CREAT|os.O_EXCL|os.O_WRONLY, 0o600)
fd = os.open(filename, os.O_CREAT | os.O_EXCL | os.O_WRONLY,
0o600)
except OSError as e:
if e.errno != errno.EEXIST:
raise
Expand Down Expand Up @@ -119,7 +121,6 @@ def _encode_utf8(s):
class MaildirMessageWriter(object):
"""See :class:`zope.sendmail.interfaces.IMaildirMessageWriter`"""


def __init__(self, fd, filename, new_filename):
self._filename = filename
self._new_filename = new_filename
Expand Down
5 changes: 3 additions & 2 deletions src/zope/sendmail/mailer.py
Expand Up @@ -31,6 +31,7 @@ class _SMTPState(local):
code = None
response = None


@implementer(ISMTPMailer)
class SMTPMailer(object):
"""Implementation of :class:`zope.sendmail.interfaces.ISMTPMailer`."""
Expand Down Expand Up @@ -107,8 +108,8 @@ def send(self, fromaddr, toaddrs, message):
password = password.encode('utf-8') # pragma: PY2
connection.login(username, password)
elif self.username:
raise RuntimeError('Mailhost does not support ESMTP but a username '
'is configured')
raise RuntimeError(
'Mailhost does not support ESMTP but a username is configured')

try:
connection.sendmail(fromaddr, toaddrs, message)
Expand Down

0 comments on commit 2ee8b0a

Please sign in to comment.