Make pokedex work with SQLAlchemy 0.7. Warning: ugly hack!
[zzz-pokedex.git] / pokedex / defaults.py
1 """ pokedex.defaults - logic for finding default paths """
2
3 import os
4
5 def get_default_db_uri_with_origin():
6 uri = os.environ.get('POKEDEX_DB_ENGINE', None)
7 origin = 'environment'
8
9 if uri is None:
10 import pkg_resources
11 sqlite_path = pkg_resources.resource_filename('pokedex',
12 'data/pokedex.sqlite')
13 uri = 'sqlite:///' + sqlite_path
14 origin = 'default'
15
16 return uri, origin
17
18 def get_default_index_dir_with_origin():
19 index_dir = os.environ.get('POKEDEX_INDEX_DIR', None)
20 origin = 'environment'
21
22 if index_dir is None:
23 import pkg_resources
24 index_dir = pkg_resources.resource_filename('pokedex',
25 'data/whoosh-index')
26 origin = 'default'
27
28 return index_dir, origin
29
30 def get_default_csv_dir_with_origin():
31 import pkg_resources
32 csv_dir = pkg_resources.resource_filename('pokedex', 'data/csv')
33 origin = 'default'
34
35 return csv_dir, origin
36
37
38 def get_default_db_uri():
39 return get_default_db_uri_with_origin()[0]
40
41 def get_default_index_dir():
42 return get_default_index_dir_with_origin()[0]
43
44 def get_default_csv_dir():
45 return get_default_csv_dir_with_origin()[0]
46
47