[Spambayes-checkins] spambayes pop3proxy.py,1.17,1.18 Options.py,1.74,1.75

Richie Hindle richiehindle@users.sourceforge.net
Wed Nov 20 22:41:52 2002


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

Modified Files:
	pop3proxy.py Options.py 
Log Message:
 o Hovering the mouse on a message subject now displays a
   hovertip with some of the message in it (if that's how your
   browser handles the 'title' attribute).  Thanks to David Ascher
   for the suggestion.
 o Fixed Francois Granger's weird accept() problem (I think).
 o Removed gratuitous quotes from Options.py (thanks to papaDoc)


Index: pop3proxy.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/pop3proxy.py,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** pop3proxy.py	20 Nov 2002 12:45:21 -0000	1.17
--- pop3proxy.py	20 Nov 2002 22:41:50 -0000	1.18
***************
*** 56,59 ****
--- 56,63 ----
   o Review already-trained messages, and purge them.
   o Put in a link to view a message (plain text, html, multipart...?)
+  o Keyboard navigation (David Ascher).  But aren't Tab and left/right
+    arrow enough?
+  o [Francois Granger] Show the raw spambrob number close to the buttons
+    (this would mean using the extra X-Hammie header by default).
  
  
***************
*** 68,71 ****
--- 72,76 ----
     reload the database.
   o Save the stats (num classified, etc.) between sessions.
+  o "Reload database" button.
  
  
***************
*** 81,84 ****
--- 86,92 ----
   o Remove any existing X-Hammie-Disposition header from incoming emails.
   o Whitelist.
+  o Online manual.
+  o Links to project homepage, mailing list, etc.
+  o Edit settings through the web.
  
  
***************
*** 88,91 ****
--- 96,100 ----
   o Eventually, pull the common HTTP code from pop3proxy.py and Entrian
     Debugger into a library.
+  o Cope with the email client timing out and closing the connection.
  
  
***************
*** 112,115 ****
--- 121,125 ----
  import Bayes, tokenizer, mboxutils
  from FileCorpus import FileCorpus, FileMessageFactory, GzipFileMessageFactory
+ from email.Iterators import typed_subpart_iterator
  from Options import options
  
***************
*** 140,149 ****
  
      def handle_accept(self):
!         clientSocket, clientAddress = self.accept()
!         args = [clientSocket] + list(self.factoryArgs)
!         if self.socketMap != asyncore.socket_map:
!             self.factory(*args, **{'socketMap': self.socketMap})
!         else:
!             self.factory(*args)
  
  
--- 150,165 ----
  
      def handle_accept(self):
!         # If an incoming connection is instantly reset, eg. by following a
!         # link in the web interface then instantly following another one or
!         # hitting stop, handle_accept() will be triggered but accept() will
!         # return None.
!         result = self.accept()
!         if result:
!             clientSocket, clientAddress = result
!             args = [clientSocket] + list(self.factoryArgs)
!             if self.socketMap != asyncore.socket_map:
!                 self.factory(*args, **{'socketMap': self.socketMap})
!             else:
!                 self.factory(*args)
  
  
***************
*** 792,801 ****
              return form
  
!     def trimAndQuote(self, field, limit):
          """Trims a string, adding an ellipsis if necessary, and
          HTML-quotes it."""
          if len(field) > limit:
              field = field[:limit-3] + "..."
!         return cgi.escape(field)
  
      def onHome(self, params):
--- 808,817 ----
              return form
  
!     def trimAndQuote(self, field, limit, quote=False):
          """Trims a string, adding an ellipsis if necessary, and
          HTML-quotes it."""
          if len(field) > limit:
              field = field[:limit-3] + "..."
!         return cgi.escape(field, quote)
  
      def onHome(self, params):
***************
*** 815,819 ****
          self.push(' ')
          state.bayes.store()
!         self.push("Done</b>.")
  
      def onSave(self, params):
--- 831,835 ----
          self.push(' ')
          state.bayes.store()
!         self.push("Done</b>.\n")
  
      def onSave(self, params):
***************
*** 919,925 ****
          stripe = 0
          for key, message in keyedMessages:
!             # Parse the message and get the relevant headers.
              subject = self.trimAndQuote(message["Subject"] or "(none)", 50)
              from_ = self.trimAndQuote(message["From"] or "(none)", 40)
  
              # Output the table row for this message.
--- 935,955 ----
          stripe = 0
          for key, message in keyedMessages:
!             # Parse the message and get the relevant headers and the first
!             # part of the body if we can.
              subject = self.trimAndQuote(message["Subject"] or "(none)", 50)
              from_ = self.trimAndQuote(message["From"] or "(none)", 40)
+             try:
+                 part = typed_subpart_iterator(message, 'text', 'plain').next()
+                 text = part.get_payload()
+             except StopIteration:
+                 try:
+                     part = typed_subpart_iterator(message, 'text', 'html').next()
+                     text = tokenizer.html_re.sub(' ', part.get_payload())
+                     text = '(this message only has an HTML body)\n' + text
+                 except StopIteration:
+                     text = '(this message has no text body)'
+             text = text.replace('&nbsp;', ' ')      # Else they'll be quoted
+             text = re.sub(r'(\s)\s+', r'\1', text)  # Eg. multiple blank lines
+             text = self.trimAndQuote(text.strip(), 200, True)
  
              # Output the table row for this message.
***************
*** 931,934 ****
--- 961,965 ----
              elif judgement == options.header_unsure_string:
                  defer='checked'
+             subject = "<span title=\"%s\">%s</span>" % (text, subject)
              radioGroup = buttons % (key, key, defer, key, ham, key, spam)
              stripeClass = ['stripe_on', 'stripe_off'][stripe]

Index: Options.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/Options.py,v
retrieving revision 1.74
retrieving revision 1.75
diff -C2 -d -r1.74 -r1.75
*** Options.py	20 Nov 2002 12:28:15 -0000	1.74
--- Options.py	20 Nov 2002 22:41:50 -0000	1.75
***************
*** 361,366 ****
  # specify more than one server in pop3proxy_servers, you must specify the
  # same number of ports in pop3proxy_ports.
! pop3proxy_servers: ""
! pop3proxy_ports: ""
  pop3proxy_cache_use_gzip: False
  pop3proxy_cache_expiry_days: 7
--- 361,366 ----
  # specify more than one server in pop3proxy_servers, you must specify the
  # same number of ports in pop3proxy_ports.
! pop3proxy_servers:
! pop3proxy_ports:
  pop3proxy_cache_use_gzip: False
  pop3proxy_cache_expiry_days: 7
***************
*** 370,374 ****
  
  # Deprecated - use pop3proxy_servers and pop3proxy_ports instead.
! pop3proxy_server_name: ""
  pop3proxy_server_port: 110
  pop3proxy_port: 110
--- 370,374 ----
  
  # Deprecated - use pop3proxy_servers and pop3proxy_ports instead.
! pop3proxy_server_name:
  pop3proxy_server_port: 110
  pop3proxy_port: 110





More information about the Spambayes-checkins mailing list