[Spambayes-checkins] spambayes/Outlook2000 manager.py, 1.69, 1.69.2.1

Mark Hammond mhammond at users.sourceforge.net
Sun Aug 3 23:30:00 EDT 2003


Update of /cvsroot/spambayes/spambayes/Outlook2000
In directory sc8-pr-cvs1:/tmp/cvs-serv26053

Modified Files:
      Tag: outlook-dialog-branch
	manager.py 
Log Message:
Move the logic for "can we be enabled" from the dialog back into the
manager.


Index: manager.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/Outlook2000/manager.py,v
retrieving revision 1.69
retrieving revision 1.69.2.1
diff -C2 -d -r1.69 -r1.69.2.1
*** manager.py	30 Jul 2003 03:22:51 -0000	1.69
--- manager.py	4 Aug 2003 05:29:58 -0000	1.69.2.1
***************
*** 7,10 ****
--- 7,11 ----
  import shutil
  import traceback
+ import operator
  import win32api, win32con, win32ui
  
***************
*** 687,690 ****
--- 688,719 ----
              self.ReportErrorOnce(msg)
              raise
+ 
+     def GetDisabledReason(self):
+         # Gets the reason why the plugin can not be enabled.
+         # If return is None, then it can be enabled (and indeed may be!)
+         # Otherwise return is the string reason
+         nspam = self.bayes.nspam
+         nham = self.bayes.nham
+         config = self.config.filter
+         # For the sake of getting reasonable results, let's insist
+         # on 5 spam and 5 ham messages before we can allow filtering
+         # to be enabled.
+         min_ham = 5
+         min_spam = 5
+         ok_to_enable = operator.truth(config.watch_folder_ids)
+         if not ok_to_enable:
+             return "You must define folders to watch for new messages"
+         
+         ok_to_enable = nspam >= min_spam and nham >= min_ham
+         if not ok_to_enable:
+             return "There must be %d good and %d spam messages\n" \
+                    "trained before filtering can be enabled" \
+                    % (min_ham, min_spam)
+ 
+         ok_to_enable = operator.truth(config.spam_folder_id)
+         if not ok_to_enable:
+             return "You must define the folder to receive your certain spam"
+ 
+         return None
  
      def ShowManager(self):





More information about the Spambayes-checkins mailing list