[Spambayes-checkins] spambayes/spambayes message.py, 1.56, 1.57 smtpproxy.py, 1.7, 1.8

Tony Meyer anadelonbrin at users.sourceforge.net
Tue Nov 9 03:30:36 CET 2004


Update of /cvsroot/spambayes/spambayes/spambayes
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6343/spambayes

Modified Files:
	message.py smtpproxy.py 
Log Message:
Use email.message_from_string(text, _class) rather than our wrapper functions, to
 avoid the Python 2.4 DeprecationWarnings about the strict argument.

Index: message.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/spambayes/message.py,v
retrieving revision 1.56
retrieving revision 1.57
diff -C2 -d -r1.56 -r1.57
*** message.py	5 Nov 2004 03:03:00 -0000	1.56
--- message.py	9 Nov 2004 02:30:33 -0000	1.57
***************
*** 237,247 ****
          # non-persistent state includes all of email.Message.Message state
  
!     # This function (and it's hackishness) can be avoided by using the
!     # message_from_string and sbheadermessage_from_string functions
!     # at the end of the module.  i.e. instead of doing this:
      #   >>> msg = spambayes.message.SBHeaderMessage()
      #   >>> msg.setPayload(substance)
      # you do this:
!     #   >>> msg = sbheadermessage_from_string(substance)
      # imapfilter has an example of this in action
      def setPayload(self, payload):
--- 237,247 ----
          # non-persistent state includes all of email.Message.Message state
  
!     # This function (and it's hackishness) can be avoided by using
!     # email.message_from_string(text, _class=SBHeaderMessage)
!     # i.e. instead of doing this:
      #   >>> msg = spambayes.message.SBHeaderMessage()
      #   >>> msg.setPayload(substance)
      # you do this:
!     #   >>> msg = email.message_from_string(substance, _class=SBHeaderMessage)
      # imapfilter has an example of this in action
      def setPayload(self, payload):
***************
*** 485,495 ****
          del self[options['Headers','trained_header_name']]
  
- # These perform similar functions to email.message_from_string()
- def message_from_string(s, _class=Message, strict=False):
-     return email.message_from_string(s, _class, strict)
- 
- def sbheadermessage_from_string(s, _class=SBHeaderMessage, strict=False):
-     return email.message_from_string(s, _class, strict)
- 
  # Utility function to insert an exception header into the given RFC822 text.
  # This is used by both sb_server and sb_imapfilter, so it's handy to have
--- 485,488 ----

Index: smtpproxy.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/spambayes/smtpproxy.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** smtpproxy.py	16 Mar 2004 05:08:31 -0000	1.7
--- smtpproxy.py	9 Nov 2004 02:30:33 -0000	1.8
***************
*** 128,135 ****
  import sys
  import os
  
  from spambayes import Dibbler
  from spambayes import storage
! from spambayes.message import sbheadermessage_from_string
  from spambayes.tokenizer import textparts
  from spambayes.tokenizer import try_to_repair_damaged_base64
--- 128,136 ----
  import sys
  import os
+ import email
  
  from spambayes import Dibbler
  from spambayes import storage
! from spambayes import message
  from spambayes.tokenizer import textparts
  from spambayes.tokenizer import try_to_repair_damaged_base64
***************
*** 385,389 ****
  
      def extractSpambayesID(self, data):
!         msg = sbheadermessage_from_string(data)
  
          # The nicest MUA is one that forwards the header intact.
--- 386,390 ----
  
      def extractSpambayesID(self, data):
!         msg = email.message_from_string(data, _class=message.SBHeaderMessage)
  
          # The nicest MUA is one that forwards the header intact.
***************
*** 436,440 ****
              self.train_cached_message(id, isSpam)
          # Otherwise, train on the forwarded/bounced message.
!         msg = sbheadermessage_from_string(msg)
          id = msg.setIdFromPayload()
          msg.delSBHeaders()
--- 437,441 ----
              self.train_cached_message(id, isSpam)
          # Otherwise, train on the forwarded/bounced message.
!         msg = email.message_from_string(msg, _class=message.SBHeaderMessage)
          id = msg.setIdFromPayload()
          msg.delSBHeaders()



More information about the Spambayes-checkins mailing list