[Zope-Checkins] CVS: Zope/lib/python/Products/PluginIndexes/common - PluggableIndex.py:1.7 ResultList.py:1.5 UnIndex.py:1.14 randid.py:1.5 util.py:1.10

Martijn Pieters mj@zope.com
Wed, 14 Aug 2002 18:19:36 -0400


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

Modified Files:
	PluggableIndex.py ResultList.py UnIndex.py randid.py util.py 
Log Message:
Clean up indentation and trailing whitespace.


=== Zope/lib/python/Products/PluginIndexes/common/PluggableIndex.py 1.6 => 1.7 ===
--- Zope/lib/python/Products/PluginIndexes/common/PluggableIndex.py:1.6	Tue Apr 30 00:33:52 2002
+++ Zope/lib/python/Products/PluginIndexes/common/PluggableIndex.py	Wed Aug 14 18:19:34 2002
@@ -1,14 +1,14 @@
 ##############################################################################
 #
 # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
-# 
+#
 # This software is subject to the provisions of the Zope Public License,
 # Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
 # FOR A PARTICULAR PURPOSE
-# 
+#
 ##############################################################################
 
 """Pluggable Index Base Class """
@@ -43,7 +43,7 @@
         If 'withLengths' is true, returns a sequence of tuples of
         (value, length).
         """
-        
+
     def _apply_index(request, cid=''):
         """Apply the index to query parameters given in 'request'.
 
@@ -67,4 +67,3 @@
         records.  The second object is a tuple containing the names of
         all data fields used.
         """
-


=== Zope/lib/python/Products/PluginIndexes/common/ResultList.py 1.4 => 1.5 ===
--- Zope/lib/python/Products/PluginIndexes/common/ResultList.py:1.4	Wed Nov 28 10:51:05 2001
+++ Zope/lib/python/Products/PluginIndexes/common/ResultList.py	Wed Aug 14 18:19:34 2002
@@ -1,14 +1,14 @@
 ##############################################################################
 #
 # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
-# 
+#
 # This software is subject to the provisions of the Zope Public License,
 # Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
 # FOR A PARTICULAR PURPOSE
-# 
+#
 ##############################################################################
 
 from BTrees.IIBTree import IIBucket
@@ -16,13 +16,13 @@
 from BTrees.OOBTree import OOSet, union
 
 class ResultList:
-  
+
     def __init__(self, d, words, index, TupleType=type(())):
         self._index = index
 
         if type(words) is not OOSet: words=OOSet(words)
         self._words = words
-        
+
         if (type(d) is TupleType):
             d = IIBucket((d,))
         elif type(d) is not IIBucket:
@@ -43,7 +43,7 @@
 
     def has_key(self, key): return self._dict.has_key(key)
 
-    def items(self): return self._dict.items()  
+    def items(self): return self._dict.items()
 
     def __and__(self, x):
         return self.__class__(
@@ -58,7 +58,7 @@
             self._words,
             self._index,
             )
-  
+
     def __or__(self, x):
         return self.__class__(
             weightedUnion(self._dict, x._dict)[1],
@@ -89,7 +89,6 @@
             if d==lp: score = min(score,xdict[id]) # synonyms
             else: score = (score+xdict[id])/d
             result[id] = score
-    
+
         return self.__class__(
             result, union(self._words, x._words), self._index)
-


=== Zope/lib/python/Products/PluginIndexes/common/UnIndex.py 1.13 => 1.14 ===
--- Zope/lib/python/Products/PluginIndexes/common/UnIndex.py:1.13	Thu Aug  1 12:00:40 2002
+++ Zope/lib/python/Products/PluginIndexes/common/UnIndex.py	Wed Aug 14 18:19:34 2002
@@ -1,14 +1,14 @@
 ##############################################################################
 #
 # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
-# 
+#
 # This software is subject to the provisions of the Zope Public License,
 # Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
 # FOR A PARTICULAR PURPOSE
-# 
+#
 ##############################################################################
 
 """Simple column indices"""
@@ -43,7 +43,7 @@
 
         UnIndexes are indexes that contain two index components, the
         forward index (like plain index objects) and an inverted
-        index.  The inverted index is so that objects can be unindexed 
+        index.  The inverted index is so that objects can be unindexed
         even when the old value of the object is not known.
 
         e.g.
@@ -64,7 +64,7 @@
           to ignore exceptions raised while indexing instead of
           propagating them.
 
-          'call_methods' -- should be set to true if you want the index 
+          'call_methods' -- should be set to true if you want the index
           to call the attribute 'id' (note: 'id' should be callable!)
           You will also need to pass in an object in the index and
           uninded methods for this to work.
@@ -76,14 +76,14 @@
         self.call_methods=call_methods
 
         # experimental code for specifing the operator
-        self.operators = ['or','and'] 
+        self.operators = ['or','and']
         self.useOperator = 'or'
 
         self.__len__=BTrees.Length.Length() # see __len__ method docstring
         self.clear()
 
     def getId(self): return self.id
-        
+
     def clear(self):
         # inplace opportunistic conversion from old-style to new style BTrees
         try: self.__len__.set(0)
@@ -98,7 +98,7 @@
 
         _index=self._index
         self._index=OOBTree()
-        
+
         def convertSet(s,
                        IITreeSet=IITreeSet, IntType=type(0),
                        type=type, len=len,
@@ -111,7 +111,7 @@
                 except: pass # This is just an optimization.
 
             return IITreeSet(s)
-    
+
         convert(_index, self._index, threshold, convertSet)
 
         _unindex=self._unindex
@@ -160,8 +160,8 @@
             return self._unindex.get(documentId)
         else:
             return self._unindex.get(documentId, default)
-            
-        
+
+
     def removeForwardIndexEntry(self, entry, documentId):
         """Take the entry provided and remove any reference to documentId
         in its entry in the index."""
@@ -178,7 +178,7 @@
                 # index row is an int
                 del self._index[entry]
                 try: self.__len__.change(-1)
-                except AttributeError: pass # pre-BTrees-module instance   
+                except AttributeError: pass # pre-BTrees-module instance
             except:
                 LOG(self.__class__.__name__, ERROR,
                     ('unindex_object could not remove '
@@ -192,7 +192,7 @@
                  'from index %s but couldn\'t.  This '
                  'should not happen.' % (repr(entry), str(self.id))))
 
-        
+
     def insertForwardIndexEntry(self, entry, documentId):
         """Take the entry provided and put it in the correct place
         in the forward index.
@@ -200,7 +200,7 @@
         This will also deal with creating the entire row if necessary."""
         global _marker
         indexRow = self._index.get(entry, _marker)
-        
+
         # Make sure there's actually a row there already.  If not, create
         # an IntSet and stuff it in first.
         if indexRow is _marker:
@@ -271,14 +271,14 @@
             return None
 
         self.removeForwardIndexEntry(unindexRecord, documentId)
-        
+
         try:
             del self._unindex[documentId]
         except:
             LOG('UnIndex', ERROR, 'Attempt to unindex nonexistent document'
                 ' with id %s' % documentId)
 
-    def _apply_index(self, request, cid='', type=type, None=None): 
+    def _apply_index(self, request, cid='', type=type, None=None):
         """Apply the index to query parameters given in the request arg.
 
         The request argument should be a mapping object.
@@ -302,7 +302,7 @@
         column + '_usage', it is sniffed for information on how to
         handle applying the index.
 
-        If the request contains a parameter with the name of the 
+        If the request contains a parameter with the name of the
         column = '_operator' this overrides the default method
         ('or') to combine search results. Valid values are "or"
         and "and".
@@ -331,7 +331,7 @@
         # experimental code for specifing the operator
         operator = record.get('operator',self.useOperator)
         if not operator in self.operators :
-           raise RuntimeError,"operator not valid: %s" % escape(operator)
+            raise RuntimeError,"operator not valid: %s" % escape(operator)
 
         # depending on the operator we use intersection or union
         if operator=="or":  set_func = union
@@ -404,7 +404,7 @@
 
         if not withLengths:
             return tuple(self._index.keys())
-        else: 
+        else:
             rl=[]
             for i in self._index.keys():
                 set = self._index[i]
@@ -425,4 +425,3 @@
                 v = IISet((v,))
             items.append((k, v))
         return items
-


=== Zope/lib/python/Products/PluginIndexes/common/randid.py 1.4 => 1.5 ===
--- Zope/lib/python/Products/PluginIndexes/common/randid.py:1.4	Thu Apr 25 13:40:43 2002
+++ Zope/lib/python/Products/PluginIndexes/common/randid.py	Wed Aug 14 18:19:34 2002
@@ -1,5 +1,5 @@
 ##############################################################################
-# 
+#
 # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
 #
 # This software is subject to the provisions of the Zope Public License,
@@ -8,7 +8,7 @@
 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
 # FOR A PARTICULAR PURPOSE
-# 
+#
 #############################################################################
 
 import random


=== Zope/lib/python/Products/PluginIndexes/common/util.py 1.9 => 1.10 ===
--- Zope/lib/python/Products/PluginIndexes/common/util.py:1.9	Fri Mar 29 10:33:03 2002
+++ Zope/lib/python/Products/PluginIndexes/common/util.py	Wed Aug 14 18:19:34 2002
@@ -1,5 +1,5 @@
 ##############################################################################
-# 
+#
 # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
 #
 # This software is subject to the provisions of the Zope Public License,
@@ -8,7 +8,7 @@
 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
 # FOR A PARTICULAR PURPOSE
-# 
+#
 #############################################################################
 
 __version__ = '$Id$'
@@ -32,10 +32,10 @@
       Additional parameters for an index could be passed as index+"_usage" ...
 
 
-    - dictionary-style parameters specify a query for an index as 
-      an entry in the request dictionary where the key corresponds to the 
+    - dictionary-style parameters specify a query for an index as
+      an entry in the request dictionary where the key corresponds to the
       name of the index and the key is a dictionary with the parameters
-      passed to the index. 
+      passed to the index.
 
       Allowed keys of the parameter dictionary:
 
@@ -50,7 +50,7 @@
      All restrictions of the dictionary-style parameters apply to the record-style
      parameters
 
-    """    
+    """
 
 
     ParserException = 'IndexRequestParseError'
@@ -61,7 +61,7 @@
 
           request -- the request dictionary send from the ZPublisher
           iid     -- Id of index
-          options -- a list of options the index is interested in 
+          options -- a list of options the index is interested in
         """
 
         self.id = iid
@@ -101,19 +101,19 @@
 
         elif t is DictType:
             """ query is a dictionary containing all parameters """
-    
+
             query = param.get("query", ())
             if type(query) in SequenceTypes:
                 keys = query
             else:
                 keys = [ query ]
 
-            for op in options:         
+            for op in options:
                 if op == "query": continue
 
                 if param.has_key(op):
                     setattr(self, op, param[op])
- 
+
         else:
             """ query is tuple, list, string, number, or something else """
 
@@ -134,7 +134,7 @@
 
 
     def get(self,k,default_v=None):
-        
+
         if hasattr(self,k):
             v = getattr(self,k)
             if v: return v