[Spambayes-checkins] spambayes/spambayes message.py,1.61,1.62
Tony Meyer
anadelonbrin at users.sourceforge.net
Fri Dec 17 02:23:39 CET 2004
Update of /cvsroot/spambayes/spambayes/spambayes
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31195/spambayes
Modified Files:
message.py
Log Message:
The correct address separator is ',' not ';', so get notate_to to use that.
Spit out a warning if the deprecated function is used.
Change the deprecated function to work in Python 2.4 (this bit should be backported).
Index: message.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/spambayes/message.py,v
retrieving revision 1.61
retrieving revision 1.62
diff -C2 -d -r1.61 -r1.62
*** message.py 8 Dec 2004 03:34:29 -0000 1.61
--- message.py 17 Dec 2004 01:23:36 -0000 1.62
***************
*** 87,90 ****
--- 87,91 ----
import errno
import shelve
+ import warnings
try:
import cPickle as pickle
***************
*** 290,302 ****
This function does not work (as a result of using private
methods in a hackish way) in Python 2.4, so is now deprecated.
! Use *_from_string as described above."""
! prs = email.Parser.Parser()
! fp = StringIO.StringIO(payload)
! # this is kindof a hack, due to the fact that the parser creates a
! # new message object, and we already have the message object
! prs._parseheaders(self, fp)
! # we may want to do some header parsing error handling here
! # to try to extract important headers regardless of malformations
! prs._parsebody(self, fp)
def setId(self, id):
--- 291,307 ----
This function does not work (as a result of using private
methods in a hackish way) in Python 2.4, so is now deprecated.
! Use *_from_string as described above.
!
! More: Python 2.4 has a new email package, and the private functions
! are gone. So this won't even work. We have to do something to
! get this to work, for the 1.0.x branch, so use a different ugly
! hack.
! """
! warnings.warn("setPayload is deprecated. Use " \
! "email.message_from_string(payload, _class=" \
! "Message) instead.",
! DeprecationWarning, 2)
! new_me = email.message_from_string(payload, _class=Message)
! self.__dict__ = new_me.__dict__
def setId(self, id):
***************
*** 387,390 ****
--- 392,404 ----
'''Message class that is cognizant of SpamBayes headers.
Adds routines to add/remove headers for SpamBayes'''
+ def setPayload(self, payload):
+ """DEPRECATED.
+ """
+ warnings.warn("setPayload is deprecated. Use " \
+ "email.message_from_string(payload, _class=" \
+ "SBHeaderMessage) instead.",
+ DeprecationWarning, 2)
+ new_me = email.message_from_string(payload, _class=SBHeaderMessage)
+ self.__dict__ = new_me.__dict__
def setIdFromPayload(self):
***************
*** 486,490 ****
address = "%s at spambayes.invalid" % (disposition, )
try:
! self.replace_header("To", "%s;%s" % (address, self["To"]))
except KeyError:
self["To"] = address
--- 500,504 ----
address = "%s at spambayes.invalid" % (disposition, )
try:
! self.replace_header("To", "%s,%s" % (address, self["To"]))
except KeyError:
self["To"] = address
***************
*** 525,533 ****
break
to = self["To"]
! ham = "%s at spambayes.invalid;" % \
(options["Headers", "header_ham_string"],)
! spam = "%s at spambayes.invalid;" % \
(options["Headers", "header_spam_string"],)
! unsure = "%s at spambayes.invalid;" % \
(options["Headers", "header_unsure_string"],)
if options["Headers", "notate_to"]:
--- 539,547 ----
break
to = self["To"]
! ham = "%s at spambayes.invalid," % \
(options["Headers", "header_ham_string"],)
! spam = "%s at spambayes.invalid," % \
(options["Headers", "header_spam_string"],)
! unsure = "%s at spambayes.invalid," % \
(options["Headers", "header_unsure_string"],)
if options["Headers", "notate_to"]:
More information about the Spambayes-checkins
mailing list