From 44216e6a6a5052e7b4ce0abff60826ce45409493 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 24 Jan 2009 08:06:36 +0000 Subject: [PATCH] Update bible register dialog - Register only 1 bible Register HTTP Get HTTP verse selection working (part 1) More Orm migrations. bzr-revno: 290 --- openlp/plugins/bibles/bibleplugin.py | 11 +- .../plugins/bibles/forms/bibleimportdialog.py | 28 +-- .../plugins/bibles/forms/bibleimportform.py | 186 +++++++++++++----- openlp/plugins/bibles/lib/bibleDBimpl.py | 39 ++-- openlp/plugins/bibles/lib/bibleHTTPimpl.py | 2 +- openlp/plugins/bibles/lib/common.py | 4 +- openlp/plugins/bibles/lib/manager.py | 33 ++-- resources/forms/bibleimportdialog.ui | 8 +- 8 files changed, 204 insertions(+), 107 deletions(-) diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index 972b2e63d..49c4002b0 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -226,15 +226,12 @@ class BiblePlugin(Plugin, PluginUtils): def onAdvancedVersionComboBox(self): self._initialise_bible_advanced(str(self.AdvancedVersionComboBox.currentText())) # restet the bible info + pass def onAdvancedBookComboBox(self): - print self.AdvancedVersionComboBox.currentText() self._initialise_bible_advanced(str(self.AdvancedVersionComboBox.currentText())) # restet the bible info def onQuickTabClick(self): - print "onQuickTabClick" - print self.SearchTabWidget.currentIndex() - print self.SearchTabWidget.tabText(self.SearchTabWidget.currentIndex()) pass def onBibleNewClick(self): @@ -253,6 +250,10 @@ class BiblePlugin(Plugin, PluginUtils): pass def _initialise_form(self): + log.debug("_initialise_form") + self.QuickSearchComboBox.clear() + self.QuickVersionComboBox.clear() + self.AdvancedVersionComboBox.clear() bibles = self.biblemanager.get_bibles("full") self.QuickSearchComboBox.addItem("Text Search") self.QuickSearchComboBox.addItem("Verse Search") @@ -378,7 +379,7 @@ class BiblePlugin(Plugin, PluginUtils): #print "from =" + str(v) print "to =" self.searchresults = self.biblemanager.get_verse_text(bible, book,int(chapters[0]), int(chapters[1]), 1, 99) - self._display_results() + self._display_results(bible) def _split_chapters(self, text): txt = text.split("-") # split in to parts diff --git a/openlp/plugins/bibles/forms/bibleimportdialog.py b/openlp/plugins/bibles/forms/bibleimportdialog.py index 8af899b1d..42a377526 100644 --- a/openlp/plugins/bibles/forms/bibleimportdialog.py +++ b/openlp/plugins/bibles/forms/bibleimportdialog.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- -# Form implementation generated from reading ui file 'bibleimport.ui' +# Form implementation generated from reading ui file 'bibleimportdialog.ui' # -# Created: Mon Dec 15 18:34:25 2008 -# by: PyQt4 UI code generator 4.4.3 +# Created: Sat Jan 24 07:46:38 2009 +# by: PyQt4 UI code generator 4.4.4 # # WARNING! All changes made in this file will be lost! @@ -13,6 +13,9 @@ class Ui_BibleImportDialog(object): def setupUi(self, BibleImportDialog): BibleImportDialog.setObjectName("BibleImportDialog") BibleImportDialog.resize(494, 725) + icon = QtGui.QIcon() + icon.addPixmap(QtGui.QPixmap(":/icon/openlp.org-icon-32.bmp"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + BibleImportDialog.setWindowIcon(icon) self.BibleImportButtonBox = QtGui.QDialogButtonBox(BibleImportDialog) self.BibleImportButtonBox.setGeometry(QtCore.QRect(10, 690, 481, 33)) self.BibleImportButtonBox.setOrientation(QtCore.Qt.Horizontal) @@ -22,7 +25,7 @@ class Ui_BibleImportDialog(object): self.ImportToolBox.setGeometry(QtCore.QRect(10, 0, 471, 431)) self.ImportToolBox.setObjectName("ImportToolBox") self.FileImportPage = QtGui.QWidget() - self.FileImportPage.setGeometry(QtCore.QRect(0, 0, 461, 361)) + self.FileImportPage.setGeometry(QtCore.QRect(0, 0, 96, 26)) self.FileImportPage.setObjectName("FileImportPage") self.OSISGroupBox = QtGui.QGroupBox(self.FileImportPage) self.OSISGroupBox.setGeometry(QtCore.QRect(8, 65, 451, 81)) @@ -38,9 +41,9 @@ class Ui_BibleImportDialog(object): self.OSISLocationEdit.setObjectName("OSISLocationEdit") self.gridLayout_2.addWidget(self.OSISLocationEdit, 0, 1, 1, 1) self.OsisFileButton = QtGui.QPushButton(self.OSISGroupBox) - icon = QtGui.QIcon() - icon.addPixmap(QtGui.QPixmap("../images/import_load.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.OsisFileButton.setIcon(icon) + icon1 = QtGui.QIcon() + icon1.addPixmap(QtGui.QPixmap(":/imports/import_load.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.OsisFileButton.setIcon(icon1) self.OsisFileButton.setObjectName("OsisFileButton") self.gridLayout_2.addWidget(self.OsisFileButton, 0, 2, 1, 1) self.CVSGroupBox = QtGui.QGroupBox(self.FileImportPage) @@ -63,11 +66,11 @@ class Ui_BibleImportDialog(object): self.BooksLocationEdit.setObjectName("BooksLocationEdit") self.gridLayout.addWidget(self.BooksLocationEdit, 0, 1, 1, 1) self.BooksFileButton = QtGui.QPushButton(self.CVSGroupBox) - self.BooksFileButton.setIcon(icon) + self.BooksFileButton.setIcon(icon1) self.BooksFileButton.setObjectName("BooksFileButton") self.gridLayout.addWidget(self.BooksFileButton, 0, 2, 1, 1) self.VersesFileButton = QtGui.QPushButton(self.CVSGroupBox) - self.VersesFileButton.setIcon(icon) + self.VersesFileButton.setIcon(icon1) self.VersesFileButton.setObjectName("VersesFileButton") self.gridLayout.addWidget(self.VersesFileButton, 4, 2, 1, 1) self.BibleNameEdit = QtGui.QLineEdit(self.FileImportPage) @@ -78,7 +81,7 @@ class Ui_BibleImportDialog(object): self.BibleNameLabel.setObjectName("BibleNameLabel") self.ImportToolBox.addItem(self.FileImportPage, "") self.WebBiblePage = QtGui.QWidget() - self.WebBiblePage.setGeometry(QtCore.QRect(0, 0, 461, 361)) + self.WebBiblePage.setGeometry(QtCore.QRect(0, 0, 471, 371)) self.WebBiblePage.setObjectName("WebBiblePage") self.WebBibleLayout = QtGui.QVBoxLayout(self.WebBiblePage) self.WebBibleLayout.setSpacing(8) @@ -190,7 +193,7 @@ class Ui_BibleImportDialog(object): self.gridLayout_3.addWidget(self.ProgressBar, 0, 0, 1, 1) self.retranslateUi(BibleImportDialog) - self.ImportToolBox.setCurrentIndex(0) + self.ImportToolBox.setCurrentIndex(1) QtCore.QMetaObject.connectSlotsByName(BibleImportDialog) BibleImportDialog.setTabOrder(self.BibleNameEdit, self.OSISLocationEdit) BibleImportDialog.setTabOrder(self.OSISLocationEdit, self.OsisFileButton) @@ -220,7 +223,7 @@ class Ui_BibleImportDialog(object): self.ImportToolBox.setItemText(self.ImportToolBox.indexOf(self.FileImportPage), QtGui.QApplication.translate("BibleImportDialog", "File Import Page", None, QtGui.QApplication.UnicodeUTF8)) self.OptionsGroupBox.setTitle(QtGui.QApplication.translate("BibleImportDialog", "Download Options", None, QtGui.QApplication.UnicodeUTF8)) self.LocationLabel.setText(QtGui.QApplication.translate("BibleImportDialog", "Location:", None, QtGui.QApplication.UnicodeUTF8)) - self.LocationComboBox.setItemText(1, QtGui.QApplication.translate("BibleImportDialog", "CrossWire", None, QtGui.QApplication.UnicodeUTF8)) + self.LocationComboBox.setItemText(1, QtGui.QApplication.translate("BibleImportDialog", "Crosswalk", None, QtGui.QApplication.UnicodeUTF8)) self.TypeLabel.setText(QtGui.QApplication.translate("BibleImportDialog", "Type:", None, QtGui.QApplication.UnicodeUTF8)) self.TypeComboBox.setItemText(1, QtGui.QApplication.translate("BibleImportDialog", "Download As Needed", None, QtGui.QApplication.UnicodeUTF8)) self.BibleLabel.setText(QtGui.QApplication.translate("BibleImportDialog", "Bible:", None, QtGui.QApplication.UnicodeUTF8)) @@ -237,4 +240,3 @@ class Ui_BibleImportDialog(object): self.PermisionLabel.setText(QtGui.QApplication.translate("BibleImportDialog", "Permission:", None, QtGui.QApplication.UnicodeUTF8)) self.ProgressGroupBox.setTitle(QtGui.QApplication.translate("BibleImportDialog", "Import Progress", None, QtGui.QApplication.UnicodeUTF8)) self.ProgressBar.setFormat(QtGui.QApplication.translate("BibleImportDialog", "%p", None, QtGui.QApplication.UnicodeUTF8)) - diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index 390bcb154..56525af6a 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -7,6 +7,7 @@ import sys import os, os.path import sys import time +import logging from openlp.core.resources import * @@ -18,6 +19,9 @@ from bibleimportdialog import Ui_BibleImportDialog from openlp.core.lib import PluginUtils class BibleImportForm(QDialog, Ui_BibleImportDialog, PluginUtils): + global log + log=logging.getLogger("BibleImportForm") + log.info("BibleImportForm loaded") """ Class documentation goes here. """ @@ -29,71 +33,105 @@ class BibleImportForm(QDialog, Ui_BibleImportDialog, PluginUtils): self.setupUi(self) self.biblemanager = biblemanager self.config = config + self.bibletype = None + self.barmax = 0 + QtCore.QObject.connect(self.LocationComboBox, QtCore.SIGNAL("activated(int)"), self.onLocationComboBox) + QtCore.QObject.connect(self.TypeComboBox, QtCore.SIGNAL("activated(int)"), self.onTypeComboBox) + QtCore.QObject.connect(self.BibleComboBox, QtCore.SIGNAL("activated(int)"), self.onBibleComboBox) + @pyqtSignature("") def on_VersesFileButton_clicked(self): filename = QtGui.QFileDialog.getOpenFileName(self, 'Open file',self._get_last_dir()) self.VerseLocationEdit.setText(filename) self._save_last_directory(filename) + self.setCSV() @pyqtSignature("") def on_BooksFileButton_clicked(self): filename = QtGui.QFileDialog.getOpenFileName(self, 'Open file',self._get_last_dir()) self.BooksLocationEdit.setText(filename) - self._save_last_directory(filename) + self._save_last_directory(filename) + self.setCSV() @pyqtSignature("") def on_OsisFileButton_clicked(self): filename = QtGui.QFileDialog.getOpenFileName(self, 'Open file',self._get_last_dir()) self.OSISLocationEdit.setText(filename) - self._save_last_directory(filename) - + self._save_last_directory(filename) + self.setOSIS() + def on_OSISLocationEdit_lostFocus(self): - if len(self.OSISLocationEdit.displayText() ) > 1: - self.BooksLocationEdit.setReadOnly(True) - self.VerseLocationEdit.setReadOnly(True) + if len(self.OSISLocationEdit.displayText() ) > 0: + self.setOSIS() else: - self.BooksLocationEdit.setReadOnly(False) - self.VerseLocationEdit.setReadOnly(False) - + if self.bibletype == "OSIS": # Was OSIS and is not any more stops lostFocus running mad + self.bibletype = None + self.freeAll() + def on_BooksLocationEdit_lostFocus(self): - if len(self.BooksLocationEdit.displayText()) > 1 or len(self.VerseLocationEdit.displayText()) > 1: - self.OSISLocationEdit.setReadOnly(True) - else: - self.OSISLocationEdit.setReadOnly(False) - + self._checkcsv() + def on_VerseLocationEdit_lostFocus(self): - if len(self.BooksLocationEdit.displayText()) > 1 or len(self.VerseLocationEdit.displayText()) > 1: - self.OSISLocationEdit.setReadOnly(True) + self._checkcsv() + + def _checkcsv(self): + if len(self.BooksLocationEdit.displayText()) > 0 or len(self.VerseLocationEdit.displayText()) > 0: + self.setCSV() else: - self.OSISLocationEdit.setReadOnly(False) - + if self.bibletype == "CVS": # Was CSV and is not any more stops lostFocus running mad + self.bibletype = None + self.freeAll() + + def onLocationComboBox(self): + self._checkhttp() + + def onTypeComboBox(self): + self._checkhttp() + + def onBibleComboBox(self): + self._checkhttp() + + def _checkhttp(self): + if len(self.LocationComboBox.currentText()) > 0 or \ + len(self.TypeComboBox.currentText()) > 0 or \ + len(self.BibleComboBox.currentText()) >0 : + self.setHTTP() + else: + if self.bibletype == "HTTP": # Was HTTP and is not any more stops lostFocus running mad + self.bibletype = None + self.freeAll() + def on_CopyrightEdit_lostFocus(self): - self.validate() + A =1 def on_VersionNameEdit_lostFocus(self): - self.validate() + A =1 def on_PermisionEdit_lostFocus(self): - self.validate() + A =1 def on_BibleNameEdit_lostFocus(self): - self.validate() + A =1 def on_BibleImportButtonBox_clicked(self,button): + log.debug("BibleImportButtonBox %s , %s", button.text() , self.bibletype) if button.text() == "Save": if self.biblemanager != None: - self.MessageLabel.setText("Import Started") - self.ProgressBar.setValue(1) - self.progress = 0 - self.biblemanager.process_dialog(self) - self.biblemanager.register_osis_file_bible(str(self.BibleNameEdit.displayText()), self.OSISLocationEdit.displayText()) - self.biblemanager.save_meta_data(str(self.BibleNameEdit.displayText()), str(self.VersionNameEdit.displayText()), str(self.CopyrightEdit.displayText()), str(self.PermisionEdit.displayText())) - self.MessageLabel.setText("Import Complete") + if not self.bibletype == None: + self.MessageLabel.setText("Import Started") + self.ProgressBar.setValue(1) + self.progress = 0 + self.biblemanager.process_dialog(self) + self._import_bible() + self.MessageLabel.setText("Import Complete") + self.ProgressBar.setValue(self.barmax) + self.update() elif button.text() == "Cancel": self.close() def setMax(self, max): + self.barmax = max self.ProgressBar.setMaximum(max) def incrementBar(self, text = None): @@ -104,21 +142,77 @@ class BibleImportForm(QDialog, Ui_BibleImportDialog, PluginUtils): self.progress +=1 self.ProgressBar.setValue(self.progress) self.update() + + def _import_bible(self): + if self.bibletype == "OSIS": + self.biblemanager.register_osis_file_bible(str(self.BibleNameEdit.displayText()), self.OSISLocationEdit.displayText()) + elif self.bibletype == "CSV": + self.biblemanager.register_csv_file_bible(str(self.BibleNameEdit.displayText()), self.OSISLocationEdit.displayText()) + else: + self.setMax(1) # set a value as it will not be needed + bname = self.biblemanager.register_http_bible(str(self.BibleComboBox.currentText()),str(self.LocationComboBox.currentText()) ) + self.BibleNameEdit.setText(bname) + + self.biblemanager.save_meta_data(str(self.BibleNameEdit.displayText()), str(self.VersionNameEdit.displayText()), str(self.CopyrightEdit.displayText()), str(self.PermisionEdit.displayText())) + self.bibletype = None + self.freeAll() # free the scree state restrictions + self.resetAll() # reset all the screen fields + + def blockCSV(self): + self.BooksLocationEdit.setReadOnly(True) + self.VerseLocationEdit.setReadOnly(True) + self.BooksFileButton.setEnabled(False) + self.VersesFileButton.setEnabled(False) + + def setCSV(self): + self.bibletype = "CVS" + self.BooksLocationEdit.setReadOnly(False) + self.VerseLocationEdit.setReadOnly(False) + self.BooksFileButton.setEnabled(True) + self.VersesFileButton.setEnabled(True) + self.blockOSIS() + self.blockHTTP() + + def setOSIS(self): + self.bibletype = "OSIS" + self.OSISLocationEdit.setReadOnly(False) + self.OsisFileButton.setEnabled(True) + self.blockCSV() + self.blockHTTP() + + def blockOSIS(self): + self.OSISLocationEdit.setReadOnly(True) + self.OsisFileButton.setEnabled(False) + + def setHTTP(self): + self.bibletype = "HTTP" + self.LocationComboBox.setEnabled(True) + self.BibleComboBox.setEnabled(True) + self.TypeComboBox.setEnabled(True) + self.blockCSV() + self.blockOSIS() + + def blockHTTP(self): + self.LocationComboBox.setEnabled(False) + self.BibleComboBox.setEnabled(False) + self.TypeComboBox.setEnabled(False) + + def freeAll(self): + if self.bibletype == None: # only reset if no bible type set. + self.BooksLocationEdit.setReadOnly(False) + self.VerseLocationEdit.setReadOnly(False) + self.BooksFileButton.setEnabled(True) + self.VersesFileButton.setEnabled(True) + self.OSISLocationEdit.setReadOnly(False) + self.OsisFileButton.setEnabled(True) + self.LocationComboBox.setEnabled(True) + self.BibleComboBox.setEnabled(True) + self.TypeComboBox.setEnabled(True) - def validate(self): - valid = False - validcount = 0 - if len(self.BibleNameEdit.displayText()) > 0: - validcount += 1 - if len(self.OSISLocationEdit.displayText()) > 0: - validcount += 1 - if len(self.BooksLocationEdit.displayText()) > 0: - validcount += 1 - if len(self.VersionNameEdit.displayText()) > 0 and len(self.CopyrightEdit.displayText()) > 0 and len(self.PermisionEdit.displayText()) > 0: - valid = True -# if validcount == 2 and valid: -# self.BibleImportButtonBox.addButton(self.savebutton, QtGui.QDialogButtonBox.AcceptRole) # hide the save button tile screen is valid -# else: -# self.BibleImportButtonBox.removeButton(self.savebutton) # hide the save button tile screen is valid - - + def resetAll(self): + self.BooksLocationEdit.setText("") + self.VerseLocationEdit.setText("") + self.OSISLocationEdit.setText("") + self.LocationComboBox.setCurrentIndex(0) + self.BibleComboBox.setCurrentIndex(0) + self.TypeComboBox.setCurrentIndex(0) diff --git a/openlp/plugins/bibles/lib/bibleDBimpl.py b/openlp/plugins/bibles/lib/bibleDBimpl.py index 0fdcd3efa..313c1c2a2 100644 --- a/openlp/plugins/bibles/lib/bibleDBimpl.py +++ b/openlp/plugins/bibles/lib/bibleDBimpl.py @@ -63,14 +63,10 @@ class BibleDBImpl(BibleCommon): def create_tables(self): log.debug( "createTables") - if os.path.exists(self.biblefile): # delete bible file and set it up again - os.remove(self.biblefile) - #meta_table.create() - #testament_table.create() - #book_table.create() - #verse_table.create() self.save_meta("dbversion", "2") - self._load_testaments() + self._load_testament("Old Testament") + self._load_testament("Apocrypha") + self._load_testament("New Testament") def add_verse(self, bookid, chap, vse, text): log.debug( "add_verse %s,%s,%s,%s", bookid, chap, vse, text) @@ -97,17 +93,17 @@ class BibleDBImpl(BibleCommon): session.add(verse) session.commit() - def create_book(self, bookid, bookname, bookabbrev): - log.debug( "create_book %s,%s,%s", bookid, bookname, bookabbrev) + def create_book(self, bookname, bookabbrev): + log.debug( "create_book %s,%s", bookname, bookabbrev) metadata.bind.echo = False session = self.session() book = Book() - book.tetsament_id = 1 + book.testament_id = 1 book.name = bookname book.abbreviation = bookabbrev session.add(book) session.commit() - return book.id + return book.id def save_meta(self, key, value): metadata.bind.echo = False @@ -131,18 +127,14 @@ class BibleDBImpl(BibleCommon): except: return False - def _load_testaments(self): - log.debug("load_testaments") + def _load_testament(self, testament): + log.debug("load_testaments %s", testament) metadata.bind.echo = False session = self.session() test = ONTestament() - test.name = "Old Testament" + test.name = testament session.add(test) - test.name = "New Testament" - session.add(test) - test.name = "Apocrypha" - session.add(test) - session.commit() + session.commit() def get_bible_books(self): log.debug( "get_bible_books ") @@ -164,11 +156,12 @@ class BibleDBImpl(BibleCommon): log.debug( "get_bible_book %s", bookname) return self.session.query(Book).filter_by(name = bookname).first() - def get_bible_chapter(self, bookname, chapter): - log.debug( "get_bible_chapter %s,%s", bookname, chapter ) + def get_bible_chapter(self, id, chapter): + log.debug( "get_bible_chapter %s,%s", id, chapter ) metadata.bind.echo = False - s = text (""" select book.name FROM verse,book where verse.book_id == book.id AND verse.chapter == :c and book.name == :b """) - return self.db.execute(s, c=chapter, b=bookname).fetchone() + #s = text (""" select book.name FROM verse,book where verse.book_id == book.id AND verse.chapter == :c and book.name == :b """) + return self.session.query(Verse).filter_by(chapter = chapter ).filter_by(book_id = id).first() + #return self.db.execute(s, c=chapter, b=bookname).fetchone() def get_bible_text(self, bookname, chapter, sverse, everse): log.debug( "get_bible_text %s,%s,%s,%s ", bookname, chapter, sverse, everse) diff --git a/openlp/plugins/bibles/lib/bibleHTTPimpl.py b/openlp/plugins/bibles/lib/bibleHTTPimpl.py index 4245986a0..ed94ed04b 100644 --- a/openlp/plugins/bibles/lib/bibleHTTPimpl.py +++ b/openlp/plugins/bibles/lib/bibleHTTPimpl.py @@ -169,7 +169,7 @@ class BibleHTTPImpl(): log.debug( "get_bible_chapter %s,%s,%s,%s", version, bookid, bookname, chapter) log.debug("biblesource = %s", self.biblesource) try: - if self.biblesource == 'Crosswalk': + if self.biblesource.lower() == 'crosswalk': ev = CWExtract(self.proxyurl) else: ev = BGExtract(self.proxyurl) diff --git a/openlp/plugins/bibles/lib/common.py b/openlp/plugins/bibles/lib/common.py index 282fbab6d..4365563ce 100644 --- a/openlp/plugins/bibles/lib/common.py +++ b/openlp/plugins/bibles/lib/common.py @@ -32,14 +32,12 @@ class BibleCommon: """ def _get_web_text(self, urlstring, proxyurl): log.debug( "get_web_text %s %s", proxyurl, urlstring) - - if proxyurl != "" or len(proxyurl) > 0 : + if not proxyurl == None: print "ProxyUrl " , proxyurl + " " + str(len(proxyurl)) proxy_support = urllib2.ProxyHandler({'http': self.proxyurl}) http_support = urllib2.HTTPHandler() opener= urllib2.build_opener(proxy_support, http_support) urllib2.install_opener(opener) - xml_string = "" req = urllib2.Request(urlstring) req.add_header('User-Agent', 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)') diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index 0ec37411a..1c0bf0619 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -61,7 +61,7 @@ class BibleManager(): biblesource = self.bibleDBCache[bname].get_meta("WEB") # look to see if lazy load bible exists and get create getter. if biblesource: nhttp = BibleHTTPImpl() - nhttp.set_bible_source(biblesource) # tell The Server where to get the verses from. + nhttp.set_bible_source(biblesource.value) # tell The Server where to get the verses from. self.bibleHTTPCache[bname] = nhttp proxy = self.bibleDBCache[bname].get_meta("proxy") # look to see if lazy load bible exists and get create getter. nhttp.set_proxy(proxy) # tell The Server where to get the verses from. @@ -79,7 +79,7 @@ class BibleManager(): Return a list of bibles from a given URL. The selected Bible can then be registered and LazyLoaded into a database """ - log.debug( "register_HTTP_bible %s,%s,%s,%s,%s", biblename, biblesource, proxyurl, proxyid, proxypass, mode) + log.debug( "register_HTTP_bible %s,%s,%s,%s,%s,%s", biblename, biblesource, proxyurl, proxyid, proxypass, mode) if self._is_new_bible(biblename): nbible = BibleDBImpl(self.biblePath, biblename, self.config) # Create new Bible nbible.create_tables() # Create Database @@ -96,6 +96,7 @@ class BibleManager(): nbible.save_meta("proxyid", proxyid) # store the proxy userid if proxypass != None: nbible.save_meta("proxypass", proxypass) # store the proxy password + return biblename def register_cvs_file_bible(self, biblename, booksfile, versefile): @@ -126,6 +127,7 @@ class BibleManager(): bcsv.load_data(osisfile, self.dialogobject) def get_bibles(self, mode="full"): + log.debug("get_bibles") """ Returns a list of Books of the bible Mode "Full" - Returns all the bibles for the Queck seearch @@ -195,18 +197,24 @@ class BibleManager(): Rest can be guessed at ! """ text = [] - #log.debug( self.bibleDBCache) - #log.debug( self.bibleHTTPCache) - log.debug( "get_verse_text %s,%s,%s,%s,%s,%s", bible,bookname, schapter,echapter, sverse, everse) -# bookid = self.booksOfBible[bookname] # convert to id ie Genesis --> 1 Revelation --> 73 -# # SORT OUT BOOKNAME BOOK ID. -# # NAME COMES IN TO ID AND BACK TO NAME ? -# c = self.bibleDBCache[bible].getBibleChapter(bookname, chapter) # check to see if book/chapter exists -# bookabbrev = "" -# log.debug( "Bible Chapter %s", c ) + bookabbrev = "" + log.debug( "get_verse_text %s,%s,%s,%s,%s,%s", bible, bookname, schapter, echapter, sverse, everse) + if not self.bibleHTTPCache[bible] == None: + book= self.bibleDBCache[bible].get_bible_book(bookname) # check to see if book/chapter exists + if book == None: + book = self.bibleDBCache[bible].create_book(bookname, bookabbrev) + for chapter in range(schapter, echapter+1): + print chapter + v = self.bibleDBCache[bible].get_bible_chapter(book.id, chapter) + if v == None: + chaptlist = self.bibleHTTPCache[bible].get_bible_chapter(bible, book.id, bookname, chapter) + self.bibleDBCache[bible].create_chapter(book.id, chapter, chaptlist) + + + #log.debug( "Bible Chapter %s", c ) # if not c: # self._loadBook(bible,bookid, bookname, bookabbrev) -# self._loadChapter(bible, bookid,bookname, chapter) +# self._loadChapter(bible, bookid,bookname, schapter) if schapter == echapter: text = self.bibleDBCache[bible].get_bible_text(bookname, schapter, sverse, everse) else: @@ -223,6 +231,7 @@ class BibleManager(): txt = self.bibleDBCache[bible].get_bible_text(bookname, i, start, end) text.extend(txt) + print text return text def _load_book(self, bible, bookid, bookname, bookabbrev): diff --git a/resources/forms/bibleimportdialog.ui b/resources/forms/bibleimportdialog.ui index 01303b8ec..5e7db5a46 100644 --- a/resources/forms/bibleimportdialog.ui +++ b/resources/forms/bibleimportdialog.ui @@ -50,8 +50,8 @@ 0 0 - 471 - 369 + 96 + 26 @@ -192,7 +192,7 @@ 0 0 471 - 369 + 371 @@ -245,7 +245,7 @@ - CrossWire + Crosswalk