forked from openlp/openlp
Fixed up some of the Bible loading
This commit is contained in:
parent
db534dc2e8
commit
01ec0f407f
@ -97,9 +97,9 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard):
|
||||
QtCore.SIGNAL(u'currentIdChanged(int)'),
|
||||
self.onCurrentIdChanged)
|
||||
|
||||
def show(self):
|
||||
def exec_(self):
|
||||
self.setDefaults()
|
||||
return QtGui.QWizard.show()
|
||||
return QtGui.QWizard.exec_(self)
|
||||
|
||||
def validateCurrentPage(self):
|
||||
if self.currentId() == 0:
|
||||
@ -238,22 +238,22 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard):
|
||||
|
||||
def setDefaults(self):
|
||||
self.setField(u'source_format', 0)
|
||||
self.setField(u'osis_location', u'')
|
||||
self.setField(u'csv_booksfile', u'')
|
||||
self.setField(u'csv_versefile', u'')
|
||||
self.setField(u'opensong_file', u'')
|
||||
self.setField(u'web_location', 0)
|
||||
self.setField(u'osis_location', '')
|
||||
self.setField(u'csv_booksfile', '')
|
||||
self.setField(u'csv_versefile', '')
|
||||
self.setField(u'opensong_file', '')
|
||||
self.setField(u'web_location', DownloadLocation.Crosswalk)
|
||||
self.setField(u'web_biblename', self.BibleComboBox)
|
||||
self.setField(u'proxy_server',
|
||||
self.config.get_config(u'proxy address', u''))
|
||||
self.config.get_config(u'proxy address', ''))
|
||||
self.setField(u'proxy_username',
|
||||
self.config.get_config(u'proxy username',u''))
|
||||
self.config.get_config(u'proxy username',''))
|
||||
self.setField(u'proxy_password',
|
||||
self.config.get_config(u'proxy password',u''))
|
||||
self.config.get_config(u'proxy password',''))
|
||||
self.setField(u'license_version', self.VersionNameEdit)
|
||||
self.setField(u'license_copyright', self.CopyrightEdit)
|
||||
self.setField(u'license_permission', self.PermissionEdit)
|
||||
self.onLocationComboBoxChanged(0)
|
||||
self.onLocationComboBoxChanged(DownloadLocation.Crosswalk)
|
||||
|
||||
def loadWebBibles(self):
|
||||
"""
|
||||
|
@ -109,7 +109,7 @@ class BibleDB(QtCore.QObject):
|
||||
self.create_testament(u'Apocrypha')
|
||||
|
||||
def create_testament(self, testament):
|
||||
log.debug(u'%s: %s', __name__, testament)
|
||||
log.debug(u'BibleDB.create_testament("%s")', testament)
|
||||
self.session.add(Testament.populate(name=testament))
|
||||
self.commit()
|
||||
|
||||
@ -153,11 +153,11 @@ class BibleDB(QtCore.QObject):
|
||||
self.commit()
|
||||
|
||||
def get_books(self):
|
||||
log.debug(__name__)
|
||||
log.debug(u'BibleDB.get_books()')
|
||||
return self.session.query(Book).order_by(Book.id).all()
|
||||
|
||||
def get_book(self, book):
|
||||
log.debug(u'%s: %s', __name__, book)
|
||||
log.debug(u'BibleDb.get_book("%s")', __name__, book)
|
||||
db_book = self.session.query(Book)\
|
||||
.filter(Book.name.like(book + u'%'))\
|
||||
.first()
|
||||
@ -168,7 +168,7 @@ class BibleDB(QtCore.QObject):
|
||||
return db_book
|
||||
|
||||
def get_chapter(self, id, chapter):
|
||||
log.debug(u'%s: %s, %s', __name__, id, chapter)
|
||||
log.debug(u'BibleDB.get_chapter("%s", %s)', id, chapter)
|
||||
return self.session.query(Verse)\
|
||||
.filter_by(chapter=chapter)\
|
||||
.filter_by(book_id=id)\
|
||||
@ -192,7 +192,7 @@ class BibleDB(QtCore.QObject):
|
||||
|
||||
[(u'Genesis', 1, 1, 1), (u'Genesis', 2, 2, 3)]
|
||||
"""
|
||||
log.debug(u'%s: %s', __name__, reference_list)
|
||||
log.debug(u'BibleDB.get_verses: %s', reference_list)
|
||||
verse_list = []
|
||||
for book, chapter, start_verse, end_verse in reference_list:
|
||||
db_book = self.get_book(book)
|
||||
@ -221,7 +221,7 @@ class BibleDB(QtCore.QObject):
|
||||
contains spaces, it will split apart and AND'd on the list of
|
||||
values.
|
||||
"""
|
||||
log.debug(u'%s: %s', __name__, text)
|
||||
log.debug(u'BibleDB.verse_search("%s")', text)
|
||||
verses = self.session.query(Verse)
|
||||
if text.find(u',') > -1:
|
||||
or_clause = []
|
||||
@ -237,7 +237,7 @@ class BibleDB(QtCore.QObject):
|
||||
return verses
|
||||
|
||||
def get_chapter_count(self, book):
|
||||
log.debug(u'%s: %s', __name__, book)
|
||||
log.debug(u'BibleDB.get_chapter_count("%s")', book)
|
||||
count = self.session.query(Verse.chapter).join(Book)\
|
||||
.filter(Book.name==book)\
|
||||
.distinct().count()
|
||||
@ -249,7 +249,7 @@ class BibleDB(QtCore.QObject):
|
||||
return count
|
||||
|
||||
def get_verse_count(self, book, chapter):
|
||||
log.debug(u'%s: %s, %s', __name__, book, chapter)
|
||||
log.debug(u'BibleDB.get_verse_count("%s", %s)', book, chapter)
|
||||
count = self.session.query(Verse).join(Book)\
|
||||
.filter(Book.name==book)\
|
||||
.filter(Verse.chapter==chapter)\
|
||||
|
@ -42,7 +42,7 @@ class BGExtract(BibleCommon):
|
||||
log.debug(u'init %s', proxyurl)
|
||||
self.proxyurl = proxyurl
|
||||
|
||||
def get_chapter(self, version, bookname, chapter) :
|
||||
def get_bible_chapter(self, version, bookname, chapter) :
|
||||
"""
|
||||
Access and decode bibles via the BibleGateway website
|
||||
|
||||
@ -256,10 +256,10 @@ class HTTPBible(BibleDB):
|
||||
return None
|
||||
|
||||
def get_books(self):
|
||||
return [Book.populate(name=self.books[book]['name']) for book in self.books]
|
||||
return [Book.populate(name=book['name']) for book in self.books]
|
||||
|
||||
def get_chapter_count(self, book):
|
||||
return self.books[book][u'chap']
|
||||
return self.lookup_book(book)[u'chap']
|
||||
|
||||
def set_proxy_server(self, server):
|
||||
self.proxy_server = server
|
||||
@ -268,7 +268,7 @@ class HTTPBible(BibleDB):
|
||||
self.books = books
|
||||
|
||||
def lookup_book(self, name):
|
||||
log.debug('Looking up "%s" in %s', (name, self.books))
|
||||
log.debug('Looking up "%s" in %s', name, self.books)
|
||||
for book in self.books:
|
||||
if book[u'name'] == name or book[u'abbr'] == name:
|
||||
return book
|
||||
|
@ -131,8 +131,7 @@ class BibleManager(object):
|
||||
u'name': unicode(line[0]),
|
||||
u'abbr': unicode(line[1]),
|
||||
u'test': line[2],
|
||||
u'chap': line[3],
|
||||
u'ordr': order
|
||||
u'chap': line[3]
|
||||
})
|
||||
except:
|
||||
log.exception(u'Failed to load http books.')
|
||||
|
Loading…
Reference in New Issue
Block a user