Skip to content

Commit 476199d

Browse files
author
Jean Jordaan
committed
Made subject_re an attribute of MailGW...
...so that it can be easily overridden in an instance's interfaces.MailGW, and wrote subject_re as a re.VERBOSE, with a couple of comments.
1 parent 7ff8bb0 commit 476199d

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

roundup/mailgw.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class node. Any parts of other types are each stored in separate files
7373
an exception, the original message is bounced back to the sender with the
7474
explanatory message given in the exception.
7575
76-
$Id: mailgw.py,v 1.123 2003-06-18 23:34:52 richard Exp $
76+
$Id: mailgw.py,v 1.124 2003-06-23 08:37:15 neaj Exp $
7777
'''
7878

7979
import string, re, os, mimetools, cStringIO, smtplib, socket, binascii, quopri
@@ -188,11 +188,21 @@ def getheader(self, name, default=None):
188188
hdr = mimetools.Message.getheader(self, name, default)
189189
return rfc2822.decode_header(hdr)
190190

191-
subject_re = re.compile(r'(?P<refwd>\s*\W?\s*(fw|fwd|re|aw)\W\s*)*'
192-
r'\s*(?P<quote>")?(\[(?P<classname>[^\d\s]+)(?P<nodeid>\d+)?\])?'
193-
r'\s*(?P<title>[^[]+)?"?(\[(?P<args>.+?)\])?', re.I)
194-
195191
class MailGW:
192+
193+
# Matches subjects like:
194+
# Re: "[issue1234] title of issue [status=resolved]"
195+
subject_re = re.compile(r'''
196+
(?P<refwd>\s*\W?\s*(fw|fwd|re|aw)\W\s*)*\s* # Re:
197+
(?P<quote>")? # Leading "
198+
(\[(?P<classname>[^\d\s]+) # [issue..
199+
(?P<nodeid>\d+)? # ..1234]
200+
\])?\s*
201+
(?P<title>[^[]+)? # issue title
202+
"? # Trailing "
203+
(\[(?P<args>.+?)\])? # [prop=value]
204+
''', re.IGNORECASE|re.VERBOSE)
205+
196206
def __init__(self, instance, db, arguments={}):
197207
self.instance = instance
198208
self.db = db
@@ -495,7 +505,7 @@ def handle_message(self, message):
495505
if subject.strip().lower() == 'help':
496506
raise MailUsageHelp
497507

498-
m = subject_re.match(subject)
508+
m = self.subject_re.match(subject)
499509

500510
# check for well-formed subject line
501511
if m:

0 commit comments

Comments
 (0)