From d232133b35a5e07a6fdabe8e48b7fdbca636fe1b Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Thu, 22 Jul 2010 01:39:00 +0100 Subject: [PATCH 01/10] Remove wildcard import --- openlp/plugins/presentations/presentationplugin.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openlp/plugins/presentations/presentationplugin.py b/openlp/plugins/presentations/presentationplugin.py index 50784ed51..dd2cdad03 100644 --- a/openlp/plugins/presentations/presentationplugin.py +++ b/openlp/plugins/presentations/presentationplugin.py @@ -28,7 +28,8 @@ import logging from openlp.core.lib import Plugin, build_icon, PluginStatus, translate from openlp.core.utils import AppLocation -from openlp.plugins.presentations.lib import * +from openlp.plugins.presentations.lib import PresentationController, \ + PresentationMediaItem, PresentationTab log = logging.getLogger(__name__) From b5ceb59e27a35777309ecb4c94de19bfb778e278 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Fri, 23 Jul 2010 01:01:06 +0100 Subject: [PATCH 02/10] Cleanup getters and setters --- openlp/core/lib/settingsmanager.py | 29 --------- openlp/core/ui/mainwindow.py | 22 +++---- openlp/core/utils/languagemanager.py | 1 - openlp/plugins/bibles/lib/common.py | 19 ------ openlp/plugins/bibles/lib/http.py | 20 +------ openlp/plugins/bibles/lib/manager.py | 2 +- openlp/plugins/songs/lib/songxml.py | 89 +--------------------------- 7 files changed, 18 insertions(+), 164 deletions(-) diff --git a/openlp/core/lib/settingsmanager.py b/openlp/core/lib/settingsmanager.py index a8c8e7c50..d4569a647 100644 --- a/openlp/core/lib/settingsmanager.py +++ b/openlp/core/lib/settingsmanager.py @@ -57,34 +57,6 @@ class SettingsManager(object): self.mainwindow_left + self.mainwindow_right) - 100 ) / 2 self.slidecontroller_image = self.slidecontroller - 50 - def get_preview_visibility(self): - """ - Return the preview panel's visibility. - """ - return QtCore.QSettings().value(u'user interface/preview panel', - QtCore.QVariant(True)).toBool() - - def set_preview_visibility(self, visible): - """ - Set the preview panel's visibility. - """ - QtCore.QSettings().setValue(u'user interface/preview panel', - QtCore.QVariant(visible)) - - def get_live_visibility(self): - """ - Return the live panel's visibility. - """ - return QtCore.QSettings().value(u'user interface/live panel', - QtCore.QVariant(True)).toBool() - - def set_live_visibility(self, visible): - """ - Set the live panel's visibility. - """ - QtCore.QSettings().setValue(u'user interface/live panel', - QtCore.QVariant(visible)) - @staticmethod def get_last_dir(section, num=None): """ @@ -206,4 +178,3 @@ class SettingsManager(object): else: # no filtering required return files - diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index ec34a483b..c7082ddf9 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -303,18 +303,18 @@ class Ui_MainWindow(object): self.ToolsAddToolItem.setObjectName(u'ToolsAddToolItem') self.ViewPreviewPanel = QtGui.QAction(MainWindow) self.ViewPreviewPanel.setCheckable(True) - self.ViewPreviewPanel.setChecked( - self.settingsmanager.get_preview_visibility()) + previewVisible = QtCore.QSettings().value( + u'user interface/preview panel', QtCore.QVariant(True)).toBool() + self.ViewPreviewPanel.setChecked(previewVisible) self.ViewPreviewPanel.setObjectName(u'ViewPreviewPanel') - self.PreviewController.Panel.setVisible( - self.settingsmanager.get_preview_visibility()) + self.PreviewController.Panel.setVisible(previewVisible) self.ViewLivePanel = QtGui.QAction(MainWindow) self.ViewLivePanel.setCheckable(True) - self.ViewLivePanel.setChecked( - self.settingsmanager.get_live_visibility()) + liveVisible = QtCore.QSettings().value(u'user interface/live panel', + QtCore.QVariant(True)).toBool() + self.ViewLivePanel.setChecked(liveVisible) self.ViewLivePanel.setObjectName(u'ViewLivePanel') - self.LiveController.Panel.setVisible( - self.settingsmanager.get_live_visibility()) + self.LiveController.Panel.setVisible(liveVisible) self.ModeDefaultItem = QtGui.QAction(MainWindow) self.ModeDefaultItem.setCheckable(True) self.ModeDefaultItem.setObjectName(u'ModeDefaultItem') @@ -890,7 +890,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): False - Hidden """ self.PreviewController.Panel.setVisible(visible) - self.settingsmanager.set_preview_visibility(visible) + QtCore.QSettings().setValue(u'user interface/preview panel', + QtCore.QVariant(visible)) self.ViewPreviewPanel.setChecked(visible) def setLivePanelVisibility(self, visible): @@ -904,7 +905,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): False - Hidden """ self.LiveController.Panel.setVisible(visible) - self.settingsmanager.set_live_visibility(visible) + QtCore.QSettings().setValue(u'user interface/live panel', + QtCore.QVariant(visible)) self.ViewLivePanel.setChecked(visible) def loadSettings(self): diff --git a/openlp/core/utils/languagemanager.py b/openlp/core/utils/languagemanager.py index c0315559f..9cb87e891 100644 --- a/openlp/core/utils/languagemanager.py +++ b/openlp/core/utils/languagemanager.py @@ -143,4 +143,3 @@ class LanguageManager(object): if LanguageManager.__qmList__ is None: LanguageManager.init_qm_list() return LanguageManager.__qmList__ - diff --git a/openlp/plugins/bibles/lib/common.py b/openlp/plugins/bibles/lib/common.py index 30777b3a2..a4cd2a42a 100644 --- a/openlp/plugins/bibles/lib/common.py +++ b/openlp/plugins/bibles/lib/common.py @@ -138,24 +138,6 @@ class SearchResults(object): self.chapter = chapter self.verselist = verselist - def get_verselist(self): - """ - Returns the list of verses. - """ - return self.verselist - - def get_book(self): - """ - Returns the book of the Bible. - """ - return self.book - - def get_chapter(self): - """ - Returns the chapter of the book. - """ - return self.chapter - def has_verselist(self): """ Returns whether or not the verse list contains verses. @@ -277,4 +259,3 @@ def unescape(text): pass return text # leave as is return re.sub(u'&#?\w+;', fixup, text) - diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index 8bf7ac63e..dc3e8f906 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -178,7 +178,6 @@ class BGExtract(BibleCommon): """ Extract verses from BibleGateway """ - def __init__(self, proxyurl=None): log.debug(u'init %s', proxyurl) self.proxyurl = proxyurl @@ -269,7 +268,6 @@ class CWExtract(BibleCommon): """ Extract verses from CrossWalk/BibleStudyTools """ - def __init__(self, proxyurl=None): log.debug(u'init %s', proxyurl) self.proxyurl = proxyurl @@ -429,13 +427,12 @@ class HTTPBible(BibleDB): ## if it was there. By reusing the returned book name ## we get a correct book. For example it is possible ## to request ac and get Acts back. - bookname = search_results.get_book() + bookname = search_results.book Receiver.send_message(u'openlp_process_events') # check to see if book/chapter exists db_book = self.get_book(bookname) - self.create_chapter(db_book.id, - search_results.get_chapter(), - search_results.get_verselist()) + self.create_chapter(db_book.id, search_results.chapter, + search_results.verselist) Receiver.send_message(u'openlp_process_events') Receiver.send_message(u'bibles_hideprogress') Receiver.send_message(u'openlp_process_events') @@ -487,14 +484,3 @@ class HTTPBible(BibleDB): The chapter whose verses are being counted. """ return HTTPBooks.get_verse_count(book, chapter) - - def set_proxy_server(self, server): - """ - Sets the proxy server. - - **Note: This is not actually used.** - - ``server`` - The hostname or IP address of the proxy server. - """ - self.proxy_server = server diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index f862e1d1c..a252c2632 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -148,7 +148,7 @@ class BibleManager(object): file=filename, download_source=source.value, download_name=download_name) if meta_proxy: - web_bible.set_proxy_server(meta_proxy.value) + web_bible.proxy_server = meta_proxy.value self.db_cache[name] = web_bible log.debug(u'Bibles reloaded') diff --git a/openlp/plugins/songs/lib/songxml.py b/openlp/plugins/songs/lib/songxml.py index 85aa5dcc6..0a54bea9b 100644 --- a/openlp/plugins/songs/lib/songxml.py +++ b/openlp/plugins/songs/lib/songxml.py @@ -24,15 +24,9 @@ ############################################################################### import logging -#import sys -#import os from types import ListType -# Do we need these two lines? -#sys.path.append(os.path.abspath(u'./../../../..')) -#sys.path.append(os.path.abspath(os.path.join(u'.', u'..', u'..'))) - log = logging.getLogger(__name__) class SongException(Exception): @@ -70,14 +64,7 @@ class Song(object): from_ccli_text_buffer to_ccli_text_buffer - OpenSong: - from_opensong_file - to_opensong_file - from_opensong_buffer - to_opensong_buffer - presentation (screen): - get_number_of_slides get_preview_slide get_render_slide @@ -215,8 +202,8 @@ class Song(object): author_list = u', '.join(lst) self.set_title(sName) self.set_author_list(author_list) - self.set_copyright(sCopyright) - self.set_ccli_number(sCcli) + self.copyright = sCopyright + self.ccli_number = sCcli self.set_lyrics(lyrics) def from_ccli_text_file(self, textFileName): @@ -267,58 +254,30 @@ class Song(object): """Return copyright info string""" return self._assure_string(self.copyright) - def set_copyright(self, copyright): - """Set the copyright string""" - self.copyright = copyright - def get_ccli_number(self): """Return the songCclino""" return self._assure_string(self.ccli_number) - def set_ccli_number(self, ccli_number): - """Set the ccli_number""" - self.ccli_number = ccli_number - def get_theme_name(self): """Return the theme name for the song""" return self._assure_string(self.theme_name) - def set_theme_name(self, theme_name): - """Set the theme name (string)""" - self.theme_name = theme_name - def get_song_book(self): """Return the song_book (string)""" return self._assure_string(self.song_book) - def set_song_book(self, song_book): - """Set the song_book (string)""" - self.song_book = song_book - def get_song_number(self): """Return the song_number (string)""" return self._assure_string(self.song_number) - def set_song_number(self, song_number): - """Set the song_number (string)""" - self.song_number = song_number - def get_comments(self): """Return the comments (string)""" return self._assure_string(self.comments) - def set_comments(self, comments): - """Set the comments (string)""" - self.comments = comments - def get_verse_order(self): """Get the verseOrder (string) - preferably space delimited""" return self._assure_string(self.verse_order) - def set_verse_order(self, verse_order): - """Set the verse order (string) - space delimited""" - self.verse_order = verse_order - def get_author_list(self, asOneString = True): """Return the list of authors as a string @@ -369,45 +328,6 @@ class Song(object): else: self.category_array = self._list_to_string(category_array) - def get_show_title(self): - """Return the show_title flag (bool)""" - return self.show_title - - def set_show_title(self, show_title): - """Set the show_title flag (bool)""" - self.show_title = show_title - - def get_show_author_list(self): - """Return the show_author_list flag""" - return self.show_author_list - - def set_show_author_list(self, show_author_list): - """Set the show_author_list flag (bool)""" - self.show_author_list = show_author_list - - def get_show_copyright(self): - """Return the show_copyright flag""" - return self.show_copyright - - def set_show_copyright(self, show_copyright): - """Set the show_copyright flag (bool)""" - self.show_copyright = show_copyright - - def get_show_ccli_number(self): - """Return the showSongCclino (string)""" - return self.show_ccli_number - - def set_show_ccli_number(self, show_ccli_number): - """Set the show_ccli_number flag (bool)""" - self.show_ccli_number = show_ccli_number - - def get_lyrics(self): - """Return the lyrics as a list of strings - - this will return all the strings in the song - """ - return self.lyrics - def set_lyrics(self, lyrics): """Set the lyrics as a list of strings""" self.lyrics = lyrics @@ -431,11 +351,6 @@ class Song(object): if tmpSlide: self.slideList.append(tmpSlide) - def get_number_of_slides(self): - """Return the number of slides in the song (int)""" - numOfSlides = len(self.slideList) - return numOfSlides - def get_preview_slide(self, slideNumber): """Return the preview text for specified slide number From e9edb0c7a4dc3a2ec407d0a13a5147a3a1449523 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Fri, 23 Jul 2010 03:19:35 +0100 Subject: [PATCH 03/10] Refactor BibleGateway retrieval --- openlp/plugins/bibles/lib/http.py | 69 +++++-------------------------- 1 file changed, 10 insertions(+), 59 deletions(-) diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index dc3e8f906..c1deaccfa 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -29,12 +29,11 @@ import os import sqlite3 import re -from BeautifulSoup import BeautifulSoup, Tag, NavigableString +from BeautifulSoup import BeautifulSoup, NavigableString from openlp.core.lib import Receiver from openlp.core.utils import AppLocation -from openlp.plugins.bibles.lib.common import BibleCommon, SearchResults, \ - unescape +from openlp.plugins.bibles.lib.common import BibleCommon, SearchResults from openlp.plugins.bibles.lib.db import BibleDB, Book log = logging.getLogger(__name__) @@ -205,63 +204,15 @@ class BGExtract(BibleCommon): Receiver.send_message(u'openlp_process_events') soup = BeautifulSoup(page) Receiver.send_message(u'openlp_process_events') - verses = soup.find(u'div', u'result-text-style-normal') - verse_number = 0 - verse_list = {0: u''} - # http://www.codinghorror.com/blog/2009/11/parsing-html-the-cthulhu-way.html - # This is a PERFECT example of opening the Cthulu tag! - # O Bible Gateway, why doth ye such horrific HTML produce? + text = str(soup.find(u'div', u'result-text-style-normal')) + useful_soup = BeautifulSoup(text) + verses = useful_soup.findAll(u'p') + verses.pop(0) + verses.pop() + verse_list = {} for verse in verses: - Receiver.send_message(u'openlp_process_events') - if isinstance(verse, Tag) and verse.name == u'div' and filter(lambda a: a[0] == u'class', verse.attrs)[0][1] == u'footnotes': - break - if isinstance(verse, Tag) and verse.name == u'sup' and filter(lambda a: a[0] == u'class', verse.attrs)[0][1] != u'versenum': - continue - if isinstance(verse, Tag) and verse.name == u'p' and not verse.contents: - continue - if isinstance(verse, Tag) and (verse.name == u'p' or verse.name == u'font') and verse.contents: - for item in verse.contents: - Receiver.send_message(u'openlp_process_events') - if isinstance(item, Tag) and (item.name == u'h4' or item.name == u'h5'): - continue - if isinstance(item, Tag) and item.name == u'sup' and filter(lambda a: a[0] == u'class', item.attrs)[0][1] != u'versenum': - continue - if isinstance(item, Tag) and item.name == u'p' and not item.contents: - continue - if isinstance(item, Tag) and item.name == u'sup': - verse_number = int(str(item.contents[0])) - verse_list[verse_number] = u'' - continue - if isinstance(item, Tag) and item.name == u'font': - for subitem in item.contents: - Receiver.send_message(u'openlp_process_events') - if isinstance(subitem, Tag) and subitem.name == u'sup' and filter(lambda a: a[0] == u'class', subitem.attrs)[0][1] != u'versenum': - continue - if isinstance(subitem, Tag) and subitem.name == u'p' and not subitem.contents: - continue - if isinstance(subitem, Tag) and subitem.name == u'sup': - verse_number = int(str(subitem.contents[0])) - verse_list[verse_number] = u'' - continue - if isinstance(subitem, NavigableString): - verse_list[verse_number] = verse_list[verse_number] + subitem.replace(u' ', u' ') - continue - if isinstance(item, NavigableString): - verse_list[verse_number] = verse_list[verse_number] + item.replace(u' ', u' ') - continue - if isinstance(verse, Tag) and verse.name == u'sup': - verse_number = int(str(verse.contents[0])) - verse_list[verse_number] = u'' - continue - if isinstance(verse, NavigableString): - if not isinstance(verse, unicode): - verse = unicode(verse, u'utf8') - verse_list[verse_number] = verse_list[verse_number] + \ - unescape(verse.replace(u' ', u' ')) - # Delete the "0" element, since we don't need it, it's just there for - # some stupid initial whitespace, courtesy of Bible Gateway. - del verse_list[0] - # Finally, return the list of verses in a "SearchResults" object. + verse_list[int(str(verse.sup.contents[0]))] = \ + unicode(verse.contents[2]) return SearchResults(bookname, chapter, verse_list) class CWExtract(BibleCommon): From 1ea37f8d7708b5448e875bb6f72d5f8cbd4e83a1 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Fri, 23 Jul 2010 16:25:54 +0100 Subject: [PATCH 04/10] Cleanup refactor --- openlp/plugins/bibles/lib/http.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index c1deaccfa..c262a0619 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -207,12 +207,11 @@ class BGExtract(BibleCommon): text = str(soup.find(u'div', u'result-text-style-normal')) useful_soup = BeautifulSoup(text) verses = useful_soup.findAll(u'p') - verses.pop(0) - verses.pop() verse_list = {} for verse in verses: - verse_list[int(str(verse.sup.contents[0]))] = \ - unicode(verse.contents[2]) + if verse.sup: + verse_list[int(str(verse.sup.contents[0]))] = \ + unicode(verse.contents[2]) return SearchResults(bookname, chapter, verse_list) class CWExtract(BibleCommon): From 9b425cb52daea8faaf711f31305e0d5daa1dfe71 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Fri, 23 Jul 2010 17:21:27 +0100 Subject: [PATCH 05/10] Fix BibleGateway refactor --- openlp/plugins/bibles/lib/http.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index c262a0619..80beb179d 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -211,7 +211,7 @@ class BGExtract(BibleCommon): for verse in verses: if verse.sup: verse_list[int(str(verse.sup.contents[0]))] = \ - unicode(verse.contents[2]) + unicode(verse.contents[-1]) return SearchResults(bookname, chapter, verse_list) class CWExtract(BibleCommon): From ccda22a96299dca058886f9576cdd9b969620b5d Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Sat, 24 Jul 2010 02:10:57 +0100 Subject: [PATCH 06/10] Fix BG refactor --- openlp/plugins/bibles/lib/http.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index 80beb179d..94d16b909 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -198,20 +198,20 @@ class BGExtract(BibleCommon): urlstring = u'http://www.biblegateway.com/passage/?search=%s+%s' \ u'&version=%s' % (bookname, chapter, version) log.debug(u'BibleGateway url = %s' % urlstring) - # Let's get the page, and then open it in BeautifulSoup, so as to - # attempt to make "easy" work of bad HTML. page = urllib2.urlopen(urlstring) Receiver.send_message(u'openlp_process_events') soup = BeautifulSoup(page) Receiver.send_message(u'openlp_process_events') - text = str(soup.find(u'div', u'result-text-style-normal')) - useful_soup = BeautifulSoup(text) - verses = useful_soup.findAll(u'p') + content = soup.find(u'div', u'result-text-style-normal') + verse_count = len(soup.findAll(u'sup', u'versenum')) + found_count = 0 verse_list = {} - for verse in verses: - if verse.sup: - verse_list[int(str(verse.sup.contents[0]))] = \ - unicode(verse.contents[-1]) + while found_count < verse_count: + content = content.findNext(u'sup', u'versenum') + raw_verse_num = content.next + raw_verse_text = raw_verse_num.next + verse_list[int(str(raw_verse_num))] = unicode(raw_verse_text) + found_count += 1 return SearchResults(bookname, chapter, verse_list) class CWExtract(BibleCommon): From 323090e141f3d4e5a790b91a37740e23a3d808ea Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Sat, 24 Jul 2010 03:14:08 +0100 Subject: [PATCH 07/10] Bible search fixes (Bug #608409) --- openlp/plugins/bibles/lib/db.py | 7 +++++++ openlp/plugins/bibles/lib/http.py | 8 ++++---- openlp/plugins/bibles/lib/manager.py | 3 +-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index 81255458f..3a4f72bcb 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -305,6 +305,13 @@ class BibleDB(QtCore.QObject, Manager): Book.abbreviation.like(book + u'%')) return db_book + def get_books(self): + """ + A wrapper so both local and web bibles have a get_books() method that + manager can call. Used in the media manager advanced search tab. + """ + return self.get_all_objects(Book, order_by_ref=Book.id) + def get_verses(self, reference_list): """ This is probably the most used function. It retrieves the list of diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index 94d16b909..b8df6ff41 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -135,10 +135,10 @@ class HTTPBooks(object): u'verses FROM chapters WHERE book_id = ?', (book[u'id'],)) if chapters: return { - u'id': chapters[chapter][0], - u'book_id': chapters[chapter][1], - u'chapter': chapters[chapter][2], - u'verses': chapters[chapter][3] + u'id': chapters[chapter-1][0], + u'book_id': chapters[chapter-1][1], + u'chapter': chapters[chapter-1][2], + u'verses': chapters[chapter-1][3] } else: return None diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index a252c2632..a01ddc665 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -198,8 +198,7 @@ class BibleManager(object): u'name': book.name, u'chapters': self.db_cache[bible].get_chapter_count(book.name) } - for book in self.db_cache[bible].get_all_objects(Book, - order_by_ref=Book.id) + for book in self.db_cache[bible].get_books() ] def get_chapter_count(self, bible, book): From 8004bc4c186d55a855951f0dca576852db18fdb0 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Sat, 24 Jul 2010 03:19:24 +0100 Subject: [PATCH 08/10] Import fix for last commit --- openlp/plugins/bibles/lib/manager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index a01ddc665..a458c1b2c 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -29,7 +29,7 @@ from PyQt4 import QtCore from openlp.core.lib import SettingsManager from openlp.core.utils import AppLocation -from openlp.plugins.bibles.lib.db import BibleDB, Book, BibleMeta +from openlp.plugins.bibles.lib.db import BibleDB, BibleMeta from common import parse_reference from opensong import OpenSongBible From 7df342ff1adf0d80621c3468d213d600026a9379 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Sat, 24 Jul 2010 21:52:37 +0100 Subject: [PATCH 09/10] Fix bible search strictness for web bibles --- openlp/plugins/bibles/lib/http.py | 1 + 1 file changed, 1 insertion(+) diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index 255ba229f..81243bfd1 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -104,6 +104,7 @@ class HTTPBooks(object): """ if not isinstance(name, unicode): name = unicode(name) + name = name.title() books = HTTPBooks.run_sql(u'SELECT id, testament_id, name, ' u'abbreviation, chapters FROM books WHERE name = ? OR ' u'abbreviation = ?', (name, name)) From 69ffb9124e739dae0dfa311526602e0e4d5a9c41 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Sun, 25 Jul 2010 00:12:36 +0100 Subject: [PATCH 10/10] Fix some pesky bits --- openlp/plugins/bibles/lib/http.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index 81243bfd1..aad92871f 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -204,10 +204,15 @@ class BGExtract(BibleCommon): u'http://www.biblegateway.com/passage/?%s' % url_params) log.debug(u'BibleGateway url = %s' % page.geturl()) Receiver.send_message(u'openlp_process_events') - soup = BeautifulSoup(page) + cleaner = [(re.compile(' |
'), lambda match: '')] + soup = BeautifulSoup(page, markupMassage=cleaner) Receiver.send_message(u'openlp_process_events') - content = soup.find(u'div', u'result-text-style-normal') - verse_count = len(soup.findAll(u'sup', u'versenum')) + footnotes = soup.findAll(u'sup', u'footnote') + [footnote.extract() for footnote in footnotes] + cleanup = [(re.compile('\s+'), lambda match: ' ')] + verses = BeautifulSoup(str(soup), markupMassage=cleanup) + content = verses.find(u'div', u'result-text-style-normal') + verse_count = len(verses.findAll(u'sup', u'versenum')) found_count = 0 verse_list = {} while found_count < verse_count: