[Zope3-checkins] CVS: Zope3/src/zope/fieldindex - fieldindex.py:1.9

Steve Alexander steve@cat-box.net
Tue, 3 Jun 2003 11:45:40 -0400


Update of /cvs-repository/Zope3/src/zope/fieldindex
In directory cvs.zope.org:/tmp/cvs-serv9102/src/zope/fieldindex

Modified Files:
	fieldindex.py 
Log Message:
Various formatting cleanup.
Use new implements() style.
replaced use of 0 and 1 with False and True.


=== Zope3/src/zope/fieldindex/fieldindex.py 1.8 => 1.9 ===
--- Zope3/src/zope/fieldindex/fieldindex.py:1.8	Thu May  1 15:35:42 2003
+++ Zope3/src/zope/fieldindex/fieldindex.py	Tue Jun  3 11:45:09 2003
@@ -22,17 +22,18 @@
 
 from zope.fieldindex.ifieldindex import IFieldIndex
 from types import ListType, TupleType
+from zope.interface import implements
 
 
 class FieldIndex(Persistent):
 
-    __implements__ = IFieldIndex
+    implements(IFieldIndex)
 
     def __init__(self):
         self.clear()
 
     def clear(self):
-        """ initialize forward and reverse mappings """
+        """Initialize forward and reverse mappings."""
         # The forward index maps indexed values to a sequence of docids
         self._fwd_index = OOBTree()
         # The reverse index maps a docid to its index value
@@ -54,42 +55,47 @@
     def unindex_doc(self, docid):
         try:      # ignore non-existing docids, don't raise
             value = self._rev_index[docid]
-        except KeyError: 
+        except KeyError:
             return
-        
+
         del self._rev_index[docid]
 
         try:
             self._fwd_index[value].remove(docid)
             if len(self._fwd_index[value]) == 0:
                 del self._fwd_index[value]
-        except KeyError: pass
+        except KeyError:
+            pass
 
     def search(self, values):
         # values can either be a single value or a sequence of
         # values to be searched.
-        if isinstance(values , (ListType, TupleType)):
+        if isinstance(values, (ListType, TupleType)):
             result = IISet()
             for value in values:
-                try: r = IISet(self._fwd_index[value])
-                except KeyError: continue
+                try:
+                    r = IISet(self._fwd_index[value])
+                except KeyError:
+                    continue
                 # the results of all subsearches are combined using OR
                 result = union(result, r)
         else:
-            try: result = IISet(self._fwd_index[values])
-            except KeyError: result = IISet()    
+            try:
+                result = IISet(self._fwd_index[values])
+            except KeyError:
+                result = IISet()
 
-        return result 
+        return result
 
     def rangesearch(self, minvalue, maxvalue):
         return IISet(self._fwd_index.keys(minvalue, maxvalue))
 
     def _insert_forward(self, docid, value):
-        """ insert into forward index """
+        """Insert into forward index."""
         if not self._fwd_index.has_key(value):
             self._fwd_index[value] = IITreeSet()
         self._fwd_index[value].insert(docid)
 
     def _insert_reverse(self, docid, value):
-        """ insert into reverse index """
+        """Insert into reverse index."""
         self._rev_index[docid] = value