Fix: wrong variable names caused osis and http bible imports to crash

Fix: handle unicode in song search string generation
Fix: replaced tab indentation
regenerate search_lyrics on song reindex action

bzr-revno: 1149
This commit is contained in:
Meinert Jordan 2010-12-17 18:55:53 +00:00 committed by Tim Bentley
commit 176d4fbc2a
6 changed files with 15 additions and 10 deletions

View File

@ -138,6 +138,6 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog):
if re.search(r'[/\\]openlp[/\\]', line):
source = re.sub(r'.*[/\\]openlp[/\\](.*)".*', r'\1', line)
if u':' in line:
exception = line.split(u'\n')[-1].split(u':')[0]
exception = line.split(u'\n')[-1].split(u':')[0]
subject = u'Bug report: %s in %s' % (exception, source)
mailto(address=u'bugs@openlp.org', subject=subject, body=body % content)

View File

@ -350,7 +350,7 @@ class HTTPBible(BibleDB):
Run the import. This method overrides the parent class method. Returns
``True`` on success, ``False`` on failure.
"""
self.wizard.ImportProgressBar.setMaximum(2)
self.wizard.importProgressBar.setMaximum(2)
self.wizard.incrementProgressBar('Registering bible...')
self.create_meta(u'download source', self.download_source)
self.create_meta(u'download name', self.download_name)

View File

@ -134,9 +134,9 @@ class OSISBible(BibleDB):
testament)
if last_chapter == 0:
if book == u'Gen':
self.wizard.ImportProgressBar.setMaximum(1188)
self.wizard.importProgressBar.setMaximum(1188)
else:
self.wizard.ImportProgressBar.setMaximum(260)
self.wizard.importProgressBar.setMaximum(260)
if last_chapter != chapter:
if last_chapter != 0:
self.session.commit()

View File

@ -108,6 +108,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
self.TopicsListView.setSortingEnabled(False)
self.TopicsListView.setAlternatingRowColors(True)
self.findVerseSplit = re.compile(u'---\[\]---\n', re.UNICODE)
self.whitespace = re.compile(r'\W+', re.UNICODE)
def initialise(self):
self.VerseEditButton.setEnabled(False)
@ -738,7 +739,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
verseId = unicode(item.data(QtCore.Qt.UserRole).toString())
bits = verseId.split(u':')
sxml.add_verse_to_lyrics(bits[0], bits[1], unicode(item.text()))
text = text + re.sub(r'\W+', u' ',
text = text + whitespace.sub(u' ',
unicode(self.VerseListWidget.item(i, 0).text())) + u' '
if (bits[1] > u'1') and (bits[0][0] not in multiple):
multiple.append(bits[0][0])

View File

@ -247,7 +247,7 @@ class SongImport(QtCore.QObject):
"""
Extracts alphanumeric words for searchable fields
"""
return re.sub(r'\W+', u' ', text)
return re.sub(r'\W+', u' ', text, re.UNICODE)
def finish(self):
"""

View File

@ -31,7 +31,7 @@ from PyQt4 import QtCore, QtGui
from openlp.core.lib import Plugin, StringContent, build_icon, translate
from openlp.core.lib.db import Manager
from openlp.plugins.songs.lib import SongMediaItem, SongsTab
from openlp.plugins.songs.lib import SongMediaItem, SongsTab, SongXMLParser
from openlp.plugins.songs.lib.db import init_schema, Song
from openlp.plugins.songs.lib.importer import SongFormat
@ -150,9 +150,13 @@ class SongsPlugin(Plugin):
song.title = u''
if song.alternate_title is None:
song.alternate_title = u''
song.search_title = self.whitespace.sub(u' ', \
song.title.lower()) + u' ' + \
self.whitespace.sub(u' ', song.alternate_title.lower())
song.search_title = self.whitespace.sub(u' ', song.title.lower() + \
u' ' + song.alternate_title.lower())
lyrics = u''
verses = SongXMLParser(song.lyrics).get_verses()
for verse in verses:
lyrics = lyrics + self.whitespace.sub(u' ', verse[1]) + u' '
song.search_lyrics = lyrics.lower()
progressDialog.setValue(counter)
self.manager.save_objects(songs)
counter += 1