# HG changeset patch # User Jean Jordaan # Date 1056357435 0 # Node ID d4e615fcbe04b2c9a3d98c48adbf15270aec84ff # Parent 4856faf558a24b1becb85af98afa921b9eccf072 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. diff -r 4856faf558a2 -r d4e615fcbe04 roundup/mailgw.py --- a/roundup/mailgw.py Mon Jun 23 08:05:30 2003 +0000 +++ b/roundup/mailgw.py Mon Jun 23 08:37:15 2003 +0000 @@ -73,7 +73,7 @@ an exception, the original message is bounced back to the sender with the explanatory message given in the exception. -$Id: mailgw.py,v 1.123 2003-06-18 23:34:52 richard Exp $ +$Id: mailgw.py,v 1.124 2003-06-23 08:37:15 neaj Exp $ ''' import string, re, os, mimetools, cStringIO, smtplib, socket, binascii, quopri @@ -188,11 +188,21 @@ hdr = mimetools.Message.getheader(self, name, default) return rfc2822.decode_header(hdr) -subject_re = re.compile(r'(?P\s*\W?\s*(fw|fwd|re|aw)\W\s*)*' - r'\s*(?P")?(\[(?P[^\d\s]+)(?P\d+)?\])?' - r'\s*(?P[^[]+)?"?(\[(?P<args>.+?)\])?', re.I) +class MailGW: -class MailGW: + # Matches subjects like: + # Re: "[issue1234] title of issue [status=resolved]" + subject_re = re.compile(r''' + (?P<refwd>\s*\W?\s*(fw|fwd|re|aw)\W\s*)*\s* # Re: + (?P<quote>")? # Leading " + (\[(?P<classname>[^\d\s]+) # [issue.. + (?P<nodeid>\d+)? # ..1234] + \])?\s* + (?P<title>[^[]+)? # issue title + "? # Trailing " + (\[(?P<args>.+?)\])? # [prop=value] + ''', re.IGNORECASE|re.VERBOSE) + def __init__(self, instance, db, arguments={}): self.instance = instance self.db = db @@ -495,7 +505,7 @@ if subject.strip().lower() == 'help': raise MailUsageHelp - m = subject_re.match(subject) + m = self.subject_re.match(subject) # check for well-formed subject line if m: