[Spambayes-checkins] spambayes/spambayes ImapUI.py, 1.9, 1.10 Options.py, 1.50, 1.51 ProxyUI.py, 1.7, 1.8 UserInterface.py, 1.8, 1.9 message.py, 1.25, 1.26

Tony Meyer anadelonbrin at users.sourceforge.net
Tue May 6 17:33:27 EDT 2003


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

Modified Files:
	ImapUI.py Options.py ProxyUI.py UserInterface.py message.py 
Log Message:
Delete any existing spambayes header before training.

Update option names to new names/styles.

Add storage option to allow specification of the messageinfo
database, so that copies don't end up littering lots of CWDs.
(Also provide access to this option in pop3proxy and imapfilter
ui's).

Index: ImapUI.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/spambayes/ImapUI.py,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** ImapUI.py	3 May 2003 22:16:30 -0000	1.9
--- ImapUI.py	6 May 2003 23:33:24 -0000	1.10
***************
*** 89,92 ****
--- 89,93 ----
      ('Categorization',        'ham_cutoff'),
      ('Categorization',        'spam_cutoff'),
+     ('Storage',               'messageinfo_storage_file'),
  )
  
***************
*** 142,146 ****
          self._writePreamble("Select Filter Folders")
          self._login_to_imap()
!         available_folders = self._folder_list()
          content = self.html.configForm.clone()
          content.configFormContent = ""
--- 143,147 ----
          self._writePreamble("Select Filter Folders")
          self._login_to_imap()
!         available_folders = self.imap.folder_list()
          content = self.html.configForm.clone()
          content.configFormContent = ""
***************
*** 191,195 ****
          self._writePreamble("Select Training Folders")
          self._login_to_imap()
!         available_folders = self._folder_list()
          content = self.html.configForm.clone()
          content.configFormContent = ""
--- 192,196 ----
          self._writePreamble("Select Training Folders")
          self._login_to_imap()
!         available_folders = self.imap.folder_list()
          content = self.html.configForm.clone()
          content.configFormContent = ""
***************
*** 259,285 ****
          return self._buildBox(options.display_name(section, option),
                                None, folderTable)
- 
-     def _folder_list(self):
-         '''Return a alphabetical list of all folders available
-         on the server'''
-         response = self.imap.list()
-         if response[0] != "OK":
-             return []
-         all_folders = response[1]
-         folders = []
-         for fol in all_folders:
-             r = re.compile(r"\(([\w\\ ]*)\) ")
-             m = r.search(fol)
-             name_attributes = fol[:m.end()-1]
-             # IMAP is a truly odd protocol.  The delimiter is
-             # only the delimiter for this particular folder - each
-             # folder *may* have a different delimiter
-             self.folder_delimiter = fol[m.end()+1:m.end()+2]
-             # a bit of a hack, but we really need to know if this is
-             # the case
-             if self.folder_delimiter == ',':
-                 print """WARNING: Your imap server uses commas as the folder
-                 delimiter.  This may cause unpredictable errors."""
-             folders.append(fol[m.end()+5:-1])
-         folders.sort()
-         return folders
--- 260,261 ----

Index: Options.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/spambayes/Options.py,v
retrieving revision 1.50
retrieving revision 1.51
diff -C2 -d -r1.50 -r1.51
*** Options.py	6 May 2003 22:59:00 -0000	1.50
--- Options.py	6 May 2003 23:33:24 -0000	1.51
***************
*** 614,617 ****
--- 614,627 ----
       directory.""",
       FILE_WITH_PATH, DO_NOT_RESTORE),
+ 
+     ("messageinfo_storage_file", "Message information file name", "spambayes.messageinfo.db",
+      """Spambayes builds a database of information about messages
+      that it has already seen and trained or classified.  This
+      database is used to ensure that these messages are retrained
+      or reclassified (unless specifically requested to).  This option
+      specifies the name of the database file.  If you don't give a
+      full pathname, the name will be taken to be relative to the current
+      working directory.""",
+      FILE_WITH_PATH, DO_NOT_RESTORE),
    ),
  

Index: ProxyUI.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/spambayes/ProxyUI.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** ProxyUI.py	4 May 2003 03:59:05 -0000	1.7
--- ProxyUI.py	6 May 2003 23:33:24 -0000	1.8
***************
*** 101,104 ****
--- 101,105 ----
      ('Categorization',      'ham_cutoff'),
      ('Categorization',      'spam_cutoff'),
+     ('Storage',             'messageinfo_storage_file'),
  )
  
***************
*** 340,346 ****
          if len(keys) == 0:
              keys, date, prior, this, next = self._buildReviewKeys(start)
!         keyedMessageInfo = {options.header_spam_string: [],
!                             options.header_ham_string: [],
!                             options.header_unsure_string: []}
          for key in keys:
              # Parse the message, get the judgement header and build a message
--- 341,347 ----
          if len(keys) == 0:
              keys, date, prior, this, next = self._buildReviewKeys(start)
!         keyedMessageInfo = {options["Headers", "header_spam_string"]: [],
!                             options["Headers", "header_ham_string"]: [],
!                             options["Headers", "header_unsure_string"]: []}
          for key in keys:
              # Parse the message, get the judgement header and build a message
***************
*** 348,354 ****
              cachedMessage = sourceCorpus[key]
              message = spambayes.mboxutils.get_message(cachedMessage.getSubstance())
!             judgement = message[options.hammie_header_name]
              if judgement is None:
!                 judgement = options.header_unsure_string
              else:
                  judgement = judgement.split(';')[0].strip()
--- 349,356 ----
              cachedMessage = sourceCorpus[key]
              message = spambayes.mboxutils.get_message(cachedMessage.getSubstance())
!             judgement = message[options["Headers",
!                                         "classification_header_name"]]
              if judgement is None:
!                 judgement = options["Headers", "header_unsure_string"]
              else:
                  judgement = judgement.split(';')[0].strip()
***************
*** 368,374 ****
              templateRow = page.reviewRow.clone()
              page.table = ""  # To make way for the real rows.
!             for header, label in ((options.header_spam_string, 'Spam'),
!                                   (options.header_ham_string, 'Ham'),
!                                   (options.header_unsure_string, 'Unsure')):
                  messages = keyedMessageInfo[header]
                  if messages:
--- 370,380 ----
              templateRow = page.reviewRow.clone()
              page.table = ""  # To make way for the real rows.
!             for header, label in ((options["Headers",
!                                            "header_spam_string"], 'Spam'),
!                                   (options["Headers",
!                                            "header_ham_string"], 'Ham'),
!                                   (options["Headers",
!                                            "header_unsure_string"],
!                                    'Unsure')):
                  messages = keyedMessageInfo[header]
                  if messages:

Index: UserInterface.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/spambayes/UserInterface.py,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** UserInterface.py	28 Apr 2003 23:36:24 -0000	1.8
--- UserInterface.py	6 May 2003 23:33:24 -0000	1.9
***************
*** 98,102 ****
      def onIncomingConnection(self, clientSocket):
          """Checks the security settings."""
!         return options.html_ui_allow_remote_connections or \
                 clientSocket.getpeername()[0] == clientSocket.getsockname()[0]
  
--- 98,102 ----
      def onIncomingConnection(self, clientSocket):
          """Checks the security settings."""
!         return options["html_ui", "allow_remote_connections"] or \
                 clientSocket.getpeername()[0] == clientSocket.getsockname()[0]
  

Index: message.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/spambayes/message.py,v
retrieving revision 1.25
retrieving revision 1.26
diff -C2 -d -r1.25 -r1.26
*** message.py	29 Apr 2003 13:46:18 -0000	1.25
--- message.py	6 May 2003 23:33:24 -0000	1.26
***************
*** 89,92 ****
--- 89,93 ----
  
  import sys
+ import os
  import types
  import re
***************
*** 128,133 ****
          del self.db[msg.getId()]
          
! # this should come from a Mark Hammond idea of a master db
! msginfoDB = MessageInfoDB("spambayes.messageinfo.db")
  
  class Message(email.Message.Message):
--- 129,139 ----
          del self.db[msg.getId()]
          
! # This should come from a Mark Hammond idea of a master db
! # For the moment, we get the name of another file from the options,
! # so that these files don't litter lots of working directories.
! # Once there is a master db, this option can be removed.
! message_info_db_name = options["Storage", "messageinfo_storage_file"]
! message_info_db_name = os.path.expanduser(message_info_db_name)
! msginfoDB = MessageInfoDB(message_info_db_name)
  
  class Message(email.Message.Message):





More information about the Spambayes-checkins mailing list