From 08ef4d46aedb54e3423dd5541113299a16fc8303 Mon Sep 17 00:00:00 2001 From: Samuel Howard Date: Thu, 7 Mar 2024 16:02:48 -0600 Subject: [PATCH] In theory, this fixes index loading --- src/multi_bible_search/bible_search.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/multi_bible_search/bible_search.py b/src/multi_bible_search/bible_search.py index 71ddd07..779933f 100644 --- a/src/multi_bible_search/bible_search.py +++ b/src/multi_bible_search/bible_search.py @@ -2,17 +2,16 @@ import bz2 from collections import Counter import json +import os from typing import List class BibleSearch(object): def __init__(self, debug=False): - try: - with bz2.open("src/multi_bible_search/bible_index.json.pbz2", "rt", encoding='utf-8')as data_file: - self.__search_index = json.load(data_file) - except FileNotFoundError: - with bz2.open("../src/multi_bible_search/bible_index.json.pbz2", "rt", encoding='utf-8') as data_file: - self.__search_index = json.load(data_file) + base_path = os.path.dirname(os.path.abspath(__file__)) + + with bz2.open(f"{base_path}/bible_index.json.pbz2", "rt", encoding='utf-8')as data_file: + self.__search_index = json.load(data_file) if debug: print("Search index loaded")