Skip to content

Commit 311227d

Browse files
author
Johannes Gijsbers
committed
Update metakit indexer:
* Derive from indexer_common instead of indexer_dbm. * Use is_stopword instead of self.disallows. * Return a list of nodeids from find() instead of a dictionary.
1 parent f1da502 commit 311227d

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

roundup/backends/back_metakit.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: back_metakit.py,v 1.88 2004-10-24 10:44:49 a1s Exp $
1+
# $Id: back_metakit.py,v 1.89 2005-01-09 19:01:09 jlgijsbers Exp $
22
'''Metakit backend for Roundup, originally by Gordon McMillan.
33
44
Known Current Bugs:
@@ -45,7 +45,7 @@
4545
import metakit
4646
from sessions_dbm import Sessions, OneTimeKeys
4747
import re, marshal, os, sys, time, calendar, shutil
48-
from indexer_dbm import Indexer
48+
from indexer_common import Indexer, is_stopword
4949
import locking
5050
from roundup.date import Range
5151
from blobfiles import files_in_dir
@@ -2001,7 +2001,6 @@ def __init__(self, db, classname, **properties):
20012001
CURVERSION = 2
20022002

20032003
class Indexer(Indexer):
2004-
disallows = {'THE':1, 'THIS':1, 'ZZZ':1, 'THAT':1, 'WITH':1}
20052004
def __init__(self, path, datadb):
20062005
self.path = os.path.join(path, 'index.mk4')
20072006
self.db = metakit.storage(self.path, 1)
@@ -2078,7 +2077,7 @@ def add_text(self, identifier, text, mime_type='text/plain'):
20782077
wordlist = re.findall(r'\b\w{2,25}\b', text.upper())
20792078
words = {}
20802079
for word in wordlist:
2081-
if not self.disallows.has_key(word):
2080+
if not is_stopword(word):
20822081
words[word] = 1
20832082
words = words.keys()
20842083

@@ -2112,8 +2111,8 @@ def find(self, wordlist):
21122111
if len(hits) == 0:
21132112
return {}
21142113
if hits is None:
2115-
return {}
2116-
rslt = {}
2114+
return []
2115+
rslt = []
21172116
ids = self.db.view('ids').remapwith(hits)
21182117
tbls = self.datadb.view('tables')
21192118
for i in range(len(ids)):
@@ -2122,7 +2121,7 @@ def find(self, wordlist):
21222121
classname = tbls[hit.tblid].name
21232122
nodeid = str(hit.nodeid)
21242123
property = self._getpropname(classname, hit.propid)
2125-
rslt[i] = (classname, nodeid, property)
2124+
rslt.append((classname, nodeid, property))
21262125
return rslt
21272126

21282127
def save_index(self):

0 commit comments

Comments
 (0)