From 74752da6948f0350c305e7a2010851af6761f7b0 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 30 Sep 2010 20:40:10 +0200 Subject: [PATCH 01/11] implemented 'text search' for bibles --- openlp/plugins/bibles/lib/db.py | 8 ++++---- openlp/plugins/bibles/lib/manager.py | 22 +++++++++++++++++++++- openlp/plugins/bibles/lib/mediaitem.py | 20 +++++++++++++------- 3 files changed, 38 insertions(+), 12 deletions(-) diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index 49bc82102..ca7fcfda7 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -240,7 +240,7 @@ class BibleDB(QtCore.QObject, Manager): and the value is the verse text. """ log.debug(u'create_chapter %s,%s', book_id, chapter) - #text list has book and chapter as first two elements of the array + # text list has book and chapter as first two elements of the array for verse_number, verse_text in textlist.iteritems(): verse = Verse.populate( book_id = book_id, @@ -353,9 +353,9 @@ class BibleDB(QtCore.QObject, Manager): QtGui.QMessageBox.information(self.bible_plugin.mediaItem, translate('BiblesPlugin.BibleDB', 'Book not found'), translate('BiblesPlugin.BibleDB', 'The book you requested ' - 'could not be found in this bible. Please check your ' - 'spelling and that this is a complete bible not just ' - 'one testament.')) + 'could not be found in this bible. Please check your ' + 'spelling and that this is a complete bible not just ' + 'one testament.')) return verse_list def verse_search(self, text): diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index fd2c2adff..4a5869ca6 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -254,9 +254,29 @@ class BibleManager(object): 'Book Chapter:Verse-Verse\n' 'Book Chapter:Verse-Verse,Verse-Verse\n' 'Book Chapter:Verse-Verse,Chapter:Verse-Verse\n' - 'Book Chapter:Verse-Chapter:Verse\n')) + 'Book Chapter:Verse-Chapter:Verse')) return None + def verse_search(self, bible, text): + """ + ``bible`` + The bible to seach in. + + ``text`` + The text to search for. + """ + log.debug(u'BibleManager.verse_search("%s", "%s")', bible, text) + if text: + return self.db_cache[bible].verse_search(text) + else: + QtGui.QMessageBox.information(self.parent.mediaItem, + translate('BiblesPlugin.BibleManager', + 'Scripture Reference Error'), + translate('BiblesPlugin.BibleManager', 'Your scripture ' + 'reference is not valid. Make sure to state a keyword to search' + ' for. Keywords separated by a comma will be treated as OR.')) + return None + def save_meta_data(self, bible, version, copyright, permissions): """ Saves the bibles meta data diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 92eb200ee..fe0e7409c 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -535,10 +535,19 @@ class BibleMediaItem(MediaManagerItem): bible = unicode(self.QuickVersionComboBox.currentText()) dual_bible = unicode(self.QuickSecondBibleComboBox.currentText()) text = unicode(self.QuickSearchEdit.text()) - self.search_results = self.parent.manager.get_verses(bible, text) - if dual_bible: - self.dual_search_results = self.parent.manager.get_verses( - dual_bible, text) + if self.QuickSearchComboBox.currentIndex() == 0: # Verse Search + self.search_results = self.parent.manager.get_verses(bible, text) + if dual_bible: + self.dual_search_results = self.parent.manager.get_verses( + dual_bible, text) + else: # Text Search + self.search_results = self.parent.manager.verse_search(bible, text) + if dual_bible: + for count, verse in enumerate(self.search_results): + text = u'%s %s:%s' % (verse.book.name, verse.chapter, + verse.verse) + self.dual_search_results[count] = self.parent.manager.\ + get_verses(dual_bible, text)[0] if self.ClearQuickSearchComboBox.currentIndex() == 0: self.listView.clear() if self.listView.count() != 0 and self.search_results: @@ -702,19 +711,16 @@ class BibleMediaItem(MediaManagerItem): if bible_text: raw_slides.append(bible_text) bible_text = u'' - # Service Item: Capabilities if self.parent.settings_tab.layout_style == 2 and not dual_bible: # Split the line but do not replace line breaks in renderer. service_item.add_capability(ItemCapabilities.NoLineBreaks) service_item.add_capability(ItemCapabilities.AllowsPreview) service_item.add_capability(ItemCapabilities.AllowsLoop) - # Service Item: Title for title in raw_title: if not service_item.title: service_item.title = title else: service_item.title += u', ' + title - # Service Item: Theme if len(self.parent.settings_tab.bible_theme) == 0: service_item.theme = None else: From e17f6c7c9ed37d1f1c580dd9ae02d02560836572 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Fri, 1 Oct 2010 15:50:29 +0200 Subject: [PATCH 02/11] -disable search buttons while searching, -clean ups --- openlp/plugins/bibles/lib/__init__.py | 2 +- openlp/plugins/bibles/lib/db.py | 26 +++++++++++++------------- openlp/plugins/bibles/lib/manager.py | 12 ++++++------ openlp/plugins/bibles/lib/mediaitem.py | 20 +++++++++++++++----- 4 files changed, 35 insertions(+), 25 deletions(-) diff --git a/openlp/plugins/bibles/lib/__init__.py b/openlp/plugins/bibles/lib/__init__.py index 06f9d7cc7..e3f0d8f46 100644 --- a/openlp/plugins/bibles/lib/__init__.py +++ b/openlp/plugins/bibles/lib/__init__.py @@ -75,7 +75,7 @@ def parse_reference(reference): 7 None|[0-9]+|end None or the end of the second verse range. The reference list is a list of tuples, with each tuple structured like - this:: + this: (book, chapter, start_verse, end_verse) ``reference`` diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index ca7fcfda7..6f947cb87 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -281,23 +281,23 @@ class BibleDB(QtCore.QObject, Manager): def create_meta(self, key, value): """ - Utility method to save BibleMeta objects in a Bible database + Utility method to save BibleMeta objects in a Bible database. ``key`` - The key for this instance + The key for this instance. ``value`` - The value for this instance + The value for this instance. """ log.debug(u'save_meta %s/%s', key, value) self.save_object(BibleMeta.populate(key=key, value=value)) def get_book(self, book): """ - Return a book object from the database + Return a book object from the database. ``book`` - The name of the book to return + The name of the book to return. """ log.debug(u'BibleDb.get_book("%s")', book) db_book = self.get_object_filtered(Book, Book.name.like(book + u'%')) @@ -320,14 +320,14 @@ class BibleDB(QtCore.QObject, Manager): ``reference_list`` This is the list of references the media manager item wants. It is - a list of tuples, with the following format:: + a list of tuples, with the following format: (book, chapter, start_verse, end_verse) Therefore, when you are looking for multiple items, simply break them up into references like this, bundle them into a list. This function then runs through the list, and returns an amalgamated - list of ``Verse`` objects. For example:: + list of ``Verse`` objects. For example: [(u'Genesis', 1, 1, 1), (u'Genesis', 2, 2, 3)] """ @@ -387,10 +387,10 @@ class BibleDB(QtCore.QObject, Manager): def get_chapter_count(self, book): """ - Return the number of chapters in a book + Return the number of chapters in a book. ``book`` - The book to get the chapter count for + The book to get the chapter count for. """ log.debug(u'BibleDB.get_chapter_count("%s")', book) count = self.session.query(Verse.chapter).join(Book)\ @@ -403,13 +403,13 @@ class BibleDB(QtCore.QObject, Manager): def get_verse_count(self, book, chapter): """ - Return the number of verses in a chapter + Return the number of verses in a chapter. ``book`` - The book containing the chapter + The book containing the chapter. ``chapter`` - The chapter to get the verse count for + The chapter to get the verse count for. """ log.debug(u'BibleDB.get_verse_count("%s", %s)', book, chapter) count = self.session.query(Verse).join(Book)\ @@ -423,7 +423,7 @@ class BibleDB(QtCore.QObject, Manager): def dump_bible(self): """ - Utility debugging method to dump the contents of a bible + Utility debugging method to dump the contents of a bible. """ log.debug(u'.........Dumping Bible Database') log.debug('...............................Books ') diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index 4a5869ca6..78d8e770a 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -137,7 +137,7 @@ class BibleManager(object): name = bible.get_name() log.debug(u'Bible Name: "%s"', name) self.db_cache[name] = bible - # look to see if lazy load bible exists and get create getter. + # Look to see if lazy load bible exists and get create getter. source = self.db_cache[name].get_object(BibleMeta, u'download source') if source: @@ -204,7 +204,7 @@ class BibleManager(object): def get_chapter_count(self, bible, book): """ - Returns the number of Chapters for a given book + Returns the number of Chapters for a given book. """ log.debug(u'get_book_chapter_count %s', book) return self.db_cache[bible].get_chapter_count(book) @@ -212,7 +212,7 @@ class BibleManager(object): def get_verse_count(self, bible, book, chapter): """ Returns all the number of verses for a given - book and chapterMaxBibleBookVerses + book and chapterMaxBibleBookVerses. """ log.debug(u'BibleManager.get_verse_count("%s", "%s", %s)', bible, book, chapter) @@ -279,7 +279,7 @@ class BibleManager(object): def save_meta_data(self, bible, version, copyright, permissions): """ - Saves the bibles meta data + Saves the bibles meta data. """ log.debug(u'save_meta data %s,%s, %s,%s', bible, version, copyright, permissions) @@ -289,14 +289,14 @@ class BibleManager(object): def get_meta_data(self, bible, key): """ - Returns the meta data for a given key + Returns the meta data for a given key. """ log.debug(u'get_meta %s,%s', bible, key) return self.db_cache[bible].get_object(BibleMeta, key) def exists(self, name): """ - Check cache to see if new bible + Check cache to see if new bible. """ if not isinstance(name, unicode): name = unicode(name) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index fe0e7409c..ab39665f8 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -497,6 +497,7 @@ class BibleMediaItem(MediaManagerItem): def onAdvancedSearchButton(self): log.debug(u'Advanced Search Button pressed') + self.AdvancedSearchButton.setEnabled(False) bible = unicode(self.AdvancedVersionComboBox.currentText()) dual_bible = unicode(self.AdvancedSecondBibleComboBox.currentText()) book = unicode(self.AdvancedBookComboBox.currentText()) @@ -529,9 +530,11 @@ class BibleMediaItem(MediaManagerItem): self.displayResults(bible, dual_bible) else: self.displayResults(bible, dual_bible) + self.AdvancedSearchButton.setEnabled(True) def onQuickSearchButton(self): log.debug(u'Quick Search Button pressed') + self.QuickSearchButton.setEnabled(False) bible = unicode(self.QuickVersionComboBox.currentText()) dual_bible = unicode(self.QuickSecondBibleComboBox.currentText()) text = unicode(self.QuickSearchEdit.text()) @@ -543,11 +546,17 @@ class BibleMediaItem(MediaManagerItem): else: # Text Search self.search_results = self.parent.manager.verse_search(bible, text) if dual_bible: - for count, verse in enumerate(self.search_results): - text = u'%s %s:%s' % (verse.book.name, verse.chapter, - verse.verse) - self.dual_search_results[count] = self.parent.manager.\ - get_verses(dual_bible, text)[0] + text = [] + for verse in self.search_results: + text.append((verse.book.name, verse.chapter, verse.verse, + verse.verse)) + self.dual_search_results = self.parent.manager.get_verses( + dual_bible, text) +# for count, verse in enumerate(self.search_results): +# text = u'%s %s:%s' % (verse.book.name, verse.chapter, +# verse.verse) +# self.dual_search_results[count] = self.parent.manager.\ +# get_verses(dual_bible, text)[0] if self.ClearQuickSearchComboBox.currentIndex() == 0: self.listView.clear() if self.listView.count() != 0 and self.search_results: @@ -567,6 +576,7 @@ class BibleMediaItem(MediaManagerItem): self.displayResults(bible, dual_bible) elif self.search_results: self.displayResults(bible, dual_bible) + self.QuickSearchButton.setEnabled(True) def displayResults(self, bible, dual_bible=u''): """ From 919b07bd61f07d5569f05154f58234c2cb0c2e4f Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Fri, 1 Oct 2010 16:18:15 +0200 Subject: [PATCH 03/11] clean ups --- openlp/plugins/bibles/lib/db.py | 6 +++--- openlp/plugins/bibles/lib/http.py | 18 +++++++++--------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index 6f947cb87..60b9a8836 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -4,7 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # # --------------------------------------------------------------------------- # -# Copyright (c) 2008-2010 Raoul Snyman # +# Copyright (c) 2008-2010 Raoul Snyman + # # Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael # # Gorven, Scott Guerrieri, Meinert Jordan, Andreas Preikschat, Christian # # Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon Tibble, # @@ -64,10 +64,10 @@ class Verse(BaseModel): def init_schema(url): """ - Setup a bible database connection and initialise the database schema + Setup a bible database connection and initialise the database schema. ``url`` - The database to setup + The database to setup. """ session, metadata = init_db(url) diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index 415a0cde5..8abb3e62f 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -187,16 +187,16 @@ class BGExtract(object): def get_bible_chapter(self, version, bookname, chapter): """ - Access and decode bibles via the BibleGateway website + Access and decode bibles via the BibleGateway website. ``version`` - The version of the bible like 31 for New International version + The version of the bible like 31 for New International version. ``bookname`` - Name of the Book + Name of the Book. ``chapter`` - Chapter number + Chapter number. """ log.debug(u'get_bible_chapter %s, %s, %s', version, bookname, chapter) url_params = urllib.urlencode( @@ -298,13 +298,13 @@ class CWExtract(object): versetext = versetext + part elif part and part.attrMap and \ (part.attrMap[u'class'] == u'WordsOfChrist' or \ - part.attrMap[u'class'] == u'strongs'): + part.attrMap[u'class'] == u'strongs'): for subpart in part.contents: Receiver.send_message(u'openlp_process_events') if isinstance(subpart, NavigableString): versetext = versetext + subpart elif subpart and subpart.attrMap and \ - subpart.attrMap[u'class'] == u'strongs': + subpart.attrMap[u'class'] == u'strongs': for subsub in subpart.contents: Receiver.send_message(u'openlp_process_events') if isinstance(subsub, NavigableString): @@ -382,14 +382,14 @@ class HTTPBible(BibleDB): ``reference_list`` This is the list of references the media manager item wants. It is - a list of tuples, with the following format:: + a list of tuples, with the following format: (book, chapter, start_verse, end_verse) Therefore, when you are looking for multiple items, simply break them up into references like this, bundle them into a list. This function then runs through the list, and returns an amalgamated - list of ``Verse`` objects. For example:: + list of ``Verse`` objects. For example: [(u'Genesis', 1, 1, 1), (u'Genesis', 2, 2, 3)] """ @@ -428,7 +428,7 @@ class HTTPBible(BibleDB): def get_chapter(self, book, chapter): """ - Receive the request and call the relevant handler methods + Receive the request and call the relevant handler methods. """ log.debug(u'get_chapter %s, %s', book, chapter) log.debug(u'source = %s', self.download_source) From f8ed4acf78fa6168008762525f229f8119bfb0df Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Fri, 1 Oct 2010 16:37:51 +0200 Subject: [PATCH 04/11] clean ups --- openlp/plugins/bibles/lib/mediaitem.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index ab39665f8..94519ba88 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -540,23 +540,23 @@ class BibleMediaItem(MediaManagerItem): text = unicode(self.QuickSearchEdit.text()) if self.QuickSearchComboBox.currentIndex() == 0: # Verse Search self.search_results = self.parent.manager.get_verses(bible, text) - if dual_bible: + if dual_bible and self.search_results: self.dual_search_results = self.parent.manager.get_verses( dual_bible, text) else: # Text Search self.search_results = self.parent.manager.verse_search(bible, text) - if dual_bible: - text = [] - for verse in self.search_results: - text.append((verse.book.name, verse.chapter, verse.verse, - verse.verse)) - self.dual_search_results = self.parent.manager.get_verses( - dual_bible, text) -# for count, verse in enumerate(self.search_results): -# text = u'%s %s:%s' % (verse.book.name, verse.chapter, -# verse.verse) -# self.dual_search_results[count] = self.parent.manager.\ -# get_verses(dual_bible, text)[0] + if dual_bible and self.search_results: +# text = [] +# for verse in self.search_results: +# text.append((verse.book.name, verse.chapter, verse.verse, +# verse.verse)) +# self.dual_search_results = self.parent.manager.get_verses( +# dual_bible, text) + for count, verse in enumerate(self.search_results): + text = u'%s %s:%s' % (verse.book.name, verse.chapter, + verse.verse) + self.dual_search_results[count] = self.parent.manager.\ + get_verses(dual_bible, text)[0] if self.ClearQuickSearchComboBox.currentIndex() == 0: self.listView.clear() if self.listView.count() != 0 and self.search_results: From f515dc60d0e9567294490b8256d6d450e8ba629c Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 6 Oct 2010 16:15:39 +0200 Subject: [PATCH 05/11] changed methods (call the db methods instead of the manager's methods) --- openlp/plugins/bibles/lib/manager.py | 48 ++++++++++++-------------- openlp/plugins/bibles/lib/mediaitem.py | 22 +++++------- 2 files changed, 31 insertions(+), 39 deletions(-) diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index 12d673d9b..09d3b3e8e 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -181,10 +181,10 @@ class BibleManager(object): def get_bibles(self): """ - Returns a list of the names of available Bibles. + Returns a dict with all available Bibles. """ log.debug(u'get_bibles') - return self.db_cache.keys() + return self.db_cache def get_books(self, bible): """ @@ -238,10 +238,6 @@ class BibleManager(object): - Genesis 1:1-10,2:1-10 """ log.debug(u'BibleManager.get_verses("%s", "%s")', bible, versetext) -# if type(versetext) is list: -# reflist = versetext -# else: -# reflist = parse_reference(versetext) reflist = parse_reference(versetext) if reflist: return self.db_cache[bible].get_verses(reflist) @@ -261,26 +257,26 @@ class BibleManager(object): 'Book Chapter:Verse-Chapter:Verse')) return None - def verse_search(self, bible, text): - """ - ``bible`` - The bible to seach in. - - ``text`` - The text to search for. - """ - log.debug(u'BibleManager.verse_search("%s", "%s")', bible, text) - if text: - return self.db_cache[bible].verse_search(text) - else: - QtGui.QMessageBox.information(self.parent.mediaItem, - translate('BiblesPlugin.BibleManager', - 'Scripture Reference Error'), - translate('BiblesPlugin.BibleManager', 'You did not enter a ' - 'search keyword.\nYou can seperate different keywords by a space' - ' to search for all of your keywords and can seperate them by a' - ' comma to search for one of them.')) - return None +# def verse_search(self, bible, text): +# """ +# ``bible`` +# The bible to seach in. +# +# ``text`` +# The text to search for. +# """ +# log.debug(u'BibleManager.verse_search("%s", "%s")', bible, text) +# if text: +# return self.db_cache[bible].verse_search(text) +# else: +# QtGui.QMessageBox.information(self.parent.mediaItem, +# translate('BiblesPlugin.BibleManager', +# 'Scripture Reference Error'), +# translate('BiblesPlugin.BibleManager', 'You did not enter a ' +# 'search keyword.\nYou can seperate different keywords by a space' +# ' to search for all of your keywords and can seperate them by a' +# ' comma to search for one of them.')) +# return None def save_meta_data(self, bible, version, copyright, permissions): """ diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 3b94c399f..70d3fb97d 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -32,6 +32,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import MediaManagerItem, Receiver, BaseListWithDnD, \ ItemCapabilities, translate from openlp.plugins.bibles.forms import ImportWizardForm +from openlp.plugins.bibles.lib.db import BibleDB log = logging.getLogger(__name__) @@ -374,7 +375,7 @@ class BibleMediaItem(MediaManagerItem): self.AdvancedSecondBibleComboBox.clear() self.QuickSecondBibleComboBox.addItem(u'') self.AdvancedSecondBibleComboBox.addItem(u'') - bibles = self.parent.manager.get_bibles() + bibles = self.parent.manager.get_bibles().keys() # load bibles into the combo boxes first = True for bible in bibles: @@ -544,19 +545,14 @@ class BibleMediaItem(MediaManagerItem): self.dual_search_results = self.parent.manager.get_verses( dual_bible, text) else: # Text Search - self.search_results = self.parent.manager.verse_search(bible, text) + bibles = self.parent.manager.get_bibles() + self.search_results = bibles[bible].verse_search(text) if dual_bible and self.search_results: -# text = [] -# for verse in self.search_results: -# text.append((verse.book.name, verse.chapter, verse.verse, -# verse.verse)) -# self.dual_search_results = self.parent.manager.get_verses( -# dual_bible, text) - for count, verse in enumerate(self.search_results): - text = u'%s %s:%s' % (verse.book.name, verse.chapter, - verse.verse) - self.dual_search_results[count] = self.parent.manager.\ - get_verses(dual_bible, text, text)[0] + text = [] + for verse in self.search_results: + text.append((verse.book.name, verse.chapter, verse.verse, + verse.verse)) + self.dual_search_results = bibles[dual_bible].get_verses(text) if self.ClearQuickSearchComboBox.currentIndex() == 0: self.listView.clear() if self.listView.count() != 0 and self.search_results: From 59b387b9d06ae4136099e8094d88c093d6d99639 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 6 Oct 2010 16:57:38 +0200 Subject: [PATCH 06/11] replaced 'permission' with permissions since the db uses permissions --- openlp/plugins/bibles/forms/bibleimportwizard.py | 16 ++++++++-------- openlp/plugins/bibles/forms/importwizardform.py | 12 ++++++------ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/openlp/plugins/bibles/forms/bibleimportwizard.py b/openlp/plugins/bibles/forms/bibleimportwizard.py index d64fce261..304e9fb0f 100644 --- a/openlp/plugins/bibles/forms/bibleimportwizard.py +++ b/openlp/plugins/bibles/forms/bibleimportwizard.py @@ -275,14 +275,14 @@ class Ui_BibleImportWizard(object): self.CopyrightEdit.setObjectName(u'CopyrightEdit') self.LicenseDetailsLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.CopyrightEdit) - self.PermissionLabel = QtGui.QLabel(self.LicenseDetailsPage) - self.PermissionLabel.setObjectName(u'PermissionLabel') + self.PermissionsLabel = QtGui.QLabel(self.LicenseDetailsPage) + self.PermissionsLabel.setObjectName(u'PermissionsLabel') self.LicenseDetailsLayout.setWidget(2, QtGui.QFormLayout.LabelRole, - self.PermissionLabel) - self.PermissionEdit = QtGui.QLineEdit(self.LicenseDetailsPage) - self.PermissionEdit.setObjectName(u'PermissionEdit') + self.PermissionsLabel) + self.PermissionsEdit = QtGui.QLineEdit(self.LicenseDetailsPage) + self.PermissionsEdit.setObjectName(u'PermissionsEdit') self.LicenseDetailsLayout.setWidget(2, QtGui.QFormLayout.FieldRole, - self.PermissionEdit) + self.PermissionsEdit) BibleImportWizard.addPage(self.LicenseDetailsPage) self.ImportPage = QtGui.QWizardPage() self.ImportPage.setObjectName(u'ImportPage') @@ -372,8 +372,8 @@ class Ui_BibleImportWizard(object): translate('BiblesPlugin.ImportWizardForm', 'Version name:')) self.CopyrightLabel.setText( translate('BiblesPlugin.ImportWizardForm', 'Copyright:')) - self.PermissionLabel.setText( - translate('BiblesPlugin.ImportWizardForm', 'Permission:')) + self.PermissionsLabel.setText( + translate('BiblesPlugin.ImportWizardForm', 'Permissions:')) self.ImportPage.setTitle( translate('BiblesPlugin.ImportWizardForm', 'Importing')) self.ImportPage.setSubTitle( diff --git a/openlp/plugins/bibles/forms/importwizardform.py b/openlp/plugins/bibles/forms/importwizardform.py index 3b2611e8f..3a20130eb 100644 --- a/openlp/plugins/bibles/forms/importwizardform.py +++ b/openlp/plugins/bibles/forms/importwizardform.py @@ -282,7 +282,7 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard): self.LicenseDetailsPage.registerField( u'license_copyright', self.CopyrightEdit) self.LicenseDetailsPage.registerField( - u'license_permission', self.PermissionEdit) + u'license_permissions', self.PermissionsEdit) def setDefaults(self): settings = QtCore.QSettings() @@ -308,8 +308,8 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard): QtCore.QVariant(self.VersionNameEdit.text())) self.setField(u'license_copyright', QtCore.QVariant(self.CopyrightEdit.text())) - self.setField(u'license_permission', - QtCore.QVariant(self.PermissionEdit.text())) + self.setField(u'license_permissions', + QtCore.QVariant(self.PermissionsEdit.text())) self.onLocationComboBoxChanged(WebDownload.Crosswalk) settings.endGroup() @@ -391,8 +391,8 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard): bible_type = self.field(u'source_format').toInt()[0] license_version = unicode(self.field(u'license_version').toString()) license_copyright = unicode(self.field(u'license_copyright').toString()) - license_permission = \ - unicode(self.field(u'license_permission').toString()) + license_permissions = \ + unicode(self.field(u'license_permissions').toString()) importer = None if bible_type == BibleFormat.OSIS: # Import an OSIS bible @@ -436,7 +436,7 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard): ) if importer.do_import(): self.manager.save_meta_data(license_version, license_version, - license_copyright, license_permission) + license_copyright, license_permissions) self.manager.reload_bibles() self.ImportProgressLabel.setText( translate('BiblesPlugin.ImportWizardForm', 'Finished import.')) From 2e2efab2d488b7737ba971334b444204a0fc5f3d Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Fri, 8 Oct 2010 19:07:14 +0200 Subject: [PATCH 07/11] tweaks --- openlp/plugins/bibles/lib/db.py | 6 ++-- openlp/plugins/bibles/lib/manager.py | 42 +++++++++++++------------- openlp/plugins/bibles/lib/mediaitem.py | 3 +- 3 files changed, 26 insertions(+), 25 deletions(-) diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index 4d90b474c..59eaaef22 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -369,19 +369,19 @@ class BibleDB(QtCore.QObject, Manager): values. """ log.debug(u'BibleDB.verse_search("%s")', text) - verses = self.session.query(Verse) if text.find(u',') > -1: or_clause = [] keywords = [u'%%%s%%' % keyword.strip() for keyword in text.split(u',')] for keyword in keywords: or_clause.append(Verse.text.like(keyword)) - verses = verses.filter(or_(*or_clause)) + verses = self.session.query(Verse).filter(or_(*or_clause)) else: keywords = [u'%%%s%%' % keyword.strip() for keyword in text.split(u' ')] for keyword in keywords: - verses = verses.filter(Verse.text.like(keyword)) + verses = self.session.query(Verse)\ + .filter(Verse.text.like(keyword)) verses = verses.all() return verses diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index 09d3b3e8e..83aacd234 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -257,27 +257,27 @@ class BibleManager(object): 'Book Chapter:Verse-Chapter:Verse')) return None -# def verse_search(self, bible, text): -# """ -# ``bible`` -# The bible to seach in. -# -# ``text`` -# The text to search for. -# """ -# log.debug(u'BibleManager.verse_search("%s", "%s")', bible, text) -# if text: -# return self.db_cache[bible].verse_search(text) -# else: -# QtGui.QMessageBox.information(self.parent.mediaItem, -# translate('BiblesPlugin.BibleManager', -# 'Scripture Reference Error'), -# translate('BiblesPlugin.BibleManager', 'You did not enter a ' -# 'search keyword.\nYou can seperate different keywords by a space' -# ' to search for all of your keywords and can seperate them by a' -# ' comma to search for one of them.')) -# return None - + def verse_search(self, bible, text): + """ + ``bible`` + The bible to seach in. + + ``text`` + The text to search for. + """ + log.debug(u'BibleManager.verse_search("%s", "%s")', bible, text) + if text: + return self.db_cache[bible].verse_search(text) + else: + QtGui.QMessageBox.information(self.parent.mediaItem, + translate('BiblesPlugin.BibleManager', + 'Scripture Reference Error'), + translate('BiblesPlugin.BibleManager', 'You did not enter a ' + 'search keyword.\nYou can seperate different keywords by a ' + 'space to search for all of your keywords and you can seperate ' + 'them by a comma to search for one of them.')) + return None + def save_meta_data(self, bible, version, copyright, permissions): """ Saves the bibles meta data. diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 70d3fb97d..4daa1bc93 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -546,7 +546,8 @@ class BibleMediaItem(MediaManagerItem): dual_bible, text) else: # Text Search bibles = self.parent.manager.get_bibles() - self.search_results = bibles[bible].verse_search(text) + #self.search_results = bibles[bible].verse_search(text) + self.search_results = self.parent.manager.verse_search(bible, text) if dual_bible and self.search_results: text = [] for verse in self.search_results: From 1bf1aeacd44f6aaa309f590a9c1fa5d0550b1cb6 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Fri, 8 Oct 2010 19:37:34 +0200 Subject: [PATCH 08/11] minor fixes for proposal --- openlp/plugins/bibles/lib/mediaitem.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 4daa1bc93..f985c7471 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -539,14 +539,15 @@ class BibleMediaItem(MediaManagerItem): bible = unicode(self.QuickVersionComboBox.currentText()) dual_bible = unicode(self.QuickSecondBibleComboBox.currentText()) text = unicode(self.QuickSearchEdit.text()) - if self.QuickSearchComboBox.currentIndex() == 0: # Verse Search + if self.QuickSearchComboBox.currentIndex() == 0: + # We are doing a 'Verse Search'. self.search_results = self.parent.manager.get_verses(bible, text) if dual_bible and self.search_results: self.dual_search_results = self.parent.manager.get_verses( dual_bible, text) - else: # Text Search + else: + # We are doing a ' Text Search'. bibles = self.parent.manager.get_bibles() - #self.search_results = bibles[bible].verse_search(text) self.search_results = self.parent.manager.verse_search(bible, text) if dual_bible and self.search_results: text = [] @@ -718,16 +719,19 @@ class BibleMediaItem(MediaManagerItem): if bible_text: raw_slides.append(bible_text) bible_text = u'' + # Service Item: Capabilities if self.parent.settings_tab.layout_style == 2 and not dual_bible: # Split the line but do not replace line breaks in renderer. service_item.add_capability(ItemCapabilities.NoLineBreaks) service_item.add_capability(ItemCapabilities.AllowsPreview) service_item.add_capability(ItemCapabilities.AllowsLoop) + # Service Item: Title for title in raw_title: if not service_item.title: service_item.title = title else: service_item.title += u', ' + title + # Service Item: Theme if len(self.parent.settings_tab.bible_theme) == 0: service_item.theme = None else: From ae015a270addeabb4a874e04c8d252df1acb37be Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 9 Oct 2010 08:00:50 +0200 Subject: [PATCH 09/11] added reStructuredText back --- openlp/plugins/bibles/lib/__init__.py | 2 +- openlp/plugins/bibles/lib/db.py | 4 ++-- openlp/plugins/bibles/lib/http.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/openlp/plugins/bibles/lib/__init__.py b/openlp/plugins/bibles/lib/__init__.py index e3f0d8f46..06f9d7cc7 100644 --- a/openlp/plugins/bibles/lib/__init__.py +++ b/openlp/plugins/bibles/lib/__init__.py @@ -75,7 +75,7 @@ def parse_reference(reference): 7 None|[0-9]+|end None or the end of the second verse range. The reference list is a list of tuples, with each tuple structured like - this: + this:: (book, chapter, start_verse, end_verse) ``reference`` diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index 59eaaef22..cca8108a4 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -320,14 +320,14 @@ class BibleDB(QtCore.QObject, Manager): ``reference_list`` This is the list of references the media manager item wants. It is - a list of tuples, with the following format: + a list of tuples, with the following format:: (book, chapter, start_verse, end_verse) Therefore, when you are looking for multiple items, simply break them up into references like this, bundle them into a list. This function then runs through the list, and returns an amalgamated - list of ``Verse`` objects. For example: + list of ``Verse`` objects. For example:: [(u'Genesis', 1, 1, 1), (u'Genesis', 2, 2, 3)] """ diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index 8abb3e62f..327228b6d 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -382,7 +382,7 @@ class HTTPBible(BibleDB): ``reference_list`` This is the list of references the media manager item wants. It is - a list of tuples, with the following format: + a list of tuples, with the following format:: (book, chapter, start_verse, end_verse) From 2ad3f983f7c93684f332dd18e6fde5e53ab9f594 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 9 Oct 2010 08:48:21 +0200 Subject: [PATCH 10/11] added reStructuredText back --- openlp/plugins/bibles/lib/http.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index 327228b6d..18cdb7223 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -389,7 +389,7 @@ class HTTPBible(BibleDB): Therefore, when you are looking for multiple items, simply break them up into references like this, bundle them into a list. This function then runs through the list, and returns an amalgamated - list of ``Verse`` objects. For example: + list of ``Verse`` objects. For example:: [(u'Genesis', 1, 1, 1), (u'Genesis', 2, 2, 3)] """ From 84d0c01274d0acab8326bed8254ceafa0bcf9484 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 9 Oct 2010 21:36:05 +0200 Subject: [PATCH 11/11] fixes for the merge proposal --- openlp/plugins/bibles/lib/db.py | 10 +++++----- openlp/plugins/bibles/lib/manager.py | 8 +++++--- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index cca8108a4..8f5c7dc79 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -353,8 +353,8 @@ class BibleDB(QtCore.QObject, Manager): QtGui.QMessageBox.information(self.bible_plugin.mediaItem, translate('BiblesPlugin.BibleDB', 'Book not found'), translate('BiblesPlugin.BibleDB', 'The book you requested ' - 'could not be found in this bible. Please check your ' - 'spelling and that this is a complete bible not just ' + 'could not be found in this Bible. Please check your ' + 'spelling and that this is a complete Bible not just ' 'one testament.')) return verse_list @@ -369,19 +369,19 @@ class BibleDB(QtCore.QObject, Manager): values. """ log.debug(u'BibleDB.verse_search("%s")', text) + verses = self.session.query(Verse) if text.find(u',') > -1: or_clause = [] keywords = [u'%%%s%%' % keyword.strip() for keyword in text.split(u',')] for keyword in keywords: or_clause.append(Verse.text.like(keyword)) - verses = self.session.query(Verse).filter(or_(*or_clause)) + verses = verses.filter(or_(*or_clause)) else: keywords = [u'%%%s%%' % keyword.strip() for keyword in text.split(u' ')] for keyword in keywords: - verses = self.session.query(Verse)\ - .filter(Verse.text.like(keyword)) + verses = verses.filter(Verse.text.like(keyword)) verses = verses.all() return verses diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index 83aacd234..877331341 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -259,11 +259,13 @@ class BibleManager(object): def verse_search(self, bible, text): """ + Does a verse search for the given bible and text. + ``bible`` - The bible to seach in. + The bible to seach in (unicode). ``text`` - The text to search for. + The text to search for (unicode). """ log.debug(u'BibleManager.verse_search("%s", "%s")', bible, text) if text: @@ -273,7 +275,7 @@ class BibleManager(object): translate('BiblesPlugin.BibleManager', 'Scripture Reference Error'), translate('BiblesPlugin.BibleManager', 'You did not enter a ' - 'search keyword.\nYou can seperate different keywords by a ' + 'search keyword.\nYou can separate different keywords by a ' 'space to search for all of your keywords and you can seperate ' 'them by a comma to search for one of them.')) return None