[Spambayes-checkins] spambayes/Outlook2000 msgstore.py,1.27,1.28

Tim Peters tim_one@users.sourceforge.net
Wed Nov 13 18:30:04 2002


Update of /cvsroot/spambayes/spambayes/Outlook2000
In directory usw-pr-cvs1:/tmp/cvs-serv28672/Outlook2000

Modified Files:
	msgstore.py 
Log Message:
_GetMessageText():  Use extract_headers() from mboxutils, instead of
our own cut'n'paste duplicate.


Index: msgstore.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/Outlook2000/msgstore.py,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -d -r1.27 -r1.28
*** msgstore.py	12 Nov 2002 23:33:45 -0000	1.27
--- msgstore.py	13 Nov 2002 18:30:01 -0000	1.28
***************
*** 10,53 ****
  
  
- # XXX
- # import mboxutils  doesn't work at this point.  The extract_headers function
- # here is a copy-and-paste.
- header_break_re = re.compile(r"\r?\n(\r?\n)")
- 
- def extract_headers(text):
-     """Very simple-minded header extraction:  prefix of text up to blank line.
- 
-     A blank line is recognized via two adjacent line-ending sequences, where
-     a line-ending sequence is a newline optionally preceded by a carriage
-     return.
- 
-     If no blank line is found, all of text is considered to be a potential
-     header section.  If a blank line is found, the text up to (but not
-     including) the blank line is considered to be a potential header section.
- 
-     The potential header section is returned, unless it doesn't contain a
-     colon, in which case an empty string is returned.
- 
-     >>> extract_headers("abc")
-     ''
-     >>> extract_headers("abc\\n\\n\\n")  # no colon
-     ''
-     >>> extract_headers("abc: xyz\\n\\n\\n")
-     'abc: xyz\\n'
-     >>> extract_headers("abc: xyz\\r\\n\\r\\n\\r\\n")
-     'abc: xyz\\r\\n'
-     >>> extract_headers("a: b\\ngibberish\\n\\nmore gibberish")
-     'a: b\\ngibberish\\n'
-     """
- 
-     m = header_break_re.search(text)
-     if m:
-         eol = m.start(1)
-         text = text[:eol]
-     if ':' not in text:
-         text = ""
-     return text
- 
- 
  # Abstract definition - can be moved out when we have more than one sub-class <wink>
  # External interface to this module is almost exclusively via a "folder ID"
--- 10,13 ----
***************
*** 414,417 ****
--- 374,379 ----
          # in an attachment.  Later.
          # Oh - and for multipart/signed messages <frown>
+         import mboxutils
+ 
          self._EnsureObject()
          prop_ids = (PR_TRANSPORT_MESSAGE_HEADERS_A,
***************
*** 429,433 ****
          # of stuff now that can't possibly be parsed as "real" (SMTP)
          # headers.
!         headers = extract_headers(headers)
  
          # Mail delivered internally via Exchange Server etc may not have
--- 391,395 ----
          # of stuff now that can't possibly be parsed as "real" (SMTP)
          # headers.
!         headers = mboxutils.extract_headers(headers)
  
          # Mail delivered internally via Exchange Server etc may not have





More information about the Spambayes-checkins mailing list