~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/services/mail/sendmail.py

Move the functions around again.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
"""
16
16
 
17
17
__all__ = [
 
18
    'append_footer',
18
19
    'format_address',
19
20
    'get_msgid',
20
21
    'MailController',
91
92
            "Address contains carriage returns: %r" % (addr,))
92
93
 
93
94
 
 
95
def append_footer(main, footer):
 
96
    """Append a footer to an email, following signature conventions.
 
97
 
 
98
    If there is no footer, do nothing.
 
99
    If there is already a signature, append an additional footer.
 
100
    If there is no existing signature, append '-- \n' and a footer.
 
101
 
 
102
    :param main: The main content, which may have a signature.
 
103
    :param footer: An additional footer to append.
 
104
    :return: a new version of main that includes the footer.
 
105
    """
 
106
    if footer == '':
 
107
        footer_separator = ''
 
108
    elif '\n-- \n' in main:
 
109
        footer_separator = '\n'
 
110
    else:
 
111
        footer_separator = '\n-- \n'
 
112
    return ''.join((main, footer_separator, footer))
 
113
 
 
114
 
94
115
def format_address(name, address):
95
116
    r"""Formats a name and address to be used as an email header.
96
117