openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #02724
[Merge] lp:~meths/openlp/trivialfixes into lp:openlp
Jon Tibble has proposed merging lp:~meths/openlp/trivialfixes into lp:openlp.
Requested reviews:
Tim Bentley (trb143)
Cleanups:
* Remove wildcard import
* Remove unnecessary getters and setters
* Refactor BibleGateway retrieval
--
https://code.launchpad.net/~meths/openlp/trivialfixes/+merge/30848
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/core/lib/settingsmanager.py'
--- openlp/core/lib/settingsmanager.py 2010-07-06 20:05:48 +0000
+++ openlp/core/lib/settingsmanager.py 2010-07-24 02:24:49 +0000
@@ -57,34 +57,6 @@
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 @@
else:
# no filtering required
return files
-
=== modified file 'openlp/core/ui/mainwindow.py'
--- openlp/core/ui/mainwindow.py 2010-07-22 20:01:03 +0000
+++ openlp/core/ui/mainwindow.py 2010-07-24 02:24:49 +0000
@@ -307,18 +307,18 @@
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')
@@ -894,7 +894,8 @@
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):
@@ -908,7 +909,8 @@
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):
=== modified file 'openlp/core/utils/languagemanager.py'
--- openlp/core/utils/languagemanager.py 2010-06-29 07:07:03 +0000
+++ openlp/core/utils/languagemanager.py 2010-07-24 02:24:49 +0000
@@ -143,4 +143,3 @@
if LanguageManager.__qmList__ is None:
LanguageManager.init_qm_list()
return LanguageManager.__qmList__
-
=== modified file 'openlp/plugins/bibles/lib/common.py'
--- openlp/plugins/bibles/lib/common.py 2010-06-09 17:09:32 +0000
+++ openlp/plugins/bibles/lib/common.py 2010-07-24 02:24:49 +0000
@@ -138,24 +138,6 @@
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 @@
pass
return text # leave as is
return re.sub(u'&#?\w+;', fixup, text)
-
=== modified file 'openlp/plugins/bibles/lib/db.py'
--- openlp/plugins/bibles/lib/db.py 2010-07-08 12:38:48 +0000
+++ openlp/plugins/bibles/lib/db.py 2010-07-24 02:24:49 +0000
@@ -305,6 +305,13 @@
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
=== modified file 'openlp/plugins/bibles/lib/http.py'
--- openlp/plugins/bibles/lib/http.py 2010-06-19 11:53:20 +0000
+++ openlp/plugins/bibles/lib/http.py 2010-07-24 02:24:49 +0000
@@ -29,12 +29,11 @@
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__)
@@ -136,10 +135,10 @@
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
@@ -178,7 +177,6 @@
"""
Extract verses from BibleGateway
"""
-
def __init__(self, proxyurl=None):
log.debug(u'init %s', proxyurl)
self.proxyurl = proxyurl
@@ -200,76 +198,26 @@
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')
- 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.
+ content = soup.find(u'div', u'result-text-style-normal')
+ verse_count = len(soup.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
@@ -429,13 +377,12 @@
## 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 +434,3 @@
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
=== modified file 'openlp/plugins/bibles/lib/manager.py'
--- openlp/plugins/bibles/lib/manager.py 2010-07-18 23:37:24 +0000
+++ openlp/plugins/bibles/lib/manager.py 2010-07-24 02:24:49 +0000
@@ -29,7 +29,7 @@
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
@@ -148,7 +148,7 @@
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')
@@ -198,8 +198,7 @@
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):
=== modified file 'openlp/plugins/presentations/presentationplugin.py'
--- openlp/plugins/presentations/presentationplugin.py 2010-07-23 11:17:18 +0000
+++ openlp/plugins/presentations/presentationplugin.py 2010-07-24 02:24:49 +0000
@@ -31,7 +31,8 @@
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__)
=== modified file 'openlp/plugins/songs/lib/songxml.py'
--- openlp/plugins/songs/lib/songxml.py 2010-07-19 20:43:02 +0000
+++ openlp/plugins/songs/lib/songxml.py 2010-07-24 02:24:49 +0000
@@ -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 @@
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 @@
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 @@
"""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 @@
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 @@
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
Follow ups