[Spambayes-checkins] SF.net SVN: spambayes:[3240] trunk/spambayes/spambayes/tokenizer.py

montanaro at users.sourceforge.net montanaro at users.sourceforge.net
Fri Feb 20 07:52:54 CET 2009


Revision: 3240
          http://spambayes.svn.sourceforge.net/spambayes/?rev=3240&view=rev
Author:   montanaro
Date:     2009-02-20 06:52:54 +0000 (Fri, 20 Feb 2009)

Log Message:
-----------
A different way of dealing with a missing cache which doesn't require later
code to test it against None.

Modified Paths:
--------------
    trunk/spambayes/spambayes/tokenizer.py

Modified: trunk/spambayes/spambayes/tokenizer.py
===================================================================
--- trunk/spambayes/spambayes/tokenizer.py	2009-02-20 06:51:36 UTC (rev 3239)
+++ trunk/spambayes/spambayes/tokenizer.py	2009-02-20 06:52:54 UTC (rev 3240)
@@ -25,7 +25,10 @@
     cache = dnscache.cache(cachefile=options["Tokenizer", "lookup_ip_cache"])
     cache.printStatsAtEnd = False
 except (IOError, ImportError):
-    cache = None
+    class cache:
+        @staticmethod
+        def lookup(*args):
+            return []
 else:
     import atexit
     atexit.register(cache.close)
@@ -1067,7 +1070,7 @@
             url = urllib.unquote(url)
             scheme, netloc, path, params, query, frag = urlparse.urlparse(url)
 
-            if cache is not None and options["Tokenizer", "x-lookup_ip"]:
+            if options["Tokenizer", "x-lookup_ip"]:
                 ips = cache.lookup(netloc)
                 if not ips:
                     pushclue("url-ip:lookup error")


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.


More information about the Spambayes-checkins mailing list