Commit 2911792b authored by Michel Pelletier's avatar Michel Pelletier

Coverted Amos's bogus DOS file to a sane format...hmm.. smells like

Notepad? :)
parent 59d506e2
from UnIndex import UnIndex, MV, intSet from UnIndex import UnIndex, MV, intSet
from types import ListType, TupleType from types import ListType, TupleType
class UnKeywordIndex(UnIndex): class UnKeywordIndex(UnIndex):
""" """
Like an UnIndex only it indexs sequences of items Like an UnIndex only it indexs sequences of items
Searches match any keyword. Searches match any keyword.
""" """
def index_object(self, i, obj, threshold=None): def index_object(self, i, obj, threshold=None):
""" index an object 'obj' with integer id 'i'""" """ index an object 'obj' with integer id 'i'"""
index = self._index index = self._index
unindex = self._unindex unindex = self._unindex
id = self.id id = self.id
try: try:
kws=getattr(obj, id) kws=getattr(obj, id)
if callable(kws): if callable(kws):
kws = kws() kws = kws()
except: except:
kws = [MV] kws = [MV]
# index each item in the sequence # index each item in the sequence
for kw in kws: for kw in kws:
set = index.get(kw) set = index.get(kw)
if set is None: if set is None:
index[kw] = set = intSet() index[kw] = set = intSet()
set.insert(i) set.insert(i)
unindex[i] = kws unindex[i] = kws
self._index = index self._index = index
self._unindex = unindex self._unindex = unindex
return 1 return 1
def unindex_object(self, i): def unindex_object(self, i):
""" Unindex the object with integer id 'i' """ """ Unindex the object with integer id 'i' """
index = self._index index = self._index
unindex = self._unindex unindex = self._unindex
kws = unindex[i] kws = unindex[i]
if kws is None: if kws is None:
return None return None
for kw in kws: for kw in kws:
set = index.get(kw) set = index.get(kw)
if set is not None: set.remove(i) if set is not None: set.remove(i)
del unindex[i] del unindex[i]
self._index = index self._index = index
self._unindex = unindex self._unindex = unindex
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment