From: alexander s. <a1...@us...> - 2007-04-03 06:43:34
|
Update of /cvsroot/roundup/roundup/roundup In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv29383 Modified Files: mailgw.py Log Message: parseContent API modified to take single config argument Index: mailgw.py =================================================================== RCS file: /cvsroot/roundup/roundup/roundup/mailgw.py,v retrieving revision 1.186 retrieving revision 1.187 diff -C2 -r1.186 -r1.187 *** mailgw.py 26 Mar 2007 06:19:55 -0000 1.186 --- mailgw.py 3 Apr 2007 06:43:30 -0000 1.187 *************** *** 82,86 **** import traceback, MimeWriter, rfc822 ! from roundup import hyperdb, date, password, rfc2822, exceptions from roundup.mailer import Mailer, MessageSendError from roundup.i18n import _ --- 82,86 ---- import traceback, MimeWriter, rfc822 ! from roundup import configuration, hyperdb, date, password, rfc2822, exceptions from roundup.mailer import Mailer, MessageSendError from roundup.i18n import _ *************** *** 637,642 **** # Look for Re: et. al. Used later on for MAILGW_SUBJECT_CONTENT_MATCH ! refwd_re = config['MAILGW_REFWD_RE'].decode('iso8859-1') ! re_re = r'''(?P<refwd>%s)*\s*''' % refwd_re m = re.match(re_re, tmpsubject, re.IGNORECASE|re.VERBOSE|re.UNICODE) if m: --- 637,641 ---- # Look for Re: et. al. Used later on for MAILGW_SUBJECT_CONTENT_MATCH ! re_re = r"(?P<refwd>%s)*\s*" % config["MAILGW_REFWD_RE"].pattern m = re.match(re_re, tmpsubject, re.IGNORECASE|re.VERBOSE|re.UNICODE) if m: *************** *** 665,669 **** # Skip to the end of the class identifier, including any # garbage before it. ! tmpsubject = tmpsubject[m.end():] --- 664,668 ---- # Skip to the end of the class identifier, including any # garbage before it. ! tmpsubject = tmpsubject[m.end():] *************** *** 1007,1021 **** """) - # figure how much we should muck around with the email body - keep_citations = config['MAILGW_KEEP_QUOTED_TEXT'] - keep_body = config['MAILGW_LEAVE_BODY_UNCHANGED'] - blank_line = re.compile(config['MAILGW_BLANKLINE_RE']) - eol = re.compile(config['MAILGW_EOL_RE']) - signature = re.compile(config['MAILGW_SIGN_RE']) - original_msg = re.compile(config['MAILGW_ORIGMSG_RE']) - # parse the body of the message, stripping out bits as appropriate ! summary, content = parseContent(content, keep_citations, ! keep_body, blank_line, eol, signature, original_msg) content = content.strip() --- 1006,1011 ---- """) # parse the body of the message, stripping out bits as appropriate ! summary, content = parseContent(content, config=config) content = content.strip() *************** *** 1218,1231 **** return 0 ! def parseContent(content, keep_citations, keep_body, blank_line, eol, signature, original_msg): ! ''' The message body is divided into sections by blank lines. ! Sections where the second and all subsequent lines begin with a ">" ! or "|" character are considered "quoting sections". The first line of ! the first non-quoting section becomes the summary of the message. ! ! If keep_citations is true, then we keep the "quoting sections" in the ! content. ! If keep_body is true, we even keep the signature sections. ! ''' # strip off leading carriage-returns / newlines i = 0 --- 1208,1241 ---- return 0 ! def parseContent(content, keep_citations=None, keep_body=None, config=None): ! """Parse mail message; return message summary and stripped content ! ! The message body is divided into sections by blank lines. ! Sections where the second and all subsequent lines begin with a ">" ! or "|" character are considered "quoting sections". The first line of ! the first non-quoting section becomes the summary of the message. ! ! Arguments: ! ! keep_citations: declared for backward compatibility. ! If omitted or None, use config["MAILGW_KEEP_QUOTED_TEXT"] ! ! keep_body: declared for backward compatibility. ! If omitted or None, use config["MAILGW_LEAVE_BODY_UNCHANGED"] ! ! config: tracker configuration object. ! If omitted or None, use default configuration. ! ! """ ! if config is None: ! config = configuration.CoreConfig() ! if keep_citations is None: ! keep_citations = config["MAILGW_KEEP_QUOTED_TEXT"] ! if keep_body is None: ! keep_body = config["MAILGW_LEAVE_BODY_UNCHANGED"] ! eol = config["MAILGW_EOL_RE"] ! signature = config["MAILGW_SIGN_RE"] ! original_msg = config["MAILGW_ORIGMSG_RE"] ! # strip off leading carriage-returns / newlines i = 0 *************** *** 1234,1240 **** break if i > 0: ! sections = blank_line.split(content[i:]) else: ! sections = blank_line.split(content) # extract out the summary from the message --- 1244,1250 ---- break if i > 0: ! sections = config["MAILGW_BLANKLINE_RE"].split(content[i:]) else: ! sections = config["MAILGW_BLANKLINE_RE"].split(content) # extract out the summary from the message |