projects
/
zzz-pokedex.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
fe8bf85
)
Allow lookup() callers to pass in their own whoosh indices.
author
Eevee
<git@veekun.com>
Fri, 21 Aug 2009 00:36:31 +0000
(17:36 -0700)
committer
Eevee
<git@veekun.com>
Fri, 21 Aug 2009 00:36:31 +0000
(17:36 -0700)
pokedex/lookup.py
patch
|
blob
|
history
diff --git
a/pokedex/lookup.py
b/pokedex/lookup.py
index
37a50f3
..
f17caf7
100644
(file)
--- a/
pokedex/lookup.py
+++ b/
pokedex/lookup.py
@@
-129,7
+129,7
@@
def open_index(directory=None, session=None, recreate=False):
return index, speller
return index, speller
-def lookup(name, session=None, exact_only=False):
+def lookup(name, session=None,
indices=None,
exact_only=False):
"""Attempts to find some sort of object, given a database session and name.
Returns (objects, exact) where `objects` is a list of database objects, and
"""Attempts to find some sort of object, given a database session and name.
Returns (objects, exact) where `objects` is a list of database objects, and
@@
-150,6
+150,10
@@
def lookup(name, session=None, exact_only=False):
if this is not provided, a connection to the default database will be
attempted.
if this is not provided, a connection to the default database will be
attempted.
+ `indices`
+ Tuple of index, speller as returned from `open_index()`. Defaults to
+ a call to `open_index()`.
+
`exact_only`
If True, only exact matches are returned. If set to False (the
default), and the provided `name` doesn't match anything exactly,
`exact_only`
If True, only exact matches are returned. If set to False (the
default), and the provided `name` doesn't match anything exactly,
@@
-159,7
+163,10
@@
def lookup(name, session=None, exact_only=False):
if not session:
session = connect()
if not session:
session = connect()
- index, speller = open_index()
+ if indices:
+ index, speller = indices
+ else:
+ index, speller = open_index()
exact = True
exact = True