[Spambayes-checkins] spambayes/scripts sb_mboxtrain.py,1.1,1.2
Tony Meyer
anadelonbrin at users.sourceforge.net
Tue Sep 9 01:03:57 EDT 2003
Update of /cvsroot/spambayes/spambayes/scripts
In directory sc8-pr-cvs1:/tmp/cvs-serv6536/scripts
Modified Files:
sb_mboxtrain.py
Log Message:
Implement half of [ 801699 ] migration from hammie to sb_* scripts
(although in a different way)
This makes it optional to write the X-Spambayes-Trained header, to ease transition
from hammie.py
Index: sb_mboxtrain.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/scripts/sb_mboxtrain.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** sb_mboxtrain.py 5 Sep 2003 01:16:45 -0000 1.1
--- sb_mboxtrain.py 9 Sep 2003 07:03:54 -0000 1.2
***************
*** 116,119 ****
--- 116,121 ----
continue
trained += 1
+ if not options["Headers", "include_trained"]:
+ continue
f = file(tfn, "wb")
f.write(msg.as_string())
***************
*** 155,177 ****
if msg_train(h, msg, is_spam, force):
trained += 1
! # Write it out with the Unix "From " line
! outf.write(msg.as_string(True))
! outf.seek(0)
! try:
! os.ftruncate(f.fileno(), 0)
! f.seek(0)
! except:
! # If anything goes wrong, don't try to write
! print "Problem truncating mbox--nothing written"
! raise
! try:
! for line in outf.xreadlines():
! f.write(line)
! except:
! print >> sys.stderr ("Problem writing mbox! Sorry, "
! "I tried my best, but your mail "
! "may be corrupted.")
! raise
fcntl.lockf(f, fcntl.LOCK_UN)
f.close()
--- 157,181 ----
if msg_train(h, msg, is_spam, force):
trained += 1
! if not options["Headers", "include_trained"]:
! # Write it out with the Unix "From " line
! outf.write(msg.as_string(True))
! if not options["Headers", "include_trained"]:
! outf.seek(0)
! try:
! os.ftruncate(f.fileno(), 0)
! f.seek(0)
! except:
! # If anything goes wrong, don't try to write
! print "Problem truncating mbox--nothing written"
! raise
! try:
! for line in outf.xreadlines():
! f.write(line)
! except:
! print >> sys.stderr ("Problem writing mbox! Sorry, "
! "I tried my best, but your mail "
! "may be corrupted.")
! raise
fcntl.lockf(f, fcntl.LOCK_UN)
f.close()
***************
*** 203,206 ****
--- 207,212 ----
msg_train(h, msg, is_spam, force)
trained += 1
+ if not options["Headers", "include_trained"]:
+ continue
f = file(tfn, "wb")
f.write(msg.as_string())
***************
*** 290,293 ****
--- 296,300 ----
if loud: print "Training ham (%s):" % g
train(h, g, False, force, trainnew, removetrained)
+ sys.stdout.flush()
save = True
***************
*** 295,298 ****
--- 302,306 ----
if loud: print "Training spam (%s):" % s
train(h, s, True, force, trainnew, removetrained)
+ sys.stdout.flush()
save = True
More information about the Spambayes-checkins
mailing list