From 364de1af86d950f2a35ef17653d7d987d4b0f926 Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Wed, 1 Jun 2011 23:47:42 +0100 Subject: [PATCH 01/12] aphrostrophe fix for song searching --- openlp/core/lib/mediamanageritem.py | 2 +- openlp/plugins/songs/lib/__init__.py | 22 +++++++++++++++++----- openlp/plugins/songs/lib/mediaitem.py | 20 +++++++++++--------- 3 files changed, 29 insertions(+), 15 deletions(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 602b3c55b..d74ea04b0 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -91,7 +91,7 @@ class MediaManagerItem(QtGui.QWidget): Constructor to create the media manager item. """ QtGui.QWidget.__init__(self, parent) - self.whitespace = re.compile(r'\W+', re.UNICODE) + self.whitespace = re.compile(r'[\W_]+', re.UNICODE) self.plugin = plugin visible_title = self.plugin.getString(StringContent.VisibleName) self.title = unicode(visible_title[u'title']) diff --git a/openlp/plugins/songs/lib/__init__.py b/openlp/plugins/songs/lib/__init__.py index 53b3d7cb1..323db9fe4 100644 --- a/openlp/plugins/songs/lib/__init__.py +++ b/openlp/plugins/songs/lib/__init__.py @@ -32,6 +32,8 @@ from openlp.core.lib import translate from db import Author from ui import SongStrings +WHITESPACE = re.compile(r'[\W_]+', re.UNICODE) + class VerseType(object): """ VerseType provides an enumeration for the tags that may be associated @@ -246,6 +248,12 @@ def retrieve_windows_encoding(recommendation=None): return None return filter(lambda item: item[1] == choice[0], encodings)[0][0] +def clean_string(string): + """ + Strips punctuation from the passed string to assist searching + """ + return WHITESPACE.sub(u' ', string.replace(u'\'', u'')).lower() + def clean_song(manager, song): """ Cleans the search title, rebuilds the search lyrics, adds a default author @@ -262,9 +270,8 @@ def clean_song(manager, song): if song.alternate_title is None: song.alternate_title = u'' song.alternate_title = song.alternate_title.strip() - whitespace = re.compile(r'\W+', re.UNICODE) - song.search_title = (whitespace.sub(u' ', song.title).strip() + u'@' + - whitespace.sub(u' ', song.alternate_title).strip()).strip().lower() + song.search_title = clean_string(song.title) + u'@' + \ + clean_string(song.alternate_title) # Only do this, if we the song is a 1.9.4 song (or older). if song.lyrics.find(u'') != -1: # Remove the old "language" attribute from lyrics tag (prior to 1.9.5). @@ -273,8 +280,8 @@ def clean_song(manager, song): song.lyrics = song.lyrics.replace( u'', u'') verses = SongXML().get_verses(song.lyrics) - lyrics = u' '.join([whitespace.sub(u' ', verse[1]) for verse in verses]) - song.search_lyrics = lyrics.lower() + song.search_lyrics = u' '.join([clean_string(verse[1]) + for verse in verses]) # We need a new and clean SongXML instance. sxml = SongXML() # Rebuild the song's verses, to remove any wrong verse names (for @@ -316,6 +323,11 @@ def clean_song(manager, song): if order not in compare_order: song.verse_order = u'' break + else: + verses = SongXML().get_verses(song.lyrics) + song.search_lyrics = u' '.join([clean_string(verse[1]) + for verse in verses]) + # The song does not have any author, add one. if not song.authors: name = SongStrings.AuthorUnknown diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index b24fbf64a..df9b6a41f 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -38,7 +38,8 @@ from openlp.core.lib.searchedit import SearchEdit from openlp.core.lib.ui import UiStrings from openlp.plugins.songs.forms import EditSongForm, SongMaintenanceForm, \ SongImportForm, SongExportForm -from openlp.plugins.songs.lib import OpenLyrics, SongXML, VerseType +from openlp.plugins.songs.lib import OpenLyrics, SongXML, VerseType, \ + clean_string from openlp.plugins.songs.lib.db import Author, Song from openlp.plugins.songs.lib.ui import SongStrings @@ -181,13 +182,14 @@ class SongMediaItem(MediaManagerItem): elif search_type == SongSearch.Titles: log.debug(u'Titles Search') search_results = self.plugin.manager.get_all_objects(Song, - Song.search_title.like(u'%' + self.whitespace.sub(u' ', - search_keywords.lower()) + u'%')) + Song.search_title.like(u'%' + clean_string(search_keywords) + + u'%')) self.displayResultsSong(search_results) elif search_type == SongSearch.Lyrics: log.debug(u'Lyrics Search') search_results = self.plugin.manager.get_all_objects(Song, - Song.search_lyrics.like(u'%' + search_keywords.lower() + u'%')) + Song.search_lyrics.like(u'%' + clean_string(search_keywords) + + u'%')) self.displayResultsSong(search_results) elif search_type == SongSearch.Authors: log.debug(u'Authors Search') @@ -198,16 +200,16 @@ class SongMediaItem(MediaManagerItem): elif search_type == SongSearch.Themes: log.debug(u'Theme Search') search_results = self.plugin.manager.get_all_objects(Song, - Song.theme_name.like(u'%' + self.whitespace.sub(u' ', - search_keywords) + u'%')) + Song.theme_name.like(u'%' + search_keywords + u'%')) self.displayResultsSong(search_results) self.check_search_result() def searchEntire(self, search_keywords): return self.plugin.manager.get_all_objects(Song, - or_(Song.search_title.like(u'%' + self.whitespace.sub(u' ', - search_keywords.lower()) + u'%'), - Song.search_lyrics.like(u'%' + search_keywords.lower() + u'%'), + or_(Song.search_title.like(u'%' + clean_string(search_keywords) + + u'%'), + Song.search_lyrics.like(u'%' + clean_string(search_keywords) + + u'%'), Song.comments.like(u'%' + search_keywords.lower() + u'%'))) def onSongListLoad(self): From d4031a62d367c18e2d176d3464585ebb7f66c049 Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Thu, 2 Jun 2011 22:13:32 +0100 Subject: [PATCH 02/12] More apostrophes --- openlp/plugins/songs/lib/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openlp/plugins/songs/lib/__init__.py b/openlp/plugins/songs/lib/__init__.py index 323db9fe4..05e402776 100644 --- a/openlp/plugins/songs/lib/__init__.py +++ b/openlp/plugins/songs/lib/__init__.py @@ -33,6 +33,7 @@ from db import Author from ui import SongStrings WHITESPACE = re.compile(r'[\W_]+', re.UNICODE) +APOSTROPHE = re.compile(u'[\'`’ʻ′]', re.UNICODE) class VerseType(object): """ @@ -252,7 +253,7 @@ def clean_string(string): """ Strips punctuation from the passed string to assist searching """ - return WHITESPACE.sub(u' ', string.replace(u'\'', u'')).lower() + return WHITESPACE.sub(u' ', APOSTROPHE.sub(u'', string)).lower() def clean_song(manager, song): """ From 937cfd22607bda61a4c1bdb56004c21b96c8b972 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Sat, 4 Jun 2011 20:43:59 +0200 Subject: [PATCH 03/12] Fix Bug #792811 - Traceback UnicodeEncodeError while importing a webbible If upgrade fails new bible databases now should be deleted always --- .../plugins/bibles/forms/bibleupgradeform.py | 5 ++--- openlp/plugins/bibles/lib/http.py | 8 +++++--- .../bibles/resources/bibles_resources.sqlite | Bin 104448 -> 104448 bytes 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index 524ad4435..fc5ea1e54 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -586,8 +586,6 @@ class BibleUpgradeForm(OpenLPWizard): if not meta[u'key'] == u'Version': self.newbibles[number].create_meta(meta[u'key'], meta[u'value']) - else: - self.newbibles[number].create_meta(meta[u'key'], name) if meta[u'key'] == u'download source': webbible = True include_webbible = True @@ -626,7 +624,7 @@ class BibleUpgradeForm(OpenLPWizard): bible = BiblesResourcesDB.get_webbible( meta_data[u'download name'], meta_data[u'download source'].lower()) - if bible[u'language_id']: + if bible and bible[u'language_id']: language_id = bible[u'language_id'] self.newbibles[number].create_meta(u'language_id', language_id) @@ -744,6 +742,7 @@ class BibleUpgradeForm(OpenLPWizard): Receiver.send_message(u'openlp_process_events') self.newbibles[number].session.commit() if not bible_failed: + self.newbibles[number].create_meta(u'Version', name) self.incrementProgressBar(unicode(translate( 'BiblesPlugin.UpgradeWizardForm', 'Upgrading Bible %s of %s: "%s"\n' diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index edb111d93..fdf8c2def 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -199,9 +199,10 @@ class BSExtract(object): """ log.debug(u'BSExtract.get_bible_chapter("%s", "%s", "%s")', version, bookname, chapter) + urlversion = urllib.quote(version.encode("utf-8")) urlbookname = urllib.quote(bookname.encode("utf-8")) - chapter_url = u'http://m.bibleserver.com/text/%s/%s%s' % \ - (version, urlbookname, chapter) + chapter_url = u'http://m.bibleserver.com/text/%s/%s%d' % \ + (urlversion, urlbookname, chapter) header = (u'Accept-Language', u'en') soup = get_soup_for_bible_ref(chapter_url, header) if not soup: @@ -230,8 +231,9 @@ class BSExtract(object): The version of the Bible like NIV for New International Version """ log.debug(u'BSExtract.get_books_from_http("%s")', version) + urlversion = urllib.quote(version.encode("utf-8")) chapter_url = u'http://m.bibleserver.com/overlay/selectBook?'\ - 'translation=%s' % (version) + 'translation=%s' % (urlversion) soup = get_soup_for_bible_ref(chapter_url) if not soup: return None diff --git a/openlp/plugins/bibles/resources/bibles_resources.sqlite b/openlp/plugins/bibles/resources/bibles_resources.sqlite index 9336918f2d187da2a2e0a96819dfc2ceda31dabe..3235c95629f3d00cde01ef172cf7727e3edd4670 100644 GIT binary patch delta 82 zcmV-Y0ImOkum*sz29O&8;;|ft3kIJe0|Q9`lk0LGv&IWP;2aDAd=vw@1Cj%214sh; o0?PuL0$&0L0qOy}0erI|1Y7|FJb@pR)#*3{+yE#8v%Bp@s$c&b#sB~S delta 67 zcmV-J0KETzum*sz29O&8;jtWs3kIGd0|Q9`lk0LGv&IWP;2H}7yA%Vt1Cj%214sh; Z0?PuL0$&0L0qOy}vmpeX0kga9MXCd47f}EJ From 522e68c38cb2ada41cae934585a4c4cc0f649a65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Sat, 4 Jun 2011 21:34:36 +0200 Subject: [PATCH 04/12] Biblegateway.com has changed it's Bible-Book-List Layout. Addapt the regex for importing booklist of a bible from biblegateway changed log usage --- openlp/plugins/bibles/lib/http.py | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index fdf8c2def..76a99ea50 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -109,7 +109,7 @@ class BGExtract(object): try: clean_verse_num = int(str(raw_verse_num)) except ValueError: - log.exception(u'Illegal verse number in %s %s %s:%s', + log.warn(u'Illegal verse number in %s %s %s:%s', version, bookname, chapter, unicode(raw_verse_num)) if clean_verse_num: verse_text = raw_verse_num.next @@ -139,16 +139,17 @@ class BGExtract(object): """ log.debug(u'BGExtract.get_books_from_http("%s")', version) url_params = urllib.urlencode( - {u'search': 'Bible-List', u'version': u'%s' % version}) - reference_url = u'http://www.biblegateway.com/passage/?%s' % url_params + {u'action': 'getVersionInfo', u'vid': u'%s' % version}) + reference_url = u'http://www.biblegateway.com/versions/?%s#books' % \ + url_params page = get_web_page(reference_url) if not page: send_error_message(u'download') return None page_source = page.read() page_source = unicode(page_source, 'utf8') - page_source_temp = re.search(u'.*?
', \ - page_source, re.DOTALL) + page_source_temp = re.search(u'.*?'\ + u'
', page_source, re.DOTALL) if page_source_temp: soup = page_source_temp.group(0) else: @@ -156,15 +157,17 @@ class BGExtract(object): try: soup = BeautifulSoup(soup) except HTMLParseError: - log.exception(u'BeautifulSoup could not parse the Bible page.') + log.error(u'BeautifulSoup could not parse the Bible page.') + send_error_message(u'parse') + return None if not soup: send_error_message(u'parse') return None Receiver.send_message(u'openlp_process_events') - content = soup.find(u'table', {u'id': u'booklist'}) + content = soup.find(u'table', {u'class': u'infotable'}) content = content.findAll(u'tr') if not content: - log.exception(u'No books found in the Biblegateway response.') + log.error(u'No books found in the Biblegateway response.') send_error_message(u'parse') return None books = [] @@ -210,7 +213,7 @@ class BSExtract(object): Receiver.send_message(u'openlp_process_events') content = soup.find(u'div', u'content') if not content: - log.exception(u'No verses found in the Bibleserver response.') + log.error(u'No verses found in the Bibleserver response.') send_error_message(u'parse') return None content = content.find(u'div').findAll(u'div') @@ -239,7 +242,7 @@ class BSExtract(object): return None content = soup.find(u'ul') if not content: - log.exception(u'No books found in the Bibleserver response.') + log.error(u'No books found in the Bibleserver response.') send_error_message(u'parse') return None content = content.findAll(u'li') @@ -283,7 +286,7 @@ class CWExtract(object): Receiver.send_message(u'openlp_process_events') htmlverses = soup.findAll(u'span', u'versetext') if not htmlverses: - log.debug(u'No verses found in the CrossWalk response.') + log.error(u'No verses found in the CrossWalk response.') send_error_message(u'parse') return None verses = {} @@ -335,7 +338,7 @@ class CWExtract(object): content = soup.find(u'div', {u'class': u'Body'}) content = content.find(u'ul', {u'class': u'parent'}) if not content: - log.exception(u'No books found in the Crosswalk response.') + log.error(u'No books found in the Crosswalk response.') send_error_message(u'parse') return None content = content.findAll(u'li') From 52bab3e4155ba234a54221df5ba22d5f663c26f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Sat, 4 Jun 2011 22:35:24 +0200 Subject: [PATCH 05/12] Fix right parent for all used dialogs small fixes --- .../plugins/bibles/forms/bibleupgradeform.py | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index fc5ea1e54..bbd6c1d20 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -68,6 +68,7 @@ class BibleUpgradeForm(OpenLPWizard): """ self.manager = manager self.mediaItem = bibleplugin.mediaItem + self.plugin = bibleplugin self.suffix = u'.sqlite' self.settingsSection = u'bibles' self.path = AppLocation.get_section_data_path( @@ -578,12 +579,14 @@ class BibleUpgradeForm(OpenLPWizard): name = unicode(self.versionNameEdit[biblenumber].text()) self.newbibles[number] = BibleDB(self.mediaItem, path=self.path, name=name) + self.newbibles[number].register(self.plugin.upgrade_wizard) metadata = oldbible.get_metadata() webbible = False meta_data = {} for meta in metadata: meta_data[meta[u'key']] = meta[u'value'] - if not meta[u'key'] == u'Version': + if not meta[u'key'] == u'Version' and not meta[u'key'] == \ + u'dbversion': self.newbibles[number].create_meta(meta[u'key'], meta[u'value']) if meta[u'key'] == u'download source': @@ -605,7 +608,7 @@ class BibleUpgradeForm(OpenLPWizard): meta_data[u'download source'], meta_data[u'download name'])) delete_database(self.path, - clean_filename(self.newbibles[number].get_name())) + clean_filename(name)) del self.newbibles[number] critical_error_message_box( translate('BiblesPlugin.UpgradeWizardForm', @@ -633,7 +636,7 @@ class BibleUpgradeForm(OpenLPWizard): if not language_id: log.warn(u'Upgrading from "%s" failed' % filename[0]) delete_database(self.path, - clean_filename(self.newbibles[number].get_name())) + clean_filename(name)) del self.newbibles[number] self.incrementProgressBar(unicode(translate( 'BiblesPlugin.UpgradeWizardForm', @@ -659,8 +662,7 @@ class BibleUpgradeForm(OpenLPWizard): u'name: "%s" aborted by user' % ( meta_data[u'download source'], meta_data[u'download name'])) - delete_database(self.path, - clean_filename(self.newbibles[number].get_name())) + delete_database(self.path, clean_filename(name)) del self.newbibles[number] bible_failed = True break @@ -691,8 +693,7 @@ class BibleUpgradeForm(OpenLPWizard): language_id = self.newbibles[number].get_language(name) if not language_id: log.warn(u'Upgrading books from "%s" failed' % name) - delete_database(self.path, - clean_filename(self.newbibles[number].get_name())) + delete_database(self.path, clean_filename(name)) del self.newbibles[number] self.incrementProgressBar(unicode(translate( 'BiblesPlugin.UpgradeWizardForm', @@ -718,8 +719,7 @@ class BibleUpgradeForm(OpenLPWizard): if not book_ref_id: log.warn(u'Upgrading books from %s " '\ 'failed - aborted by user' % name) - delete_database(self.path, - clean_filename(self.newbibles[number].get_name())) + delete_database(self.path, clean_filename(name)) del self.newbibles[number] bible_failed = True break @@ -755,8 +755,7 @@ class BibleUpgradeForm(OpenLPWizard): 'Upgrading Bible %s of %s: "%s"\nFailed')) % (number + 1, self.maxBibles, name), self.progressBar.maximum() - self.progressBar.value()) - delete_database(self.path, - clean_filename(name)) + delete_database(self.path, clean_filename(name)) number += 1 self.mediaItem.reloadBibles() successful_import = 0 From 346bf2426749360fcb831cf7da45cfdae67f4cd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Sun, 5 Jun 2011 14:40:26 +0200 Subject: [PATCH 06/12] changed behaviour if the user cancel the import so that after a traceback it is possible to cancel the dialog --- .../plugins/bibles/forms/bibleupgradeform.py | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index bbd6c1d20..f776c3e5d 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -116,6 +116,8 @@ class BibleUpgradeForm(OpenLPWizard): self.stop_import_flag = True if not self.currentPage() == self.progressPage: self.done(QtGui.QDialog.Rejected) + else: + self.postWizard() def onCurrentIdChanged(self, pageId): """ @@ -132,9 +134,7 @@ class BibleUpgradeForm(OpenLPWizard): """ Some cleanup while finishing """ - for number, filename in enumerate(self.files): - if number in self.success and self.success[number] == True: - delete_file(os.path.join(self.path, filename[0])) + self.mediaItem.reloadBibles() def onBackupBrowseButtonClicked(self): """ @@ -537,7 +537,7 @@ class BibleUpgradeForm(OpenLPWizard): """ Perform the actual upgrade. """ - include_webbible = False + self.include_webbible = False proxy_server = None if self.maxBibles == 0: self.progressLabel.setText( @@ -591,7 +591,7 @@ class BibleUpgradeForm(OpenLPWizard): meta[u'value']) if meta[u'key'] == u'download source': webbible = True - include_webbible = True + self.include_webbible = True if meta.has_key(u'proxy server'): proxy_server = meta[u'proxy server'] if webbible: @@ -607,8 +607,7 @@ class BibleUpgradeForm(OpenLPWizard): u'name: "%s" failed' % ( meta_data[u'download source'], meta_data[u'download name'])) - delete_database(self.path, - clean_filename(name)) + delete_database(self.path, clean_filename(name)) del self.newbibles[number] critical_error_message_box( translate('BiblesPlugin.UpgradeWizardForm', @@ -635,8 +634,7 @@ class BibleUpgradeForm(OpenLPWizard): language_id = self.newbibles[number].get_language(name) if not language_id: log.warn(u'Upgrading from "%s" failed' % filename[0]) - delete_database(self.path, - clean_filename(name)) + delete_database(self.path, clean_filename(name)) del self.newbibles[number] self.incrementProgressBar(unicode(translate( 'BiblesPlugin.UpgradeWizardForm', @@ -743,6 +741,7 @@ class BibleUpgradeForm(OpenLPWizard): self.newbibles[number].session.commit() if not bible_failed: self.newbibles[number].create_meta(u'Version', name) + delete_file(os.path.join(self.path, filename[0])) self.incrementProgressBar(unicode(translate( 'BiblesPlugin.UpgradeWizardForm', 'Upgrading Bible %s of %s: "%s"\n' @@ -757,7 +756,11 @@ class BibleUpgradeForm(OpenLPWizard): self.progressBar.maximum() - self.progressBar.value()) delete_database(self.path, clean_filename(name)) number += 1 - self.mediaItem.reloadBibles() + + def postWizard(self): + """ + Clean up the UI after the import has finished. + """ successful_import = 0 failed_import = 0 for number, filename in enumerate(self.files): @@ -772,7 +775,7 @@ class BibleUpgradeForm(OpenLPWizard): else: failed_import_text = u'' if successful_import > 0: - if include_webbible: + if self.include_webbible: self.progressLabel.setText(unicode( translate('BiblesPlugin.UpgradeWizardForm', 'Upgrading ' 'Bible(s): %s successful%s\nPlease note, that verses from ' @@ -788,3 +791,4 @@ class BibleUpgradeForm(OpenLPWizard): self.progressLabel.setText( translate('BiblesPlugin.UpgradeWizardForm', 'Upgrade ' 'failed.')) + OpenLPWizard.postWizard(self) From 1b2956a9e6ba629d3ac50e3f08af841dd44cd29a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Sun, 5 Jun 2011 19:33:46 +0200 Subject: [PATCH 07/12] remove unnecessary code --- openlp/plugins/bibles/forms/bibleupgradeform.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index f776c3e5d..b7a4c3853 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -130,12 +130,6 @@ class BibleUpgradeForm(OpenLPWizard): elif self.page(pageId) == self.selectPage and self.maxBibles == 0: self.next() - def onFinishButton(self): - """ - Some cleanup while finishing - """ - self.mediaItem.reloadBibles() - def onBackupBrowseButtonClicked(self): """ Show the file open dialog for the OSIS file. @@ -181,8 +175,6 @@ class BibleUpgradeForm(OpenLPWizard): """ Set up the signals used in the bible importer. """ - QtCore.QObject.connect(self.finishButton, - QtCore.SIGNAL(u'clicked()'), self.onFinishButton) QtCore.QObject.connect(self.backupBrowseButton, QtCore.SIGNAL(u'clicked()'), self.onBackupBrowseButtonClicked) QtCore.QObject.connect(self.noBackupCheckBox, From c85e953d4e774d6341fbff79d7e1305296b6bad2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Sun, 5 Jun 2011 19:39:13 +0200 Subject: [PATCH 08/12] remove unnecessary code --- openlp/plugins/bibles/forms/bibleupgradeform.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index b7a4c3853..7913aac31 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -68,7 +68,6 @@ class BibleUpgradeForm(OpenLPWizard): """ self.manager = manager self.mediaItem = bibleplugin.mediaItem - self.plugin = bibleplugin self.suffix = u'.sqlite' self.settingsSection = u'bibles' self.path = AppLocation.get_section_data_path( From 5505644176fa66c35d81364710bdf50057a4c6a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Sun, 5 Jun 2011 20:19:44 +0200 Subject: [PATCH 09/12] Fix Bug #793091 - if plugin changed status from inactive to active plugin.appStartup is called --- openlp/core/ui/pluginform.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/openlp/core/ui/pluginform.py b/openlp/core/ui/pluginform.py index c93b08ccb..37c6c8d63 100644 --- a/openlp/core/ui/pluginform.py +++ b/openlp/core/ui/pluginform.py @@ -132,6 +132,9 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog): Receiver.send_message(u'cursor_busy') self.activePlugin.toggleStatus(PluginStatus.Active) Receiver.send_message(u'cursor_normal') + if hasattr(self.activePlugin, u'appStartup'): + Receiver.send_message(u'openlp_process_events') + self.activePlugin.appStartup() else: self.activePlugin.toggleStatus(PluginStatus.Inactive) status_text = unicode( From 17209fcc293dd99cce386241d6c9a87a2f43ae42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Sun, 5 Jun 2011 20:46:00 +0200 Subject: [PATCH 10/12] define appStartup() in plugin.py remove hassattr(plugin, appStartup) --- openlp/core/lib/plugin.py | 6 ++++++ openlp/core/ui/mainwindow.py | 2 +- openlp/core/ui/pluginform.py | 4 +--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index 65ed76dfe..910c52d2c 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -300,6 +300,12 @@ class Plugin(QtCore.QObject): if self.mediaItem: self.mediadock.remove_dock(self.mediaItem) + def appStartup(self): + """ + Perform tasks on application starup + """ + pass + def usesTheme(self, theme): """ Called to find out if a plugin is currently using a theme. diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index bacbff073..b4a3b3640 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -655,7 +655,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): # Give all the plugins a chance to perform some tasks at startup Receiver.send_message(u'openlp_process_events') for plugin in self.pluginManager.plugins: - if plugin.isActive() and hasattr(plugin, u'appStartup'): + if plugin.isActive(): Receiver.send_message(u'openlp_process_events') plugin.appStartup() Receiver.send_message(u'openlp_process_events') diff --git a/openlp/core/ui/pluginform.py b/openlp/core/ui/pluginform.py index 37c6c8d63..b4c87488c 100644 --- a/openlp/core/ui/pluginform.py +++ b/openlp/core/ui/pluginform.py @@ -132,9 +132,7 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog): Receiver.send_message(u'cursor_busy') self.activePlugin.toggleStatus(PluginStatus.Active) Receiver.send_message(u'cursor_normal') - if hasattr(self.activePlugin, u'appStartup'): - Receiver.send_message(u'openlp_process_events') - self.activePlugin.appStartup() + self.activePlugin.appStartup() else: self.activePlugin.toggleStatus(PluginStatus.Inactive) status_text = unicode( From b5810b271ef25f7459762d786ce86b00b8b3614c Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 6 Jun 2011 08:03:06 +0200 Subject: [PATCH 11/12] fixed bug #788770 --- openlp/plugins/bibles/lib/mediaitem.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index bd84e2bb5..d94368f52 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -772,7 +772,7 @@ class BibleMediaItem(MediaManagerItem): log.exception(u'The second_search_results does not have as ' 'many verses as the search_results.') break - bible_text = u' %s %d%s%d (%s, %s)' % (verse.book.name, + bible_text = u'%s %d%s%d (%s, %s)' % (verse.book.name, verse.chapter, verse_separator, verse.verse, version, second_version) else: @@ -830,7 +830,7 @@ class BibleMediaItem(MediaManagerItem): bible_text = u'' # If we are 'Verse Per Line' then force a new line. elif self.settings.layout_style == LayoutStyle.VersePerLine: - bible_text = u'%s %s %s\n' % (bible_text, verse_text, text) + bible_text = u'%s%s %s\n' % (bible_text, verse_text, text) # We have to be 'Continuous'. else: bible_text = u'%s %s %s\n' % (bible_text, verse_text, text) From 6047dd9f5b75b98bb000c7125d95dd9a6acc63ab Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 6 Jun 2011 16:17:39 +0200 Subject: [PATCH 12/12] fixed bug 793537 Fixes: https://launchpad.net/bugs/793537 --- openlp/core/ui/screen.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/screen.py b/openlp/core/ui/screen.py index 160080c5a..b970158b2 100644 --- a/openlp/core/ui/screen.py +++ b/openlp/core/ui/screen.py @@ -106,7 +106,7 @@ class ScreenList(object): """ # Do not log at start up. if changed_screen != -1: - log.info(u'screen_count_changed %d' % number) + log.info(u'screen_count_changed %d' % self.desktop.numScreens()) # Remove unplugged screens. for screen in copy.deepcopy(self.screen_list): if screen[u'number'] == self.desktop.numScreens():