Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove pyramid dependency #97

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
6 changes: 6 additions & 0 deletions pyramid_mailer/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@ def _qencode(s):
enc = quopri.encodestring(s, quotetabs=True)
# Must encode spaces, which quopri.encodestring() doesn't do
return enc.replace(b' ', b'=20')


try:
string_types = (basestring,)
except NameError:
string_types = (str,)
43 changes: 40 additions & 3 deletions pyramid_mailer/mailer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,52 @@
from random import sample
import smtplib

from pyramid.settings import asbool
from pyramid.settings import aslist
from repoze.sendmail.mailer import SMTPMailer
from repoze.sendmail.mailer import SendmailMailer
from repoze.sendmail.delivery import DirectMailDelivery
from repoze.sendmail.delivery import QueuedMailDelivery
import transaction

from pyramid_mailer._compat import SMTP_SSL
from pyramid_mailer._compat import SMTP_SSL, string_types

truthy = frozenset(('t', 'true', 'y', 'yes', 'on', '1'))


def asbool(s):
"""Return the boolean value ``True`` if the case-lowered value of string
input ``s`` is a :term:`truthy string`. If ``s`` is already one of the
boolean values ``True`` or ``False``, return it."""
if s is None:
return False
if isinstance(s, bool):
return s
s = str(s).strip()
return s.lower() in truthy


def aslist_cronly(value):
if isinstance(value, string_types):
value = filter(None, [x.strip() for x in value.splitlines()])
return list(value)


def aslist(value, flatten=True):
"""Return a list, separating the input based on newlines.
Also if ``flatten`` is ``True`` (the default), and if the line
is a string, then the line will be split on spaces.
"""
values = aslist_cronly(value)
if not flatten:
return values
result = []
for value in values:
if isinstance(value, str):
value = value.split()
result.extend(value)
else:
result.append(value)
return result



def _check_bind_options(kw):
Expand Down
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
'pylons-sphinx-themes >= 1.0.10',
]

tests_require = []
tests_require = ['pyramid']

testing_extras = tests_require + [
'nose',
Expand Down Expand Up @@ -41,7 +41,6 @@
zip_safe=False,
platforms='any',
install_requires=[
'pyramid',
'repoze.sendmail>=4.1',
'transaction',
],
Expand Down