[Zope3-checkins] CVS: Zope3/src/zope/fieldindex - fieldindex.py:1.8.10.1
Grégoire Weber
zope@i-con.ch
Sun, 22 Jun 2003 10:24:12 -0400
Update of /cvs-repository/Zope3/src/zope/fieldindex
In directory cvs.zope.org:/tmp/cvs-serv24874/src/zope/fieldindex
Modified Files:
Tag: cw-mail-branch
fieldindex.py
Log Message:
Synced up with HEAD
=== Zope3/src/zope/fieldindex/fieldindex.py 1.8 => 1.8.10.1 ===
--- Zope3/src/zope/fieldindex/fieldindex.py:1.8 Thu May 1 15:35:42 2003
+++ Zope3/src/zope/fieldindex/fieldindex.py Sun Jun 22 10:23:41 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