comparison roundup/mailgw.py @ 1677:d4e615fcbe04

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.
author Jean Jordaan <neaj@users.sourceforge.net>
date Mon, 23 Jun 2003 08:37:15 +0000
parents dc543c28a7d0
children 3c3e44aacdb4
comparison
equal deleted inserted replaced
1676:4856faf558a2 1677:d4e615fcbe04
71 set() method to add the message to the item's spool; in the second case we 71 set() method to add the message to the item's spool; in the second case we
72 are calling the create() method to create a new node). If an auditor raises 72 are calling the create() method to create a new node). If an auditor raises
73 an exception, the original message is bounced back to the sender with the 73 an exception, the original message is bounced back to the sender with the
74 explanatory message given in the exception. 74 explanatory message given in the exception.
75 75
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 $
77 ''' 77 '''
78 78
79 import string, re, os, mimetools, cStringIO, smtplib, socket, binascii, quopri 79 import string, re, os, mimetools, cStringIO, smtplib, socket, binascii, quopri
80 import time, random, sys 80 import time, random, sys
81 import traceback, MimeWriter, rfc822 81 import traceback, MimeWriter, rfc822
186 186
187 def getheader(self, name, default=None): 187 def getheader(self, name, default=None):
188 hdr = mimetools.Message.getheader(self, name, default) 188 hdr = mimetools.Message.getheader(self, name, default)
189 return rfc2822.decode_header(hdr) 189 return rfc2822.decode_header(hdr)
190 190
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
195 class MailGW: 191 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
196 def __init__(self, instance, db, arguments={}): 206 def __init__(self, instance, db, arguments={}):
197 self.instance = instance 207 self.instance = instance
198 self.db = db 208 self.db = db
199 self.arguments = arguments 209 self.arguments = arguments
200 210
493 ''' 503 '''
494 504
495 if subject.strip().lower() == 'help': 505 if subject.strip().lower() == 'help':
496 raise MailUsageHelp 506 raise MailUsageHelp
497 507
498 m = subject_re.match(subject) 508 m = self.subject_re.match(subject)
499 509
500 # check for well-formed subject line 510 # check for well-formed subject line
501 if m: 511 if m:
502 # get the classname 512 # get the classname
503 classname = m.group('classname') 513 classname = m.group('classname')

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