Ignore:
Timestamp:
7 Apr 2014, 15:50:53 (11 years ago)
Author:
uli
Message:

pep8.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/smtp.py

    r10944 r11584  
    11## $Id$
    22##
    3 ## Copyright (C) 2012 Uli Fouquet & Henrik Bettermann
     3## Copyright (C) 2014 Uli Fouquet & Henrik Bettermann
    44## This program is free software; you can redistribute it and/or modify
    55## it under the terms of the GNU General Public License as published by
     
    5353from waeup.kofa.interfaces import IMailService
    5454
     55
    5556class DefaultMailService(grok.GlobalUtility):
    5657    """Returns a :class:`zope.sendmail.IMailDelivery`.
     
    6970            name = getattr(config, 'smtp_mailer', name)
    7071        return getUtility(IMailDelivery, name=name)
     72
    7173
    7274class FakeSMTPDelivery(grok.GlobalUtility):
     
    9294CHARSETS = ('US-ASCII', 'ISO-8859-1', 'UTF-8')
    9395
     96
    9497def encode_header_item(item):
    9598    """Turns `item`, a string into an SMTP header part string.
     
    104107    if not isinstance(item, unicode):
    105108        item = unicode(item, 'utf-8')
    106     return str(Header(item, 'iso-8859-1')) # try ascii, then latin1, then utf-8
     109    return str(Header(item, 'iso-8859-1'))  # try ascii, then latin1, utf-8
     110
    107111
    108112def encode_address(addr, name=u''):
     
    127131    return formataddr((name, addr))
    128132
     133
    129134def encode_body(text):
    130135    """Build MIME message part from text.
     
    139144    if not isinstance(text, unicode):
    140145        text = unicode(text, 'utf-8')
    141     charset = CHARSETS[-1] # fallback
     146    charset = CHARSETS[-1]  # fallback
    142147    for charset in CHARSETS:
    143148        try:
    144149            text = text.encode(charset)
    145150        except UnicodeError:
    146             pass # try next encoding
     151            pass  # try next encoding
    147152        else:
    148153            break
    149154    return MIMEText(text, 'plain', charset)
     155
    150156
    151157def send_mail(from_name, from_addr, rcpt_name, rcpt_addrs,
     
    154160    """
    155161    # format message
    156     rcpt_addrs = rcpt_addrs.replace(' ','').split(',')
     162    rcpt_addrs = rcpt_addrs.replace(' ', '').split(',')
    157163    body_to = ''
    158164    for email in rcpt_addrs:
Note: See TracChangeset for help on using the changeset viewer.