[Zope-Checkins] CVS: Zope/lib/python/Products/PluginIndexes/TextIndexNG - TextIndexNG.py:1.2.2.24

Andreas Jung andreas@digicool.com
Wed, 6 Feb 2002 10:41:07 -0500


Update of /cvs-repository/Zope/lib/python/Products/PluginIndexes/TextIndexNG
In directory cvs.zope.org:/tmp/cvs-serv9666

Modified Files:
      Tag: ajung-textindexng-branch
	TextIndexNG.py 
Log Message:
added optional parameters to constructor to enable verbose mode
and timed statistics


=== Zope/lib/python/Products/PluginIndexes/TextIndexNG/TextIndexNG.py 1.2.2.23 => 1.2.2.24 ===
 import Stemmer, Proximity
 import Thesaurus, StopWords, Normalizer
+import TextIndexCommon
 import time
 
 
 class Timer:
 
-    def __init__(self):
+    def __init__(self, verbose=1):
         self.ts = time.time()
+        self.verbose = verbose
 
     def __call__(self,s):
         diff = time.time() - self.ts
         self.ts = time.time()
-        print "%s: %5.5lf" % (s,  diff)
+
+        if self.verbose:
+            print "%s: %5.5lf" % (s,  diff)
   
 
 
@@ -95,6 +99,8 @@
                  , id 
                  , extra= None
                  , caller = None
+                 , verbose = 0
+                 , timed_statistics = 0
                 ):
 
         self.id            = id
@@ -159,6 +165,12 @@
             raise ValueError,'nearSearch must be either None, "internal"'\
                              ' or "documentLookup"'
 
+        
+        if verbose: TextIndexCommon.debug_on()
+        else:       TextIndexCommon.debug_off()
+
+        self.timed_statistics  = timed_statistics 
+
         self.clear()
                         
 
@@ -376,7 +388,7 @@
     def index_object(self, documentId, obj, threshold=None):
 
 
-        T = Timer()
+        T = Timer(self.timed_statistics)
 
         try:
             source = getattr(obj, self.id)