[Spambayes-checkins] spambayes/spambayes Dibbler.py, 1.13.4.2, 1.13.4.3

Tony Meyer anadelonbrin at users.sourceforge.net
Wed Dec 22 04:34:58 CET 2004


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

Modified Files:
      Tag: release_1_0-branch
	Dibbler.py 
Log Message:
Backport 2.2.1 compatibility.

Index: Dibbler.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/spambayes/Dibbler.py,v
retrieving revision 1.13.4.2
retrieving revision 1.13.4.3
diff -C2 -d -r1.13.4.2 -r1.13.4.3
*** Dibbler.py	20 Dec 2004 03:53:55 -0000	1.13.4.2
--- Dibbler.py	22 Dec 2004 03:34:55 -0000	1.13.4.3
***************
*** 179,182 ****
--- 179,191 ----
      True, False = 1, 0
  
+ try:
+     "".rstrip("abc")
+ except TypeError:
+     # rstrip(chars) requires Python 2.2.2 or higher.  Apart from that
+     # we probably work with Python 2.2 (and say we do), so provide the
+     # ability to do this for that case.
+     RSTRIP_CHARS_AVAILABLE = False
+ else:
+     RSTRIP_CHARS_AVAILABLE = True
  
  class BrighterAsyncChat(asynchat.async_chat):
***************
*** 594,598 ****
          minutes from now."""
          timeString = time.asctime(time.localtime(time.time() + 20*60))
!         return base64.encodestring(timeString).rstrip('\n=')
  
      def _isValidNonce(self, nonce):
--- 603,618 ----
          minutes from now."""
          timeString = time.asctime(time.localtime(time.time() + 20*60))
!         if RSTRIP_CHARS_AVAILABLE:
!             return base64.encodestring(timeString).rstrip('\n=')
!         else:
!             # Python pre 2.2.2, so can't do a rstrip(chars).  Do it
!             # manually instead.
!             def rstrip(s, chars):
!                 if not s:
!                     return s
!                 if s[-1] in chars:
!                     return rstrip(s[:-1])
!                 return s
!             return rstrip(base64.encodestring(timeString), '\n=')
  
      def _isValidNonce(self, nonce):



More information about the Spambayes-checkins mailing list