def reload_bibles(self): """ Reloads the Bibles from the available Bible databases on disk. If a web Bible is encountered, an instance of HTTPBible is loaded instead of the BibleDB class. """ log.debug('Reload bibles') files = AppLocation.get_files(self.settings_section, self.suffix) if 'alternative_book_names.sqlite' in files: files.remove('alternative_book_names.sqlite') log.debug('Bible Files %s', files) self.db_cache = {} self.old_bible_databases = [] for filename in files: bible = BibleDB(self.parent, path=self.path, file=filename) if not bible.session: continue name = bible.get_name() # Remove corrupted files. if name is None: bible.session.close() delete_file(os.path.join(self.path, filename)) continue # Find old database versions. if bible.is_old_database(): self.old_bible_databases.append([filename, name]) bible.session.close() continue log.debug('Bible Name: "%s"', name) self.db_cache[name] = bible # Look to see if lazy load bible exists and get create getter. source = self.db_cache[name].get_object(BibleMeta, 'download_source') if source: download_name = self.db_cache[name].get_object( BibleMeta, 'download_name').value meta_proxy = self.db_cache[name].get_object( BibleMeta, 'proxy_server') web_bible = HTTPBible(self.parent, path=self.path, file=filename, download_source=source.value, download_name=download_name) if meta_proxy: web_bible.proxy_server = meta_proxy.value self.db_cache[name] = web_bible log.debug('Bibles reloaded')
def reload_bibles(self): """ Reloads the Bibles from the available Bible databases on disk. If a web Bible is encountered, an instance of HTTPBible is loaded instead of the BibleDB class. """ log.debug('Reload bibles') files = AppLocation.get_files(self.settings_section, self.suffix) if 'alternative_book_names.sqlite' in files: files.remove('alternative_book_names.sqlite') log.debug('Bible Files %s', files) self.db_cache = {} self.old_bible_databases = [] for filename in files: bible = BibleDB(self.parent, path=self.path, file=filename) if not bible.session: continue name = bible.get_name() # Remove corrupted files. if name is None: bible.session.close() delete_file(os.path.join(self.path, filename)) continue # Find old database versions. if bible.is_old_database(): self.old_bible_databases.append([filename, name]) bible.session.close() continue log.debug('Bible Name: "%s"', name) self.db_cache[name] = bible # Look to see if lazy load bible exists and get create getter. source = self.db_cache[name].get_object(BibleMeta, 'download_source') if source: download_name = self.db_cache[name].get_object(BibleMeta, 'download_name').value meta_proxy = self.db_cache[name].get_object(BibleMeta, 'proxy_server') web_bible = HTTPBible(self.parent, path=self.path, file=filename, download_source=source.value, download_name=download_name) if meta_proxy: web_bible.proxy_server = meta_proxy.value self.db_cache[name] = web_bible log.debug('Bibles reloaded')
def reload_bibles(self): """ Reloads the Bibles from the available Bible databases on disk. If a web Bible is encountered, an instance of HTTPBible is loaded instead of the BibleDB class. """ log.debug('Reload bibles') file_paths = AppLocation.get_files(self.settings_section, self.suffix) if Path('alternative_book_names.sqlite') in file_paths: file_paths.remove(Path('alternative_book_names.sqlite')) log.debug('Bible Files {text}'.format(text=file_paths)) self.db_cache = {} for file_path in file_paths: bible = BibleDB(self.parent, path=self.path, file=file_path) if not bible.session: continue name = bible.get_name() # Remove corrupted files. if name is None: bible.session.close_all() delete_file(self.path / file_path) continue log.debug('Bible Name: "{name}"'.format(name=name)) self.db_cache[name] = bible # Look to see if lazy load bible exists and get create getter. if self.db_cache[name].is_web_bible: source = self.db_cache[name].get_object( BibleMeta, 'download_source') download_name = self.db_cache[name].get_object( BibleMeta, 'download_name').value meta_proxy = self.db_cache[name].get_object( BibleMeta, 'proxy_server') web_bible = HTTPBible(self.parent, path=self.path, file=file_path, download_source=source.value, download_name=download_name) if meta_proxy: web_bible.proxy_server = meta_proxy.value self.db_cache[name] = web_bible log.debug('Bibles reloaded')