Add more bible sources and improve handling

bzr-revno: 631
This commit is contained in:
Tim Bentley 2009-10-29 07:31:27 +00:00
commit d93551caf3
8 changed files with 146 additions and 36 deletions

View File

@ -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 locations starts at -10
self.SettingsTabWidget.insertTab(location + 13, tab, tab.title())
def removeTab(self, name):

View File

@ -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:'))

View File

@ -50,21 +50,43 @@ 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''))
#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 = {}
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'))
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):
self.BibleComboBox.clear()
self.BibleComboBox.addItem(u'')
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]))
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,
@ -101,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)
@ -109,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)
@ -117,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)
@ -150,12 +175,19 @@ 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.cwBibleVersions)
self.cwActive = True
else:
self.loadBibleCombo(self.bgBibleVersions)
self.cwActive = False
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,8 +242,12 @@ class BibleImportForm(QtGui.QDialog, Ui_BibleImportDialog):
else:
# set a value as it will not be needed
self.setMax(1)
bible = self.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()),

View File

@ -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'<sup class=\"versenum'
verseFootnote = u'<sup class=\'footnote'
verse = 1
@ -68,13 +67,15 @@ class BGExtract(BibleCommon):
verseText = u''
versePos = xml_string.find(u'</sup>', versePos) + 6
i = xml_string.find(verseSearch, versePos + 1)
# Not sure if this is needed now
if i == -1:
i = xml_string.find(u'</div', versePos + 1)
j = xml_string.find(u'<strong', versePos + 1)
if j > 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 +86,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)

View File

@ -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')

View File

@ -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')

View File

@ -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
Can't render this file because it has a wrong number of fields in line 51.

View File

@ -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