1
0
Fork 0
mirror of https://github.com/veekun/pokedex.git synced 2024-08-20 18:16:34 +00:00

Factor out logic for finding the default db/index.

Note: `if not x:` has changed to `if x is not None:`, changing the
semantics slightly.  Shouldn't be a big issue.
This commit is contained in:
a_magical_me 2010-05-13 10:33:07 -07:00
parent 5e52bef91a
commit ffc30bff8f
5 changed files with 74 additions and 58 deletions
pokedex

View file

@ -1,7 +1,6 @@
# encoding: utf8
from collections import namedtuple
import os, os.path
import pkg_resources
import random
import re
import shutil
@ -19,6 +18,7 @@ import whoosh.spelling
from pokedex.db import connect
import pokedex.db.tables as tables
from pokedex.roomaji import romanize
from pokedex.defaults import get_default_index_dir
__all__ = ['PokedexLookup']
@ -102,13 +102,10 @@ class PokedexLookup(object):
# By the time this returns, self.index, self.speller, and self.session
# must be set
# Defaults
if not directory:
directory = os.environ.get('POKEDEX_INDEX_DIR', None)
# If a directory was not given, use the default
if directory is None:
directory = get_default_index_dir()
if not directory:
directory = pkg_resources.resource_filename('pokedex',
'data/whoosh-index')
self.directory = directory
if session: