[Spambayes-checkins] spambayes/spambayes message.py,1.12,1.13
Tim Stone
timstone4 at users.sourceforge.net
Fri Apr 18 21:46:59 EDT 2003
Update of /cvsroot/spambayes/spambayes/spambayes
In directory sc8-pr-cvs1:/tmp/cvs-serv31121
Modified Files:
message.py
Log Message:
Converted to use the new options style.
Index: message.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/spambayes/message.py,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** message.py 19 Apr 2003 00:51:02 -0000 1.12
--- message.py 19 Apr 2003 03:46:56 -0000 1.13
***************
*** 176,179 ****
--- 176,182 ----
Nicked the regex from smtplib.quotedata.
"""
+ #XXX Tim doesn't like this regex. He will study it to
+ #XXX see if he can learn to like it, or come up with
+ #XXX something he likes better. - Tim
return re.sub(r'(?:\r\n|\n|\r(?!\n))', "\r\n", data)
***************
*** 194,202 ****
def GetClassification(self):
if self.c == 's':
! return options.header_spam_string
if self.c == 'h':
! return options.header_ham_string
if self.c == 'u':
! return options.header_unsure_string
return None
--- 197,205 ----
def GetClassification(self):
if self.c == 's':
! return options['hammie','header_spam_string']
if self.c == 'h':
! return options['hammie','header_ham_string']
if self.c == 'u':
! return options['hammie','header_unsure_string']
return None
***************
*** 206,217 ****
# may change, which would really screw this database up
! # an unrecognized string here is interpreted as unsure. Should
! # that condition actually raise an exception instead?
!
! if cls == options.header_spam_string:
self.c = 's'
! elif cls == options.header_ham_string:
self.c = 'h'
! elif cls == options.header_unsure_string:
self.c = 'u'
else:
--- 209,217 ----
# may change, which would really screw this database up
! if cls == options['hammie','header_spam_string']:
self.c = 's'
! elif cls == options['hammie','header_ham_string']:
self.c = 'h'
! elif cls == options['hammie','header_unsure_string']:
self.c = 'u'
else:
***************
*** 248,252 ****
def setIdFromPayload(self):
try:
! self.setId(self[options.pop3proxy_mailid_header_name])
except KeyError:
return None
--- 248,252 ----
def setIdFromPayload(self):
try:
! self.setId(self[options['pop3proxy','mailid_header_name']])
except KeyError:
return None
***************
*** 258,291 ****
add optional headers if needed.'''
! if prob < options.ham_cutoff:
! disposition = options.header_ham_string
! elif prob > options.spam_cutoff:
! disposition = options.header_spam_string
else:
! disposition = options.header_unsure_string
self.RememberClassification(disposition)
! self[options.hammie_header_name] = disposition
! if options.pop3proxy_include_prob:
! self[options.pop3proxy_prob_header_name] = prob
! if options.pop3proxy_include_thermostat:
thermostat = '**********'
! self[options.pop3proxy_thermostat_header_name] = \
thermostat[:int(prob*10)]
! if options.pop3proxy_include_evidence:
evd = "; ".join(["%r: %.2f" % (word, score)
! for word, score in clues
! if (word[0] == '*' or
! score <= options.clue_mailheader_cutoff or
! score >= 1.0 - options.clue_mailheader_cutoff)])
! self[options.pop3proxy_evidence_header_name] = evd
! if options.pop3proxy_add_mailid_to.find("header") != -1:
! self[options.pop3proxy_mailid_header_name] = self.id
!
! # print self._headers
! # print self.as_string()
# This won't work for now, because email.Message does not isolate message body
--- 258,288 ----
add optional headers if needed.'''
! if prob < options['hammie','ham_cutoff']:
! disposition = options['hammie','header_ham_string']
! elif prob > options['hammie','spam_cutoff']:
! disposition = options['hammie','header_spam_string']
else:
! disposition = options['hammie','header_unsure_string']
self.RememberClassification(disposition)
! self[options['hammie','header_name']] = disposition
! if options['pop3proxy','include_prob']:
! self[options['pop3proxy','prob_header_name']] = prob
! if options['pop3proxy','include_thermostat']:
thermostat = '**********'
! self[options['pop3proxy','thermostat_header_name']] = \
thermostat[:int(prob*10)]
! if options['pop3proxy','include_evidence']:
evd = "; ".join(["%r: %.2f" % (word, score)
! for word, score in clues
! if (word[0] == '*' or
! score <= options['hammie','clue_mailheader_cutoff'] or
! score >= 1.0 - options['hammie','clue_mailheader_cutoff'])])
! self[options['pop3proxy','evidence_header_name']] = evd
! if options['pop3proxy','add_mailid_to'].find("header") != -1:
! self[options['pop3proxy','mailid_header_name']] = self.id
# This won't work for now, because email.Message does not isolate message body
***************
*** 297,304 ****
def delSBHeaders(self):
! del self[options.hammie_header_name]
! del self[options.pop3proxy_mailid_header_name]
! del self[options.hammie_header_name + "-ID"] # test mode header
! del self[options.pop3proxy_prob_header_name]
! del self[options.pop3proxy_thermostat_header_name]
! del self[options.pop3proxy_evidence_header_name]
--- 294,301 ----
def delSBHeaders(self):
! del self[options['hammie','header_name']]
! del self[options['pop3proxy','mailid_header_name']]
! del self[options['hammie','header_name' + "-ID"]] # test mode header
! del self[options['pop3proxy','prob_header_name']]
! del self[options['pop3proxy','thermostat_header_name']]
! del self[options['pop3proxy','evidence_header_name']]
More information about the Spambayes-checkins
mailing list