openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #04113
[Merge] lp:~googol-hush/openlp/bibles into lp:openlp
Andreas Preikschat has proposed merging lp:~googol-hush/openlp/bibles into lp:openlp.
Requested reviews:
Tim Bentley (trb143)
Raoul Snyman (raoul-snyman)
Hello!
- Finished bible "text search" (the search considers all verses which are in the database).
- Comment/doc clean ups.
- Changed "permission" to "permissions" since the database uses "permissions" (changing this is just being consequent).
- Disabled search button while searching.
--
https://code.launchpad.net/~googol-hush/openlp/bibles/+merge/38064
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/plugins/bibles/forms/bibleimportwizard.py'
--- openlp/plugins/bibles/forms/bibleimportwizard.py 2010-09-14 18:18:47 +0000
+++ openlp/plugins/bibles/forms/bibleimportwizard.py 2010-10-09 19:52:42 +0000
@@ -275,14 +275,14 @@
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 @@
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(
=== modified file 'openlp/plugins/bibles/forms/importwizardform.py'
--- openlp/plugins/bibles/forms/importwizardform.py 2010-09-27 18:34:40 +0000
+++ openlp/plugins/bibles/forms/importwizardform.py 2010-10-09 19:52:42 +0000
@@ -282,7 +282,7 @@
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 @@
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 @@
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 @@
)
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.'))
=== modified file 'openlp/plugins/bibles/lib/db.py'
--- openlp/plugins/bibles/lib/db.py 2010-09-14 18:18:47 +0000
+++ openlp/plugins/bibles/lib/db.py 2010-10-09 19:52:42 +0000
@@ -64,10 +64,10 @@
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)
@@ -240,7 +240,7 @@
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,
@@ -281,23 +281,23 @@
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'%'))
@@ -353,9 +353,9 @@
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):
@@ -387,10 +387,10 @@
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 @@
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 @@
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 ')
=== modified file 'openlp/plugins/bibles/lib/http.py'
--- openlp/plugins/bibles/lib/http.py 2010-09-14 18:18:47 +0000
+++ openlp/plugins/bibles/lib/http.py 2010-10-09 19:52:42 +0000
@@ -187,16 +187,16 @@
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 @@
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):
@@ -428,7 +428,7 @@
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)
=== modified file 'openlp/plugins/bibles/lib/manager.py'
--- openlp/plugins/bibles/lib/manager.py 2010-09-19 08:47:00 +0000
+++ openlp/plugins/bibles/lib/manager.py 2010-10-09 19:52:42 +0000
@@ -137,7 +137,7 @@
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:
@@ -181,10 +181,10 @@
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):
"""
@@ -204,7 +204,7 @@
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 @@
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)
@@ -254,12 +254,35 @@
'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):
+ """
+ Does a verse search for the given bible and text.
+
+ ``bible``
+ The bible to seach in (unicode).
+
+ ``text``
+ The text to search for (unicode).
+ """
+ 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 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
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)
@@ -269,14 +292,14 @@
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)
=== modified file 'openlp/plugins/bibles/lib/mediaitem.py'
--- openlp/plugins/bibles/lib/mediaitem.py 2010-10-05 15:26:28 +0000
+++ openlp/plugins/bibles/lib/mediaitem.py 2010-10-09 19:52:42 +0000
@@ -32,6 +32,7 @@
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 @@
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:
@@ -497,6 +498,7 @@
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,16 +531,30 @@
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())
- 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:
+ # 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:
+ # We are doing a ' Text Search'.
+ bibles = self.parent.manager.get_bibles()
+ self.search_results = self.parent.manager.verse_search(bible, 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 = bibles[dual_bible].get_verses(text)
if self.ClearQuickSearchComboBox.currentIndex() == 0:
self.listView.clear()
if self.listView.count() != 0 and self.search_results:
@@ -558,6 +574,7 @@
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''):
"""
@@ -566,16 +583,16 @@
"""
version = self.parent.manager.get_meta_data(bible, u'Version')
copyright = self.parent.manager.get_meta_data(bible, u'Copyright')
- permission = self.parent.manager.get_meta_data(bible, u'Permissions')
+ permissions = self.parent.manager.get_meta_data(bible, u'Permissions')
if dual_bible:
dual_version = self.parent.manager.get_meta_data(dual_bible,
u'Version')
dual_copyright = self.parent.manager.get_meta_data(dual_bible,
u'Copyright')
- dual_permission = self.parent.manager.get_meta_data(dual_bible,
+ dual_permissions = self.parent.manager.get_meta_data(dual_bible,
u'Permissions')
- if not dual_permission:
- dual_permission = u''
+ if not dual_permissions:
+ dual_permissions = u''
# We count the number of rows which are maybe already present.
start_count = self.listView.count()
for count, verse in enumerate(self.search_results):
@@ -587,12 +604,12 @@
'bible': QtCore.QVariant(bible),
'version': QtCore.QVariant(version.value),
'copyright': QtCore.QVariant(copyright.value),
- 'permission': QtCore.QVariant(permission.value),
+ 'permissions': QtCore.QVariant(permissions.value),
'text': QtCore.QVariant(verse.text),
'dual_bible': QtCore.QVariant(dual_bible),
'dual_version': QtCore.QVariant(dual_version.value),
'dual_copyright': QtCore.QVariant(dual_copyright.value),
- 'dual_permission': QtCore.QVariant(dual_permission.value),
+ 'dual_permissions': QtCore.QVariant(dual_permissions.value),
'dual_text': QtCore.QVariant(
self.dual_search_results[count].text)
}
@@ -607,12 +624,12 @@
'bible': QtCore.QVariant(bible),
'version': QtCore.QVariant(version.value),
'copyright': QtCore.QVariant(copyright.value),
- 'permission': QtCore.QVariant(permission.value),
+ 'permissions': QtCore.QVariant(permissions.value),
'text': QtCore.QVariant(verse.text),
'dual_bible': QtCore.QVariant(u''),
'dual_version': QtCore.QVariant(u''),
'dual_copyright': QtCore.QVariant(u''),
- 'dual_permission': QtCore.QVariant(u''),
+ 'dual_permissions': QtCore.QVariant(u''),
'dual_text': QtCore.QVariant(u'')
}
bible_text = u' %s %d:%d (%s)' % (verse.book.name,
@@ -658,20 +675,20 @@
bible = self._decodeQtObject(bitem, 'bible')
version = self._decodeQtObject(bitem, 'version')
copyright = self._decodeQtObject(bitem, 'copyright')
- permission = self._decodeQtObject(bitem, 'permission')
+ permissions = self._decodeQtObject(bitem, 'permissions')
text = self._decodeQtObject(bitem, 'text')
dual_bible = self._decodeQtObject(bitem, 'dual_bible')
dual_version = self._decodeQtObject(bitem, 'dual_version')
dual_copyright = self._decodeQtObject(bitem, 'dual_copyright')
- dual_permission = self._decodeQtObject(bitem, 'dual_permission')
+ dual_permissions = self._decodeQtObject(bitem, 'dual_permissions')
dual_text = self._decodeQtObject(bitem, 'dual_text')
verse_text = self.formatVerse(old_chapter, chapter, verse)
- footer = u'%s (%s %s %s)' % (book, version, copyright, permission)
+ footer = u'%s (%s %s %s)' % (book, version, copyright, permissions)
if footer not in raw_footer:
raw_footer.append(footer)
if dual_bible:
footer = u'%s (%s %s %s)' % (book, dual_version, dual_copyright,
- dual_permission)
+ dual_permissions)
if footer not in raw_footer:
raw_footer.append(footer)
bible_text = u'%s %s\n\n%s %s' % (verse_text, text, verse_text,
Follow ups