forked from openlp/openlp
Add download notifications for HTTP bibles
Fix bug running off the end of bible chapter
This commit is contained in:
parent
470f1d19df
commit
fa606e19a9
@ -96,7 +96,7 @@ class CWExtract(BibleCommon):
|
|||||||
chapter - chapter number
|
chapter - chapter number
|
||||||
"""
|
"""
|
||||||
log.debug(u'get_bible_chapter %s,%s,%s,%s', version, bookid, bookname, chapter)
|
log.debug(u'get_bible_chapter %s,%s,%s,%s', version, bookid, bookname, chapter)
|
||||||
bookname = bookname.replace(u' ', '')
|
bookname = bookname.replace(u' ', u'')
|
||||||
urlstring = u'http://bible.crosswalk.com/OnlineStudyBible/bible.cgi?word=%s+%d&version=%s' % (bookname, chapter, version)
|
urlstring = u'http://bible.crosswalk.com/OnlineStudyBible/bible.cgi?word=%s+%d&version=%s' % (bookname, chapter, version)
|
||||||
xml_string = self._get_web_text(urlstring, self.proxyurl)
|
xml_string = self._get_web_text(urlstring, self.proxyurl)
|
||||||
#log.debug(u'Return data %s', xml_string)
|
#log.debug(u'Return data %s', xml_string)
|
||||||
@ -151,8 +151,8 @@ class CWExtract(BibleCommon):
|
|||||||
verseText = xml_string[versePos: i]
|
verseText = xml_string[versePos: i]
|
||||||
versePos = i
|
versePos = i
|
||||||
#print verseText
|
#print verseText
|
||||||
|
#print self._clean_text(verseText)
|
||||||
bible[verse] = self._clean_text(verseText)
|
bible[verse] = self._clean_text(verseText)
|
||||||
#bible[verse] = verseText
|
|
||||||
|
|
||||||
#log.debug( bible)
|
#log.debug( bible)
|
||||||
return SearchResults(book_title, book_chapter, bible)
|
return SearchResults(book_title, book_chapter, bible)
|
||||||
|
@ -28,9 +28,7 @@ from bibleOSISimpl import BibleOSISImpl
|
|||||||
from bibleCSVimpl import BibleCSVImpl
|
from bibleCSVimpl import BibleCSVImpl
|
||||||
from bibleDBimpl import BibleDBImpl
|
from bibleDBimpl import BibleDBImpl
|
||||||
from bibleHTTPimpl import BibleHTTPImpl
|
from bibleHTTPimpl import BibleHTTPImpl
|
||||||
|
from openlp.core.lib import Receiver
|
||||||
#from openlp.plugins.bibles.lib.tables import *
|
|
||||||
#from openlp.plugins.bibles.lib.classes import *
|
|
||||||
|
|
||||||
class BibleMode(object):
|
class BibleMode(object):
|
||||||
Full = 1
|
Full = 1
|
||||||
@ -68,6 +66,15 @@ class BibleManager(object):
|
|||||||
self.dialogobject = None
|
self.dialogobject = None
|
||||||
self.reload_bibles()
|
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
|
||||||
|
|
||||||
def reload_bibles(self):
|
def reload_bibles(self):
|
||||||
log.debug(u'Reload bibles')
|
log.debug(u'Reload bibles')
|
||||||
files = self.config.get_files(self.bibleSuffix)
|
files = self.config.get_files(self.bibleSuffix)
|
||||||
@ -228,8 +235,7 @@ class BibleManager(object):
|
|||||||
Advanced Search, and when the mode is ``BibleMode.Partial``
|
Advanced Search, and when the mode is ``BibleMode.Partial``
|
||||||
this method returns all the bibles for the Quick Search.
|
this method returns all the bibles for the Quick Search.
|
||||||
|
|
||||||
``mode``
|
c
|
||||||
Defaults to ``BibleMode.Full``. The Bible mode.
|
|
||||||
"""
|
"""
|
||||||
log.debug(u'get_bibles')
|
log.debug(u'get_bibles')
|
||||||
bible_list = []
|
bible_list = []
|
||||||
@ -293,17 +299,24 @@ class BibleManager(object):
|
|||||||
Returns a list of verses for a given Book, Chapter and ranges of verses.
|
Returns a list of verses for a given Book, Chapter and ranges of verses.
|
||||||
If the end verse(everse) is less then the start verse(sverse)
|
If the end verse(everse) is less then the start verse(sverse)
|
||||||
then only one verse is returned
|
then only one verse is returned
|
||||||
bible - Which bible to use.
|
|
||||||
|
``bible``
|
||||||
|
The name of the bible to be used
|
||||||
|
|
||||||
Rest can be guessed at !
|
Rest can be guessed at !
|
||||||
"""
|
"""
|
||||||
text = []
|
text = []
|
||||||
|
self.media.setQuickMsg1(u'')
|
||||||
|
self.media.setQuickMsg2(u'')
|
||||||
log.debug(u'get_verse_text %s,%s,%s,%s,%s,%s', bible, bookname, schapter, echapter, sverse, everse)
|
log.debug(u'get_verse_text %s,%s,%s,%s,%s,%s', bible, bookname, schapter, echapter, sverse, everse)
|
||||||
if not self.bible_http_cache[bible] == None:
|
# check to see if book/chapter exists fow HTTP bibles and load cache if necessary
|
||||||
# check to see if book/chapter exists
|
if self.bible_http_cache[bible] is not None:
|
||||||
book= self.bible_db_cache[bible].get_bible_book(bookname)
|
book= self.bible_db_cache[bible].get_bible_book(bookname)
|
||||||
if book == None:
|
if book == None:
|
||||||
|
self.media.setQuickMsg1(u'Downloading')
|
||||||
log.debug(u'get_verse_text : new book')
|
log.debug(u'get_verse_text : new book')
|
||||||
for chapter in range(schapter, echapter+1):
|
for chapter in range(schapter, echapter + 1):
|
||||||
|
self.media.setQuickMsg2(u'%s: %s'% (bookname, chapter))
|
||||||
search_results = self.bible_http_cache [bible].get_bible_chapter(bible, 0, bookname, chapter)
|
search_results = self.bible_http_cache [bible].get_bible_chapter(bible, 0, bookname, chapter)
|
||||||
if search_results.has_verselist() :
|
if search_results.has_verselist() :
|
||||||
## We have found a book of the bible lets check to see if it was there.
|
## We have found a book of the bible lets check to see if it was there.
|
||||||
@ -325,35 +338,39 @@ class BibleManager(object):
|
|||||||
## Book exists check chapter and texts only.
|
## Book exists check chapter and texts only.
|
||||||
v = self.bible_db_cache[bible].get_bible_chapter(book.id, chapter)
|
v = self.bible_db_cache[bible].get_bible_chapter(book.id, chapter)
|
||||||
if v == None:
|
if v == None:
|
||||||
|
self.media.setQuickMsg2(u'%s: %s'%(bookname, chapter))
|
||||||
self.bible_db_cache[bible].create_chapter(book.id, \
|
self.bible_db_cache[bible].create_chapter(book.id, \
|
||||||
chapter, \
|
chapter, \
|
||||||
search_results.get_verselist())
|
search_results.get_verselist())
|
||||||
else:
|
else:
|
||||||
log.debug(u'get_verse_text : old book')
|
log.debug(u'get_verse_text : old book')
|
||||||
for chapter in range(schapter, echapter+1):
|
for chapter in range(schapter, echapter + 1):
|
||||||
v = self.bible_db_cache[bible].get_bible_chapter(book.id, chapter)
|
v = self.bible_db_cache[bible].get_bible_chapter(book.id, chapter)
|
||||||
if v == None:
|
if v == None:
|
||||||
try:
|
try:
|
||||||
|
self.media.setQuickMsg1(u'Downloading')
|
||||||
|
self.media.setQuickMsg2(u'%s: %s'% (bookname, chapter))
|
||||||
search_results = self.bible_http_cache [bible].get_bible_chapter(bible, book.id, bookname, chapter)
|
search_results = self.bible_http_cache [bible].get_bible_chapter(bible, book.id, bookname, chapter)
|
||||||
self.bible_db_cache[bible].create_chapter(book.id, \
|
if search_results.has_verselist():
|
||||||
search_results.get_chapter(),\
|
self.bible_db_cache[bible].create_chapter(book.id, \
|
||||||
search_results.get_verselist())
|
search_results.get_chapter(),\
|
||||||
|
search_results.get_verselist())
|
||||||
except :
|
except :
|
||||||
log.error(u'Errow thrown %s', sys.exc_info()[1])
|
log.error(u'Errow thrown %s', sys.exc_info()[1])
|
||||||
|
#Now get verses from database
|
||||||
if schapter == echapter:
|
if schapter == echapter:
|
||||||
text = self.bible_db_cache[bible].get_bible_text(bookname, schapter, sverse, everse)
|
text = self.bible_db_cache[bible].get_bible_text(bookname, schapter, sverse, everse)
|
||||||
else:
|
else:
|
||||||
for i in range (schapter, echapter + 1):
|
for i in range (schapter, echapter + 1):
|
||||||
if i == schapter:
|
if i == schapter:
|
||||||
start = sverse
|
start = sverse
|
||||||
end = self.get_book_verse_count(bible, bookname,i )[0]
|
end = self.get_book_verse_count(bible, bookname, i)
|
||||||
elif i == echapter:
|
elif i == echapter:
|
||||||
start = 1
|
start = 1
|
||||||
end = everse
|
end = everse
|
||||||
else:
|
else:
|
||||||
start = 1
|
start = 1
|
||||||
end = self.get_book_verse_count(bible, bookname,i )[0]
|
end = self.get_book_verse_count(bible, bookname, i)
|
||||||
|
|
||||||
txt = self.bible_db_cache[bible].get_bible_text(bookname, i, start, end)
|
txt = self.bible_db_cache[bible].get_bible_text(bookname, i, start, end)
|
||||||
text.extend(txt)
|
text.extend(txt)
|
||||||
|
@ -135,6 +135,12 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
self.ClearQuickSearchComboBox = QtGui.QComboBox(self.QuickTab)
|
self.ClearQuickSearchComboBox = QtGui.QComboBox(self.QuickTab)
|
||||||
self.ClearQuickSearchComboBox.setObjectName(u'ClearQuickSearchComboBox')
|
self.ClearQuickSearchComboBox.setObjectName(u'ClearQuickSearchComboBox')
|
||||||
self.QuickLayout.addWidget(self.ClearQuickSearchComboBox, 3, 1, 1, 1)
|
self.QuickLayout.addWidget(self.ClearQuickSearchComboBox, 3, 1, 1, 1)
|
||||||
|
self.QuickMsg1 = QtGui.QLabel(self.QuickTab)
|
||||||
|
self.QuickMsg1.setObjectName(u'QuickSearchLabel')
|
||||||
|
self.QuickLayout.addWidget(self.QuickMsg1, 4, 0, 1, 1)
|
||||||
|
self.QuickMsg2 = QtGui.QLabel(self.QuickTab)
|
||||||
|
self.QuickMsg2.setObjectName(u'QuickSearchLabel')
|
||||||
|
self.QuickLayout.addWidget(self.QuickMsg2, 4, 1, 1, 1)
|
||||||
self.SearchTabWidget.addTab(self.QuickTab, 'Quick')
|
self.SearchTabWidget.addTab(self.QuickTab, 'Quick')
|
||||||
QuickSpacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum,
|
QuickSpacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum,
|
||||||
QtGui.QSizePolicy.Expanding)
|
QtGui.QSizePolicy.Expanding)
|
||||||
@ -254,6 +260,14 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
def initialise(self):
|
def initialise(self):
|
||||||
log.debug(u'initialise')
|
log.debug(u'initialise')
|
||||||
self.loadBibles()
|
self.loadBibles()
|
||||||
|
self.parent.biblemanager.set_media_manager(self)
|
||||||
|
|
||||||
|
def setQuickMsg1(self, text):
|
||||||
|
self.QuickMsg1.setText(translate(u'BibleMediaItem', unicode(text)))
|
||||||
|
|
||||||
|
def setQuickMsg2(self, text):
|
||||||
|
self.QuickMsg2.setText(translate(u'BibleMediaItem', unicode(text)))
|
||||||
|
Receiver().send_message(u'openlpprocessevents')
|
||||||
|
|
||||||
def loadBibles(self):
|
def loadBibles(self):
|
||||||
log.debug(u'Loading Bibles')
|
log.debug(u'Loading Bibles')
|
||||||
|
Loading…
Reference in New Issue
Block a user