diff --git a/openlp/core/lib/settingsmanager.py b/openlp/core/lib/settingsmanager.py index 5e1358c84..8d249d2cd 100644 --- a/openlp/core/lib/settingsmanager.py +++ b/openlp/core/lib/settingsmanager.py @@ -58,34 +58,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,4 @@ class SettingsManager(object): if extension == os.path.splitext(filename)[1]] else: # no filtering required - return files \ No newline at end of file + return files diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 5a41d4129..921213f44 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -308,18 +308,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') @@ -914,7 +914,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): @@ -928,7 +929,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 970c105fc..6b939d9b2 100644 --- a/openlp/core/utils/languagemanager.py +++ b/openlp/core/utils/languagemanager.py @@ -143,4 +143,4 @@ class LanguageManager(object): """ if LanguageManager.__qmList__ is None: LanguageManager.init_qm_list() - return LanguageManager.__qmList__ \ No newline at end of file + return LanguageManager.__qmList__ diff --git a/openlp/plugins/bibles/lib/common.py b/openlp/plugins/bibles/lib/common.py index c6818e3f3..cf7d9727a 100644 --- a/openlp/plugins/bibles/lib/common.py +++ b/openlp/plugins/bibles/lib/common.py @@ -139,24 +139,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,4 @@ def unescape(text): except KeyError: pass return text # leave as is - return re.sub(u'&#?\w+;', fixup, text) \ No newline at end of file + return re.sub(u'&#?\w+;', fixup, text) diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index 4c1890f35..49a7fcbef 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -306,6 +306,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 66c8bc571..9d5ef6e5a 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -31,12 +31,11 @@ import sqlite3 import urllib import urllib2 -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__) @@ -106,6 +105,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)) @@ -138,10 +138,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 @@ -180,7 +180,6 @@ class BGExtract(BibleCommon): """ Extract verses from BibleGateway """ - def __init__(self, proxyurl=None): log.debug(u'init %s', proxyurl) self.proxyurl = proxyurl @@ -202,78 +201,33 @@ class BGExtract(BibleCommon): url_params = urllib.urlencode( {u'search': u'%s %s' % (bookname, chapter), u'version': u'%s' % version}) - # 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( 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') - 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? - 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. + 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: + 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): """ Extract verses from CrossWalk/BibleStudyTools """ - def __init__(self, proxyurl=None): log.debug(u'init %s', proxyurl) self.proxyurl = proxyurl @@ -433,13 +387,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') @@ -491,14 +444,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 \ No newline at end of file diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index 6aade2796..e3ea29ebd 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -30,7 +30,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 @@ -149,7 +149,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') @@ -199,8 +199,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): diff --git a/openlp/plugins/bibles/resources/httpbooks.sqlite b/openlp/plugins/bibles/resources/httpbooks.sqlite index a8bcfd11f..4d89d0243 100644 Binary files a/openlp/plugins/bibles/resources/httpbooks.sqlite and b/openlp/plugins/bibles/resources/httpbooks.sqlite differ diff --git a/openlp/plugins/presentations/presentationplugin.py b/openlp/plugins/presentations/presentationplugin.py index f5b72bcd1..e35005a41 100644 --- a/openlp/plugins/presentations/presentationplugin.py +++ b/openlp/plugins/presentations/presentationplugin.py @@ -32,7 +32,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__) diff --git a/openlp/plugins/songs/lib/songxml.py b/openlp/plugins/songs/lib/songxml.py index 2eb0c50f1..ca4489f0b 100644 --- a/openlp/plugins/songs/lib/songxml.py +++ b/openlp/plugins/songs/lib/songxml.py @@ -25,15 +25,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): @@ -71,14 +65,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 @@ -216,8 +203,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): @@ -268,58 +255,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 @@ -370,45 +329,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 @@ -432,11 +352,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