[Spambayes-checkins] spambayes/Outlook2000 config_wizard.py, 1.1, 1.2

Mark Hammond mhammond at users.sourceforge.net
Fri Aug 22 00:12:40 EDT 2003


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

Modified Files:
	config_wizard.py 
Log Message:
More wizard work.


Index: config_wizard.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/Outlook2000/config_wizard.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** config_wizard.py	21 Aug 2003 13:16:12 -0000	1.1
--- config_wizard.py	22 Aug 2003 06:12:38 -0000	1.2
***************
*** 3,6 ****
--- 3,13 ----
  import copy
  
+ # NOTE: The Wizard works from a *complete* copy of the standard options
+ # but with an extra "Wizard" section to maintain state etc for the wizard.
+ # This initial option set may or may not have had values copied from the
+ # real runtime config - this allows either a "re-configure" or a
+ # "clean configure".
+ # Thus, the Wizard still uses standard config option where suitable - eg
+ # filter.watch_folder_ids
  wizard_defaults = {
      "Wizard" : (
***************
*** 8,54 ****
              """""",
          config.INTEGER, config.RESTORE),
!         (config.FolderIDOption,
!             "watch_folder_ids", "Folders to watch for new messages", [],
!             """The list of folders SpamBayes will watch for new messages,
!             processing messages as defined by the filters.""",
!             config.FOLDER_ID, config.DO_NOT_RESTORE),
          # Spam
          ("spam_folder_name", "Name of spam folder - ignored if ID set", "Spam",
              """""",
              "", config.RESTORE),
-         (config.FolderIDOption,
-             "spam_folder_id", "", None,
-             """""",
-             config.FOLDER_ID, config.DO_NOT_RESTORE),
          # unsure
          ("unsure_folder_name", "Name of unsure folder - ignored if ID set", "Maybe Spam",
              """""",
              "", config.RESTORE),
!         (config.FolderIDOption,
!             "unsure_folder_id", "", None,
!             """""",
!             config.FOLDER_ID, config.DO_NOT_RESTORE),
!         (config.FolderIDOption,
!             "train_ham_ids", "", [],
!             """""",
!             config.FOLDER_ID, config.DO_NOT_RESTORE),
!         (config.FolderIDOption,
!             "train_spam_ids", "", [],
!             """""",
!             config.FOLDER_ID, config.DO_NOT_RESTORE),
!         ),
!     }
  
  def InitWizardConfig(manager, new_config, from_existing = True):
      wc = new_config.wizard
-     wc.watch_folder_ids = []
      if from_existing:
          ids = copy.copy(manager.config.filter.watch_folder_ids)
          for id in ids:
              if manager.message_store.GetFolder(id) is not None:
!                 wc.watch_folder_ids.append(id)
!     if not wc.watch_folder_ids:
          for folder in manager.message_store.YieldReceiveFolders():
!             wc.watch_folder_ids.append(folder.GetID())
      if from_existing:
          fc = manager.config.filter
--- 15,49 ----
              """""",
          config.INTEGER, config.RESTORE),
!         ("need_train", "Will moving to the train page actually train?", True,
!             """""",
!         config.BOOLEAN, config.RESTORE),
!         ("can_go_next", "Is the Forward wizard button enabled?", True,
!             """""",
!         config.BOOLEAN, config.RESTORE),
          # Spam
          ("spam_folder_name", "Name of spam folder - ignored if ID set", "Spam",
              """""",
              "", config.RESTORE),
          # unsure
          ("unsure_folder_name", "Name of unsure folder - ignored if ID set", "Maybe Spam",
              """""",
              "", config.RESTORE),
!     ),
! }
  
  def InitWizardConfig(manager, new_config, from_existing = True):
+     new_config.filter.watch_folder_ids = []
+     new_config.filter.watch_include_sub = False
+     
      wc = new_config.wizard
      if from_existing:
          ids = copy.copy(manager.config.filter.watch_folder_ids)
          for id in ids:
+             # Only get the folders that actually exist.
              if manager.message_store.GetFolder(id) is not None:
!                 new_config.filter.watch_folder_ids.append(id)
!     if not new_config.filter.watch_folder_ids:
          for folder in manager.message_store.YieldReceiveFolders():
!             new_config.train.watch_folder_ids.append(folder.GetID())
      if from_existing:
          fc = manager.config.filter
***************
*** 56,73 ****
              folder = manager.message_store.GetFolder(fc.spam_folder_id)
              if folder is not None:
!                 wc.spam_folder_id = folder.GetID()
                  wc.spam_folder_name = ""
          if fc.unsure_folder_id:
              folder = manager.message_store.GetFolder(fc.unsure_folder_id)
              if folder is not None:
!                 wc.unsure_folder_id = folder.GetID()
                  wc.unsure_folder_name = ""
          tc = manager.config.training
          print "Ham are", tc.ham_folder_ids
          if tc.ham_folder_ids:
!             wc.train_ham_ids = tc.ham_folder_ids
          if tc.spam_folder_ids:
!             wc.train_spam_ids = tc.spam_folder_ids
!     if wc.train_ham_ids or wc.train_spam_ids:
          wc.preparation = 1 # "already prepared"
  
--- 51,68 ----
              folder = manager.message_store.GetFolder(fc.spam_folder_id)
              if folder is not None:
!                 new_config.filter.spam_folder_id = folder.GetID()
                  wc.spam_folder_name = ""
          if fc.unsure_folder_id:
              folder = manager.message_store.GetFolder(fc.unsure_folder_id)
              if folder is not None:
!                 new_config.filter.unsure_folder_id = folder.GetID()
                  wc.unsure_folder_name = ""
          tc = manager.config.training
          print "Ham are", tc.ham_folder_ids
          if tc.ham_folder_ids:
!             new_config.training.ham_folder_ids = tc.ham_folder_ids
          if tc.spam_folder_ids:
!             new_config.training.spam_folder_ids = tc.spam_folder_ids
!     if new_config.training.ham_folder_ids or new_config.training.spam_folder_ids:
          wc.preparation = 1 # "already prepared"
  





More information about the Spambayes-checkins mailing list