comparison roundup/roundupdb.py @ 1299:b2d04ce03802

Email improvements. - updated email package address formatting (deprecation) - copied email address quoting from email v2.4.3 so we're consistent with 2.2 - email summary extraction now takes the first whole sentence or line - whichever is longer
author Richard Jones <richard@users.sourceforge.net>
date Tue, 05 Nov 2002 22:59:46 +0000
parents fe67477e678f
children 328d68db2ef8
comparison
equal deleted inserted replaced
1298:f0ab014eaf72 1299:b2d04ce03802
13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" 14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS"
15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, 15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
17 # 17 #
18 # $Id: roundupdb.py,v 1.72 2002-10-08 07:28:34 richard Exp $ 18 # $Id: roundupdb.py,v 1.73 2002-11-05 22:59:46 richard Exp $
19 19
20 __doc__ = """ 20 __doc__ = """
21 Extending hyperdb with types specific to issue-tracking. 21 Extending hyperdb with types specific to issue-tracking.
22 """ 22 """
23 23
24 import re, os, smtplib, socket, time, random 24 import re, os, smtplib, socket, time, random
25 import MimeWriter, cStringIO 25 import MimeWriter, cStringIO
26 import base64, quopri, mimetypes 26 import base64, quopri, mimetypes
27 # if available, use the 'email' module, otherwise fallback to 'rfc822' 27 # if available, use the 'email' module, otherwise fallback to 'rfc822'
28 try : 28 try :
29 from email.Utils import dump_address_pair as straddr 29 from email.Utils import formataddr as straddr
30 except ImportError : 30 except ImportError :
31 from rfc822 import dump_address_pair as straddr 31 # code taken from the email package 2.4.3
32 def straddr(pair, specialsre = re.compile(r'[][\()<>@,:;".]'),
33 escapesre = re.compile(r'[][\()"]')):
34 name, address = pair
35 if name:
36 quotes = ''
37 if specialsre.search(name):
38 quotes = '"'
39 name = escapesre.sub(r'\\\g<0>', name)
40 return '%s%s%s <%s>' % (quotes, name, quotes, address)
41 return address
32 42
33 import hyperdb 43 import hyperdb
34 44
35 # set to indicate to roundup not to actually _send_ email 45 # set to indicate to roundup not to actually _send_ email
36 # this var must contain a file to write the mail to 46 # this var must contain a file to write the mail to

Roundup Issue Tracker: http://roundup-tracker.org/