From db392aa08627c3f65e8a1f9d0df61afdc08b7b45 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Tue, 27 Oct 2009 20:52:30 +0000 Subject: [PATCH 1/5] Fix typos --- openlp/plugins/bibles/lib/bibleHTTPimpl.py | 10 +++++++--- openlp/plugins/bibles/lib/manager.py | 10 +--------- openlp/plugins/bibles/lib/mediaitem.py | 2 +- openlp/plugins/songusage/lib/manager.py | 6 +++--- 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/openlp/plugins/bibles/lib/bibleHTTPimpl.py b/openlp/plugins/bibles/lib/bibleHTTPimpl.py index 6359e828e..98281d26b 100644 --- a/openlp/plugins/bibles/lib/bibleHTTPimpl.py +++ b/openlp/plugins/bibles/lib/bibleHTTPimpl.py @@ -68,13 +68,15 @@ class BGExtract(BibleCommon): verseText = u'' versePos = xml_string.find(u'', versePos) + 6 i = xml_string.find(verseSearch, versePos + 1) + # Not sure if this is needed now if i == -1: i = xml_string.find(u' 0 and j < i: i = j verseText = xml_string[versePos + 7 : i ] - bible[verse] = self._clean_text(verseText) # store the verse + # store the verse + bible[verse] = self._clean_text(verseText) versePos = -1 else: verseText = xml_string[versePos: i] @@ -85,8 +87,10 @@ class BGExtract(BibleCommon): start_tag = verseText.find(verseFootnote) # Chop off verse and start again xml_string = xml_string[i:] - versePos = xml_string.find(verseSearch) #look for the next verse - bible[verse] = self._clean_text(verseText) # store the verse + #look for the next verse + versePos = xml_string.find(verseSearch) + # store the verse + bible[verse] = self._clean_text(verseText) verse += 1 return SearchResults(bookname, chapter, bible) diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index 2948ddb88..eaaf147b6 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -66,15 +66,7 @@ class BibleManager(object): self.bibleSuffix = u'sqlite' self.dialogobject = None self.reload_bibles() - - def set_media_manager(self, media): - """ - Sets the reference to the media manager. - - ``media`` - The reference to the media manager. - """ - self.media = media + self.media = None def reload_bibles(self): log.debug(u'Reload bibles') diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index f78c20ca5..a6cfc53f8 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -268,7 +268,7 @@ class BibleMediaItem(MediaManagerItem): def initialise(self): log.debug(u'bible manager initialise') self.loadBibles() - self.parent.biblemanager.set_media_manager(self) + self.parent.biblemanager.media = self self.configUpdated() log.debug(u'bible manager initialise complete') diff --git a/openlp/plugins/songusage/lib/manager.py b/openlp/plugins/songusage/lib/manager.py index 8f94e119f..631808ff5 100644 --- a/openlp/plugins/songusage/lib/manager.py +++ b/openlp/plugins/songusage/lib/manager.py @@ -101,7 +101,7 @@ class SongUsageManager(): return True except: self.session.rollback() - log.excertion(u'SongUsage Item failed to delete') + log.exception(u'SongUsage Item failed to delete') return False else: return True @@ -116,7 +116,7 @@ class SongUsageManager(): return True except: self.session.rollback() - log.excertion(u'Failed to delete all Song Usage items') + log.exception(u'Failed to delete all Song Usage items') return False def delete_to_date(self, date): @@ -130,5 +130,5 @@ class SongUsageManager(): return True except: self.session.rollback() - log.excertion(u'Failed to delete all Song Usage items to %s' % date) + log.exception(u'Failed to delete all Song Usage items to %s' % date) return False From 19e8682bf86deb0b4d3a1ee56f4229cf5949fbc4 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 28 Oct 2009 18:35:06 +0000 Subject: [PATCH 2/5] Add BibleGateway List and access it --- openlp/core/ui/settingsform.py | 1 + .../plugins/bibles/forms/bibleimportform.py | 38 ++++++--- .../plugins/bibles/resources/biblegateway.csv | 80 +++++++++++++++++++ 3 files changed, 110 insertions(+), 9 deletions(-) create mode 100644 openlp/plugins/bibles/resources/biblegateway.csv diff --git a/openlp/core/ui/settingsform.py b/openlp/core/ui/settingsform.py index 6d17009af..02f812f9a 100644 --- a/openlp/core/ui/settingsform.py +++ b/openlp/core/ui/settingsform.py @@ -53,6 +53,7 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog): def insertTab(self, tab, location): log.debug(u'Inserting %s tab' % tab.title()) + #13 : There are 3 tables currently and lcations starts at -10 self.SettingsTabWidget.insertTab(location + 13, tab, tab.title()) def removeTab(self, name): diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index 9a871ec88..facd055fb 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -53,18 +53,33 @@ class BibleImportForm(QtGui.QDialog, Ui_BibleImportDialog): self.AddressEdit.setText(self.config.get_config(u'proxy_address', u'')) self.UsernameEdit.setText(self.config.get_config(u'proxy_username',u'')) self.PasswordEdit.setText(self.config.get_config(u'proxy_password',u'')) - + #Load and store Crosswalk Bibles filepath = os.path.split(os.path.abspath(__file__))[0] filepath = os.path.abspath(os.path.join(filepath, u'..', u'resources', u'crosswalkbooks.csv')) fbibles=open(filepath, 'r') - self.bible_versions = {} - self.BibleComboBox.clear() - self.BibleComboBox.addItem(u'') + self.cw_bible_versions = {} for line in fbibles: p = line.split(u',') - self.bible_versions[p[0]] = p[1].replace(u'\n', u'') - self.BibleComboBox.addItem(unicode(p[0])) + self.cw_bible_versions[p[0]] = p[1].replace(u'\n', u'') + #Load and store BibleGateway Bibles + filepath = os.path.split(os.path.abspath(__file__))[0] + filepath = os.path.abspath(os.path.join(filepath, u'..', + u'resources', u'biblegateway.csv')) + fbibles=open(filepath, 'r') + self.bg_bible_versions = {} + for line in fbibles: + p = line.split(u',') + self.bg_bible_versions[p[0]] = p[1].replace(u'\n', u'') + self.loadBibleCombo(self.cw_bible_versions) + + def loadBibleCombo(self, biblesList): + self.BibleComboBox.clear() + self.BibleComboBox.addItem(u'') + for bible in biblesList: + row = self.BibleComboBox.count() + self.BibleComboBox.addItem(unicode(self.trUtf8(bible))) + self.BibleComboBox.setItemData(row, QtCore.QVariant(bible)) #Combo Boxes QtCore.QObject.connect(self.LocationComboBox, @@ -150,12 +165,17 @@ class BibleImportForm(QtGui.QDialog, Ui_BibleImportDialog): self.config.set_config( u'proxy_password', unicode(self.PasswordEdit.displayText())) - def onLocationComboBoxSelected(self): + def onLocationComboBoxSelected(self, value): + if value == 0: + self.loadBibleCombo(self.cw_bible_versions) + else: + self.loadBibleCombo(self.bg_bible_versions) self.checkHttp() - def onBibleComboBoxSelected(self): + def onBibleComboBoxSelected(self, value): self.checkHttp() self.BibleNameEdit.setText(unicode(self.BibleComboBox.currentText())) + self.VersionNameEdit.setText(unicode(self.BibleComboBox.currentText())) def onCancelButtonClicked(self): # tell import to stop @@ -210,7 +230,7 @@ class BibleImportForm(QtGui.QDialog, Ui_BibleImportDialog): else: # set a value as it will not be needed self.setMax(1) - bible = self.bible_versions[ + bible = self.cw_bible_versions[ unicode(self.BibleComboBox.currentText())] loaded = self.biblemanager.register_http_bible( unicode(self.BibleComboBox.currentText()), diff --git a/openlp/plugins/bibles/resources/biblegateway.csv b/openlp/plugins/bibles/resources/biblegateway.csv new file mode 100644 index 000000000..deca46d7c --- /dev/null +++ b/openlp/plugins/bibles/resources/biblegateway.csv @@ -0,0 +1,80 @@ +Amuzgo de Guerrero,AMU +Arabic Life Application Bible,ALAB +Bulgarian Bible,BULG +1940 Bulgarian Bible,BG1940 +Chinanteco de Comaltepec,CCO +Cakchiquel Occidental,CKW +Haitian Creole Version,HCV +Slovo na cestu,SNC +Dette er Biblen pÃ¥ dansk,DN1933 +Hoffnung für Alle,HOF +Luther Bibel 1545,LUTH1545 +New International Version,NIV +New American Standard Bible,NASB +The Message,MSG +Amplified Bible,AMP +New Living Translation,NLT +King James Version,KJV +English Standard Version,ESV +Contemporary English Version,CEV +New King James Version,NKJV +New Century Version,NCV +21st Century King James Version,KJ21 +American Standard Version,ASV +Young's Literal Translation,YLT +Darby Translation,DARBY +Holman Christian Standard Bible,HCSB +New International Reader's Version,NIRV +Wycliffe New Testament,WYC +Worldwide English (New Testament),WE +New International Version - UK,NIVUK +Today's New International Version,TNIV +Reina-Valera 1960,RVR1960 +Nueva Versión Internacional,NVI +Reina-Valera 1995,RVR1995 +Castilian,CST +Reina-Valera Antigua,RVA +Biblia en Lenguaje Sencillo,BLS +La Biblia de las Américas,LBLA +Louis Segond,LSG +La Bible du Semeur,BDS +1881 Westcott-Hort New Testament,WHNU +1550 Stephanus New Testament,TR1550 +1894 Scrivener New Testament,TR1894 +The Westminster Leningrad Codex,WLC +Hiligaynon Bible,HLGN +Croatian Bible,CRO +Hungarian Károli,KAR +Icelandic Bible,ICELAND +La Nuova Diodati,LND +La Parola è Vita,LM +Jacalteco, Oriental,JAC +Kekchi,KEK +Korean Bible,KOREAN +Maori Bible,MAORI +Macedonian New Testament,MNT +Mam, Central,MVC +Mam de Todos Santos Chuchumatán,MVJ +Reimer 2001,REIMER +Náhuatl de Guerrero,NGU +Het Boek,HTB +Det Norsk Bibelselskap 1930,DNB1930 +Levande Bibeln,LB +O Livro,OL +João Ferreira de Almeida Atualizada,AA +Quiché, Centro Occidental,QUT +Romanian,RMNN +Romanian,TLCR +Russian Synodal Version,RUSV +Slovo Zhizny,SZ +Nádej pre kazdého,NPK +Albanian Bible,ALB +Levande Bibeln,SVL +Svenska 1917,SV1917 +Swahili New Testament,SNT +Ang Salita ng Diyos,SND +Ukrainian Bible,UKR +Uspanteco,USP +1934 Vietnamese Bible,VIET +Chinese Union Version (Simplified),CUVS +Chinese Union Version (Traditional),CUV \ No newline at end of file From ccb54e4fafe95a6a846805f1cf6310bc571b652f Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 28 Oct 2009 20:57:14 +0000 Subject: [PATCH 3/5] BibleGateway - Download files and add to selections --- .../plugins/bibles/forms/bibleimportdialog.py | 2 -- .../plugins/bibles/forms/bibleimportform.py | 25 ++++++++++++------- openlp/plugins/bibles/lib/bibleHTTPimpl.py | 7 +++--- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/openlp/plugins/bibles/forms/bibleimportdialog.py b/openlp/plugins/bibles/forms/bibleimportdialog.py index 8243fc72d..d5b04d795 100644 --- a/openlp/plugins/bibles/forms/bibleimportdialog.py +++ b/openlp/plugins/bibles/forms/bibleimportdialog.py @@ -250,8 +250,6 @@ class Ui_BibleImportDialog(object): self.LocationComboBox.setItemText(0, self.trUtf8(u'Crosswalk')) self.LocationComboBox.setItemText(1, self.trUtf8(u'BibleGateway')) self.BibleLabel.setText(self.trUtf8(u'Bible:')) - self.BibleComboBox.setItemText(1, self.trUtf8(u'NIV')) - self.BibleComboBox.setItemText(2, self.trUtf8(u'KJV')) self.ProxyGroupBox.setTitle(self.trUtf8(u'Proxy Settings (Optional)')) self.AddressLabel.setText(self.trUtf8(u'Proxy Address:')) self.UsernameLabel.setText(self.trUtf8(u'Username:')) diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index facd055fb..a46a7f9f6 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -58,20 +58,21 @@ class BibleImportForm(QtGui.QDialog, Ui_BibleImportDialog): filepath = os.path.abspath(os.path.join(filepath, u'..', u'resources', u'crosswalkbooks.csv')) fbibles=open(filepath, 'r') - self.cw_bible_versions = {} + self.cwBibleVersions = {} for line in fbibles: p = line.split(u',') - self.cw_bible_versions[p[0]] = p[1].replace(u'\n', u'') + self.cwBibleVersions [p[0]] = p[1].replace(u'\n', u'') #Load and store BibleGateway Bibles filepath = os.path.split(os.path.abspath(__file__))[0] filepath = os.path.abspath(os.path.join(filepath, u'..', u'resources', u'biblegateway.csv')) fbibles=open(filepath, 'r') - self.bg_bible_versions = {} + self.bgBibleVersions = {} for line in fbibles: p = line.split(u',') - self.bg_bible_versions[p[0]] = p[1].replace(u'\n', u'') - self.loadBibleCombo(self.cw_bible_versions) + self.bgBibleVersions [p[0]] = p[1].replace(u'\n', u'') + self.loadBibleCombo(self.cwBibleVersions ) + self.cwActive = True def loadBibleCombo(self, biblesList): self.BibleComboBox.clear() @@ -167,9 +168,11 @@ class BibleImportForm(QtGui.QDialog, Ui_BibleImportDialog): def onLocationComboBoxSelected(self, value): if value == 0: - self.loadBibleCombo(self.cw_bible_versions) + self.loadBibleCombo(self.cwBibleVersions ) + self.cwActive = True else: - self.loadBibleCombo(self.bg_bible_versions) + self.loadBibleCombo(self.bgBibleVersions ) + self.cwActive = False self.checkHttp() def onBibleComboBoxSelected(self, value): @@ -230,8 +233,12 @@ class BibleImportForm(QtGui.QDialog, Ui_BibleImportDialog): else: # set a value as it will not be needed self.setMax(1) - bible = self.cw_bible_versions[ - unicode(self.BibleComboBox.currentText())] + if self.cwActive: + bible = self.cwBibleVersions [ + unicode(self.BibleComboBox.currentText())] + else: + bible = self.bgBibleVersions [ + unicode(self.BibleComboBox.currentText())] loaded = self.biblemanager.register_http_bible( unicode(self.BibleComboBox.currentText()), unicode(self.LocationComboBox.currentText()), diff --git a/openlp/plugins/bibles/lib/bibleHTTPimpl.py b/openlp/plugins/bibles/lib/bibleHTTPimpl.py index 98281d26b..15537ad8f 100644 --- a/openlp/plugins/bibles/lib/bibleHTTPimpl.py +++ b/openlp/plugins/bibles/lib/bibleHTTPimpl.py @@ -50,12 +50,11 @@ class BGExtract(BibleCommon): """ log.debug(u'get_bible_chapter %s,%s,%s', version, bookname, chapter) - version=u'nasb' urlstring = \ - u'http://www.biblegateway.com/passage/?search=%s %s&version=%s' % \ - (bookname, unicode(chapter) , version) + u'http://www.biblegateway.com/passage/?search=%s+%d&version=%s' % \ + (bookname, chapter, version) + log.debug(u'BibleGateway urm = %s' % urlstring) xml_string = self._get_web_text(urlstring, self.proxyurl) - #print xml_string verseSearch = u' Date: Thu, 29 Oct 2009 06:24:53 +0000 Subject: [PATCH 4/5] Style fixes --- openlp/core/ui/settingsform.py | 2 +- .../plugins/bibles/forms/bibleimportform.py | 37 ++++++++++++------- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/openlp/core/ui/settingsform.py b/openlp/core/ui/settingsform.py index 02f812f9a..c90447c59 100644 --- a/openlp/core/ui/settingsform.py +++ b/openlp/core/ui/settingsform.py @@ -53,7 +53,7 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog): def insertTab(self, tab, location): log.debug(u'Inserting %s tab' % tab.title()) - #13 : There are 3 tables currently and lcations starts at -10 + #13 : There are 3 tables currently and locations starts at -10 self.SettingsTabWidget.insertTab(location + 13, tab, tab.title()) def removeTab(self, name): diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index a46a7f9f6..3e8029dc6 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -50,6 +50,8 @@ class BibleImportForm(QtGui.QDialog, Ui_BibleImportDialog): self.bible_type = None self.barmax = 0 self.tabWidget.setCurrentIndex(0) + self.cwBibleVersions = {} + self.bgBibleVersions = {} self.AddressEdit.setText(self.config.get_config(u'proxy_address', u'')) self.UsernameEdit.setText(self.config.get_config(u'proxy_username',u'')) self.PasswordEdit.setText(self.config.get_config(u'proxy_password',u'')) @@ -57,21 +59,25 @@ class BibleImportForm(QtGui.QDialog, Ui_BibleImportDialog): filepath = os.path.split(os.path.abspath(__file__))[0] filepath = os.path.abspath(os.path.join(filepath, u'..', u'resources', u'crosswalkbooks.csv')) - fbibles=open(filepath, 'r') - self.cwBibleVersions = {} - for line in fbibles: - p = line.split(u',') - self.cwBibleVersions [p[0]] = p[1].replace(u'\n', u'') + try: + fbibles = open(filepath, 'r') + for line in fbibles: + p = line.split(u',') + self.cwBibleVersions[p[0]] = p[1].replace(u'\n', u'') + except: + log.exception(u'Crosswalk resources missing') #Load and store BibleGateway Bibles filepath = os.path.split(os.path.abspath(__file__))[0] filepath = os.path.abspath(os.path.join(filepath, u'..', u'resources', u'biblegateway.csv')) - fbibles=open(filepath, 'r') - self.bgBibleVersions = {} - for line in fbibles: - p = line.split(u',') - self.bgBibleVersions [p[0]] = p[1].replace(u'\n', u'') - self.loadBibleCombo(self.cwBibleVersions ) + try: + fbibles = open(filepath, 'r') + for line in fbibles: + p = line.split(u',') + self.bgBibleVersions[p[0]] = p[1].replace(u'\n', u'') + except: + log.exception(u'Biblegateway resources missing') + self.loadBibleCombo(self.cwBibleVersions) self.cwActive = True def loadBibleCombo(self, biblesList): @@ -117,7 +123,8 @@ class BibleImportForm(QtGui.QDialog, Ui_BibleImportDialog): def onVersesFileButtonClicked(self): filename = QtGui.QFileDialog.getOpenFileName( - self, self.trUtf8(u'Open file'), self.config.get_last_dir(1)) + self, self.trUtf8(u'Open Bible Verses file'), + self.config.get_last_dir(1)) if filename != u'': self.VerseLocationEdit.setText(filename) self.config.set_last_dir(filename, 1) @@ -125,7 +132,8 @@ class BibleImportForm(QtGui.QDialog, Ui_BibleImportDialog): def onBooksFileButtonClicked(self): filename = QtGui.QFileDialog.getOpenFileName( - self, self.trUtf8(u'Open file'), self.config.get_last_dir(2)) + self, self.trUtf8(u'Open Bible Books file'), + self.config.get_last_dir(2)) if filename != u'': self.BooksLocationEdit.setText(filename) self.config.set_last_dir(filename, 2) @@ -133,7 +141,8 @@ class BibleImportForm(QtGui.QDialog, Ui_BibleImportDialog): def onOsisFileButtonClicked(self): filename = QtGui.QFileDialog.getOpenFileName( - self, self.trUtf8(u'Open file'), self.config.get_last_dir(3)) + self, self.trUtf8(u'Open OSIS import file'), + self.config.get_last_dir(3)) if filename != u'': self.OSISLocationEdit.setText(filename) self.config.set_last_dir(filename, 3) From b447e382ad95695c21b20a05cf6ea6e578b2c85a Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Thu, 29 Oct 2009 06:45:37 +0000 Subject: [PATCH 5/5] Strange spacing appeared from nowhere --- openlp/plugins/bibles/forms/bibleimportform.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index 3e8029dc6..1a4084424 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -177,10 +177,10 @@ class BibleImportForm(QtGui.QDialog, Ui_BibleImportDialog): def onLocationComboBoxSelected(self, value): if value == 0: - self.loadBibleCombo(self.cwBibleVersions ) + self.loadBibleCombo(self.cwBibleVersions) self.cwActive = True else: - self.loadBibleCombo(self.bgBibleVersions ) + self.loadBibleCombo(self.bgBibleVersions) self.cwActive = False self.checkHttp() @@ -243,10 +243,10 @@ class BibleImportForm(QtGui.QDialog, Ui_BibleImportDialog): # set a value as it will not be needed self.setMax(1) if self.cwActive: - bible = self.cwBibleVersions [ + bible = self.cwBibleVersions[ unicode(self.BibleComboBox.currentText())] else: - bible = self.bgBibleVersions [ + bible = self.bgBibleVersions[ unicode(self.BibleComboBox.currentText())] loaded = self.biblemanager.register_http_bible( unicode(self.BibleComboBox.currentText()),