[Spambayes-checkins] spambayes/spambayes message.py,1.48,1.49

Tony Meyer anadelonbrin at users.sourceforge.net
Sat Apr 24 23:45:33 EDT 2004


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

Modified Files:
	message.py 
Log Message:
If the move_trained_[ham|spam]_to_folder options were used, this would
wipe out the SpamBayes headers.  Fix that.

Update message.py for the newer way that the persistent_use_database option
works.

Index: message.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/spambayes/message.py,v
retrieving revision 1.48
retrieving revision 1.49
diff -C2 -d -r1.48 -r1.49
*** message.py	15 Feb 2004 23:30:49 -0000	1.48
--- message.py	25 Apr 2004 03:45:30 -0000	1.49
***************
*** 206,212 ****
  # Once there is a master db, this option can be removed.
  message_info_db_name = get_pathname_option("Storage", "messageinfo_storage_file")
! if options["Storage", "persistent_use_database"]:
      msginfoDB = MessageInfoDB(message_info_db_name)
! else:
      msginfoDB = MessageInfoPickle(message_info_db_name)
  
--- 206,214 ----
  # Once there is a master db, this option can be removed.
  message_info_db_name = get_pathname_option("Storage", "messageinfo_storage_file")
! if options["Storage", "persistent_use_database"] is True or \
!    options["Storage", "persistent_use_database"] == "dbm":
      msginfoDB = MessageInfoDB(message_info_db_name)
! elif options["Storage", "persistent_use_database"] is False or \
!      options["Storage", "persistent_use_database"] == "pickle":
      msginfoDB = MessageInfoPickle(message_info_db_name)
  
***************
*** 429,432 ****
--- 431,452 ----
              self[options['Headers','mailid_header_name']] = self.id
  
+     def currentSBHeaders(self):
+         """Return a dictionary containing the current values of the
+         SpamBayes headers.  This can be used to restore the values
+         after using the delSBHeaders() function."""
+         headers = {}
+         for header_name in [options['Headers','classification_header_name'],
+                             options['Headers','mailid_header_name'],
+                             options['Headers','classification_header_name'] + "-ID",
+                             options['Headers','thermostat_header_name'],
+                             options['Headers','evidence_header_name'],
+                             options['Headers','score_header_name'],
+                             options['Headers','trained_header_name'],
+                             ]:
+             value = self[header_name]
+             if value is not None:
+                 headers[header_name] = value
+         return headers
+ 
      def delSBHeaders(self):
          del self[options['Headers','classification_header_name']]




More information about the Spambayes-checkins mailing list