openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #01325
[Merge] lp:~raoul-snyman/openlp/biblefixes into lp:openlp
Raoul Snyman has proposed merging lp:~raoul-snyman/openlp/biblefixes into lp:openlp.
Requested reviews:
OpenLP Core (openlp-core)
Bible fixes:
- Red letter text on CrossWalk import.
- Removed text on web download progress, moved to an "indeterminable" progress style.
- Some unicode optimisations.
--
https://code.launchpad.net/~raoul-snyman/openlp/biblefixes/+merge/22305
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/core/utils/__init__.py'
--- openlp/core/utils/__init__.py 2010-03-27 12:37:21 +0000
+++ openlp/core/utils/__init__.py 2010-03-27 20:12:20 +0000
@@ -29,6 +29,8 @@
import urllib2
from datetime import datetime
+from PyQt4 import QtCore
+
import openlp
log = logging.getLogger(__name__)
@@ -124,16 +126,25 @@
log.exception(u'Reason for failure: %s', e.reason)
return version_string
+def string_to_unicode(string):
+ """
+ Converts a QString to a Python unicode object.
+ """
+ if isinstance(string, QtCore.QString):
+ string = unicode(string.toUtf8(), u'utf8')
+ return string
+
def variant_to_unicode(variant):
"""
- Converts a QVariant to a unicode string.
+ Converts a QVariant to a Python unicode object.
``variant``
The QVariant instance to convert to unicode.
"""
- string = variant.toString()
+ if isinstance(variant, QtCore.QVariant):
+ string = variant.toString()
if not isinstance(string, unicode):
- string = unicode(string, u'utf8')
+ string = string_to_unicode(string)
return string
from registry import Registry
=== modified file 'openlp/plugins/bibles/forms/importwizardform.py'
--- openlp/plugins/bibles/forms/importwizardform.py 2010-03-24 21:18:36 +0000
+++ openlp/plugins/bibles/forms/importwizardform.py 2010-03-27 20:12:20 +0000
@@ -32,7 +32,7 @@
from bibleimportwizard import Ui_BibleImportWizard
from openlp.core.lib import Receiver
-from openlp.core.utils import AppLocation, variant_to_unicode
+from openlp.core.utils import AppLocation, variant_to_unicode, string_to_unicode
from openlp.plugins.bibles.lib.manager import BibleFormat
log = logging.getLogger(__name__)
@@ -425,3 +425,4 @@
self.finishButton.setVisible(True)
self.cancelButton.setVisible(False)
Receiver.send_message(u'process_events')
+
=== modified file 'openlp/plugins/bibles/lib/common.py'
--- openlp/plugins/bibles/lib/common.py 2010-03-21 23:58:01 +0000
+++ openlp/plugins/bibles/lib/common.py 2010-03-27 20:12:20 +0000
@@ -33,7 +33,7 @@
r'(?:[ ]*-[ ]*([0-9]+|end))?(?:[ ]*,[ ]*([0-9]+)(?:[ ]*-[ ]*([0-9]+|end))?)?',
re.UNICODE)
chapter_range = re.compile(r'([\w .]+)[ ]+([0-9]+)[ ]*[:|v|V][ ]*'
- r'([0-9]+)[ ]*-[ ]*([0-9]+)[ ]*[:|v|V][ ]*([0-9]+)',
+ r'([0-9]+|end)[ ]*-[ ]*([0-9]+)[ ]*[:|v|V][ ]*([0-9]+|end)',
re.UNICODE)
log = logging.getLogger(__name__)
=== modified file 'openlp/plugins/bibles/lib/http.py'
--- openlp/plugins/bibles/lib/http.py 2010-03-26 20:50:55 +0000
+++ openlp/plugins/bibles/lib/http.py 2010-03-27 20:12:20 +0000
@@ -203,7 +203,9 @@
# 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'process_events')
soup = BeautifulSoup(page)
+ Receiver.send_message(u'process_events')
verses = soup.find(u'div', u'result-text-style-normal')
verse_number = 0
verse_list = {0: u''}
@@ -211,6 +213,7 @@
# 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'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':
@@ -219,6 +222,7 @@
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'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':
@@ -231,6 +235,7 @@
continue
if isinstance(item, Tag) and item.name == u'font':
for subitem in item.contents:
+ Receiver.send_message(u'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:
@@ -289,27 +294,42 @@
(version, urlbookname.lower(), chapter)
log.debug(u'URL: %s', chapter_url)
page = urllib2.urlopen(chapter_url)
+ Receiver.send_message(u'process_events')
if not page:
return None
soup = BeautifulSoup(page)
+ Receiver.send_message(u'process_events')
htmlverses = soup.findAll(u'span', u'versetext')
verses = {}
reduce_spaces = re.compile(r'[ ]{2,}')
+ fix_punctuation = re.compile(r'[ ]+([.,;])')
for verse in htmlverses:
Receiver.send_message(u'process_events')
versenumber = int(verse.contents[0].contents[0])
versetext = u''
for part in verse.contents:
+ Receiver.send_message(u'process_events')
if isinstance(part, NavigableString):
versetext = versetext + part
elif part and part.attrMap and \
(part.attrMap[u'class'] == u'WordsOfChrist' or \
part.attrMap[u'class'] == u'strongs'):
for subpart in part.contents:
+ Receiver.send_message(u'process_events')
if isinstance(subpart, NavigableString):
versetext = versetext + subpart
+ elif subpart and subpart.attrMap and \
+ subpart.attrMap[u'class'] == u'strongs':
+ for subsub in subpart.contents:
+ Receiver.send_message(u'process_events')
+ if isinstance(subsub, NavigableString):
+ versetext = versetext + subsub
+ Receiver.send_message(u'process_events')
+ # Fix up leading and trailing spaces, multiple spaces, and spaces
+ # between text and , and .
versetext = versetext.strip(u'\n\r\t ')
versetext = reduce_spaces.sub(u' ', versetext)
+ versetext = fix_punctuation.sub(r'\1', versetext)
verses[versenumber] = versetext
return SearchResults(bookname, chapter, verses)
@@ -410,10 +430,12 @@
## we get a correct book. For example it is possible
## to request ac and get Acts back.
bookname = search_results.get_book()
+ Receiver.send_message(u'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())
+ Receiver.send_message(u'process_events')
Receiver.send_message(u'bible_hideprogress')
Receiver.send_message(u'process_events')
return BibleDB.get_verses(self, reference_list)
=== modified file 'openlp/plugins/bibles/lib/mediaitem.py'
--- openlp/plugins/bibles/lib/mediaitem.py 2010-03-24 19:15:25 +0000
+++ openlp/plugins/bibles/lib/mediaitem.py 2010-03-27 20:12:20 +0000
@@ -266,8 +266,9 @@
MediaManagerItem.addListViewToToolBar(self)
# Progress Bar
self.SearchProgress = QtGui.QProgressBar(self)
- self.SearchProgress.setFormat('%p%')
- self.SearchProgress.setMaximum(3)
+ self.SearchProgress.setFormat('')
+ self.SearchProgress.setMinimum(0)
+ self.SearchProgress.setMaximum(0)
self.SearchProgress.setGeometry(self.ListView.geometry().left(),
self.ListView.geometry().top(), 81, 23)
self.SearchProgress.setVisible(False)
@@ -351,9 +352,10 @@
def onSearchProgressShow(self):
self.SearchProgress.setVisible(True)
- self.SearchProgress.setMinimum(0)
- self.SearchProgress.setMaximum(2)
- self.SearchProgress.setValue(1)
+ Receiver.send_message(u'process_events')
+ #self.SearchProgress.setMinimum(0)
+ #self.SearchProgress.setMaximum(2)
+ #self.SearchProgress.setValue(1)
def onSearchProgressHide(self):
self.SearchProgress.setVisible(False)
Follow ups