[debian/*.py] remove trailing whitespaces
Ignore-this: f62e84c258c847013d307d12acdf489e darcs-hash:20090309212356-0445d-d8338d06f968f316fcd085446023123be87040f7.gz
This commit is contained in:
parent
cc31727b60
commit
eae0d21f83
18 changed files with 352 additions and 352 deletions
|
@ -20,10 +20,10 @@ def format_sender(sender, header_charset='ISO-8859-15'):
|
|||
"""
|
||||
from email.Header import Header
|
||||
from email.Utils import parseaddr, formataddr
|
||||
|
||||
|
||||
# Split real name (which is optional) and email address parts
|
||||
sender_name, sender_addr = parseaddr(sender)
|
||||
|
||||
|
||||
# We must always pass Unicode strings to Header, otherwise it will
|
||||
# use RFC 2047 encoding even on plain ASCII strings.
|
||||
sender_name = str(Header(unicode(sender_name), header_charset))
|
||||
|
@ -71,14 +71,14 @@ def send_email(sender, recipient, subject, body, server='localhost', cc=None, de
|
|||
sender = format_sender(sender)
|
||||
recipient = format_sender(recipient)
|
||||
if cc: cc = format_sender(cc)
|
||||
|
||||
|
||||
# Create the message ('plain' stands for Content-Type: text/plain)
|
||||
msg = MIMEText(body.encode(body_charset), 'plain', body_charset)
|
||||
msg['From'] = sender
|
||||
msg['To'] = recipient
|
||||
msg['Subject'] = Header(unicode(subject), header_charset)
|
||||
if cc: msg['Cc'] = cc
|
||||
|
||||
|
||||
if debug:
|
||||
actual_recipient = [debug]
|
||||
else:
|
||||
|
@ -89,7 +89,7 @@ def send_email(sender, recipient, subject, body, server='localhost', cc=None, de
|
|||
actual_sender = format_sender(actual_sender)
|
||||
else:
|
||||
actual_sender = sender
|
||||
|
||||
|
||||
# Send the message
|
||||
if isinstance(server, SMTP):
|
||||
server.sendmail(actual_sender, actual_recipient, msg.as_string())
|
||||
|
@ -113,23 +113,23 @@ def parse_mail_template(fichier):
|
|||
"""
|
||||
if not isinstance(fichier, file):
|
||||
fichier = file(fichier)
|
||||
|
||||
|
||||
encoding = fichier.readline()
|
||||
matched = re.search(r'^Encoding:\s*([^\r\n]*)', encoding)
|
||||
if matched:
|
||||
encoding = matched.group(1)
|
||||
else:
|
||||
raise SyntaxError("Encoding manquant dans template")
|
||||
|
||||
|
||||
subject = fichier.readline()
|
||||
matched = re.search(r'^Subject:\s*([^\r\n]*)', subject)
|
||||
if matched:
|
||||
subject = matched.group(1).decode(encoding)
|
||||
else:
|
||||
raise SyntaxError("Subject manquant dans template")
|
||||
|
||||
|
||||
if fichier.readline() not in ['\r\n', '\n']:
|
||||
raise SyntaxError("le fichier n'a pas le bon format")
|
||||
|
||||
|
||||
body = fichier.read().decode(encoding)
|
||||
return subject, body
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue