From c96407e6363db66ce91c2931a0dd84bf52f716d7 Mon Sep 17 00:00:00 2001 From: Eevee Date: Mon, 1 Feb 2010 23:05:30 -0800 Subject: [PATCH] Give Pokedex plugin its own whoosh index. --- plugins/Pokedex/README.txt | 8 ++++++-- plugins/Pokedex/plugin.py | 8 +++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/plugins/Pokedex/README.txt b/plugins/Pokedex/README.txt index 84a64f3..8d733dd 100644 --- a/plugins/Pokedex/README.txt +++ b/plugins/Pokedex/README.txt @@ -1,6 +1,10 @@ This plugin provides simple Pokédex lookups. -You must install the pokedex module, run 'pokedex setup', and provide the paths -to the resulting SQLite and Whoosh files. +You must install the pokedex module, run 'pokedex setup', and provide the path +to the resulting database. + +The plugin will create a full-text lookup index when it's first loaded, in a +directory called 'pokedex-index' inside the data directory. This may take a +few moments. pokedex can be found here: http://git.veekun.com/?p=pokedex.git;a=summary diff --git a/plugins/Pokedex/plugin.py b/plugins/Pokedex/plugin.py index 77de7d9..84e9cf9 100644 --- a/plugins/Pokedex/plugin.py +++ b/plugins/Pokedex/plugin.py @@ -29,6 +29,7 @@ ### +import supybot.conf as conf import supybot.utils as utils from supybot.commands import * import supybot.plugins as plugins @@ -46,6 +47,10 @@ class Pokedex(callbacks.Plugin): self.__parent = super(Pokedex, self) self.__parent.__init__(irc) self.db = pokedex.db.connect(self.registryValue('databaseURL')) + self.indices = pokedex.lookup.open_index( + directory=conf.supybot.directories.data.dirize('pokedex-index'), + session=self.db, + ) def pokedex(self, irc, msg, args, thing): """ @@ -53,7 +58,8 @@ class Pokedex(callbacks.Plugin): Looks up in the veekun Pokédex.""" # Similar logic to the site, here. - results = pokedex.lookup.lookup(thing, session=self.db) + results = pokedex.lookup.lookup(thing, session=self.db, + indices=self.indices) # Nothing found if len(results) == 0: -- 2.7.4