forked from openlp/openlp
parent
ccaa1bdf92
commit
0924bfc246
@ -247,7 +247,7 @@ class EventReceiver(QtCore.QObject):
|
||||
``msg``
|
||||
Defaults to *None*. The message to send with the event.
|
||||
"""
|
||||
log.debug(u'Event %s passed with payload %s' % (event, msg))
|
||||
#log.debug(u'Event %s passed with payload %s' % (event, msg))
|
||||
self.emit(QtCore.SIGNAL(event), msg)
|
||||
|
||||
|
||||
|
@ -28,6 +28,7 @@
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
import shutil
|
||||
from tempfile import gettempdir
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
@ -721,11 +722,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||
plugin.firstTime()
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
temp_dir = os.path.join(unicode(gettempdir()), u'openlp')
|
||||
if not os.path.exists(temp_dir):
|
||||
return
|
||||
for filename in os.listdir(temp_dir):
|
||||
delete_file(os.path.join(temp_dir, filename))
|
||||
os.removedirs(temp_dir)
|
||||
shutil.rmtree(temp_dir, True)
|
||||
|
||||
def onFirstTimeWizardClicked(self):
|
||||
"""
|
||||
|
@ -29,6 +29,7 @@ The bible import functions for OpenLP
|
||||
import logging
|
||||
import os
|
||||
import shutil
|
||||
from tempfile import gettempdir
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
@ -124,7 +125,7 @@ class BibleUpgradeForm(OpenLPWizard):
|
||||
self.preWizard()
|
||||
self.performWizard()
|
||||
self.postWizard()
|
||||
elif self.page(pageId) == self.selectPage and self.maxBibles == 0:
|
||||
elif self.page(pageId) == self.selectPage and not self.files:
|
||||
self.next()
|
||||
|
||||
def onBackupBrowseButtonClicked(self):
|
||||
@ -425,9 +426,13 @@ class BibleUpgradeForm(OpenLPWizard):
|
||||
return False
|
||||
return True
|
||||
elif self.currentPage() == self.selectPage:
|
||||
temp_dir = os.path.join(gettempdir(), u'openlp')
|
||||
check_directory_exists(temp_dir)
|
||||
for number, filename in enumerate(self.files):
|
||||
if not self.checkBox[number].checkState() == QtCore.Qt.Checked:
|
||||
continue
|
||||
# Move bibles to temp dir.
|
||||
shutil.move(os.path.join(self.path, filename[0]), temp_dir)
|
||||
version_name = unicode(self.versionNameEdit[number].text())
|
||||
if not version_name:
|
||||
critical_error_message_box(UiStrings().EmptyField,
|
||||
@ -435,37 +440,6 @@ class BibleUpgradeForm(OpenLPWizard):
|
||||
'You need to specify a version name for your Bible.'))
|
||||
self.versionNameEdit[number].setFocus()
|
||||
return False
|
||||
elif self.manager.exists(version_name):
|
||||
critical_error_message_box(
|
||||
translate('BiblesPlugin.UpgradeWizardForm',
|
||||
'Bible Exists'),
|
||||
translate('BiblesPlugin.UpgradeWizardForm',
|
||||
'This Bible already exists. Please upgrade '
|
||||
'a different Bible, delete the existing one or '
|
||||
'uncheck.'))
|
||||
self.versionNameEdit[number].setFocus()
|
||||
return False
|
||||
elif os.path.exists(os.path.join(self.path, clean_filename(
|
||||
version_name))) and version_name == filename[1]:
|
||||
newfilename = u'old_database_%s' % filename[0]
|
||||
if not os.path.exists(os.path.join(self.path,
|
||||
newfilename)):
|
||||
os.rename(os.path.join(self.path, filename[0]),
|
||||
os.path.join(self.path, newfilename))
|
||||
self.files[number] = [newfilename, filename[1]]
|
||||
continue
|
||||
else:
|
||||
critical_error_message_box(
|
||||
translate('BiblesPlugin.UpgradeWizardForm',
|
||||
'Bible Exists'),
|
||||
translate('BiblesPlugin.UpgradeWizardForm',
|
||||
'This Bible already exists. Please upgrade '
|
||||
'a different Bible, delete the existing one or '
|
||||
'uncheck.'))
|
||||
self.verticalWidget[number].show()
|
||||
self.formWidget[number].show()
|
||||
self.versionNameEdit[number].setFocus()
|
||||
return False
|
||||
elif os.path.exists(os.path.join(self.path,
|
||||
clean_filename(version_name))):
|
||||
critical_error_message_box(
|
||||
@ -495,7 +469,6 @@ class BibleUpgradeForm(OpenLPWizard):
|
||||
self.files = self.manager.old_bible_databases
|
||||
self.addScrollArea()
|
||||
self.retranslateUi()
|
||||
self.maxBibles = len(self.files)
|
||||
for number, filename in enumerate(self.files):
|
||||
self.checkBox[number].setCheckState(QtCore.Qt.Checked)
|
||||
oldname = filename[1]
|
||||
@ -516,9 +489,8 @@ class BibleUpgradeForm(OpenLPWizard):
|
||||
Prepare the UI for the upgrade.
|
||||
"""
|
||||
OpenLPWizard.preWizard(self)
|
||||
self.progressLabel.setText(translate(
|
||||
'BiblesPlugin.UpgradeWizardForm',
|
||||
'Starting upgrade...'))
|
||||
self.progressLabel.setText(
|
||||
translate('BiblesPlugin.UpgradeWizardForm', 'Starting upgrade...'))
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
|
||||
def performWizard(self):
|
||||
@ -527,46 +499,47 @@ class BibleUpgradeForm(OpenLPWizard):
|
||||
"""
|
||||
self.include_webbible = False
|
||||
proxy_server = None
|
||||
if self.maxBibles == 0:
|
||||
if not self.files:
|
||||
self.progressLabel.setText(
|
||||
translate('BiblesPlugin.UpgradeWizardForm', 'There are no '
|
||||
'Bibles that need to be upgraded.'))
|
||||
self.progressBar.hide()
|
||||
return
|
||||
self.maxBibles = 0
|
||||
max_bibles = 0
|
||||
for number, file in enumerate(self.files):
|
||||
if self.checkBox[number].checkState() == QtCore.Qt.Checked:
|
||||
self.maxBibles += 1
|
||||
number = 0
|
||||
for biblenumber, filename in enumerate(self.files):
|
||||
max_bibles += 1
|
||||
temp_dir = os.path.join(gettempdir(), u'openlp')
|
||||
for number, filename in enumerate(self.files):
|
||||
if self.stop_import_flag:
|
||||
bible_failed = True
|
||||
break
|
||||
bible_failed = False
|
||||
self.success[biblenumber] = False
|
||||
if not self.checkBox[biblenumber].checkState() == QtCore.Qt.Checked:
|
||||
self.success[number] = False
|
||||
if not self.checkBox[number].checkState() == QtCore.Qt.Checked:
|
||||
continue
|
||||
self.progressBar.reset()
|
||||
oldbible = OldBibleDB(self.mediaItem, path=self.path,
|
||||
oldbible = OldBibleDB(self.mediaItem, path=temp_dir,
|
||||
file=filename[0])
|
||||
name = filename[1]
|
||||
if name is None:
|
||||
print u'no Name!!!'
|
||||
# FIXME: ?
|
||||
delete_file(os.path.join(self.path, filename[0]))
|
||||
self.incrementProgressBar(unicode(translate(
|
||||
'BiblesPlugin.UpgradeWizardForm',
|
||||
'Upgrading Bible %s of %s: "%s"\nFailed')) %
|
||||
(number + 1, self.maxBibles, name),
|
||||
(number + 1, max_bibles, name),
|
||||
self.progressBar.maximum() - self.progressBar.value())
|
||||
number += 1
|
||||
continue
|
||||
self.progressLabel.setText(unicode(translate(
|
||||
'BiblesPlugin.UpgradeWizardForm',
|
||||
'Upgrading Bible %s of %s: "%s"\nUpgrading ...')) %
|
||||
(number + 1, self.maxBibles, name))
|
||||
(number + 1, max_bibles, name))
|
||||
if os.path.exists(os.path.join(self.path, filename[0])):
|
||||
name = unicode(self.versionNameEdit[biblenumber].text())
|
||||
name = unicode(self.versionNameEdit[number].text())
|
||||
self.newbibles[number] = BibleDB(self.mediaItem, path=self.path,
|
||||
name=name)
|
||||
name=name, file=filename[0])
|
||||
self.newbibles[number].register(self.plugin.upgrade_wizard)
|
||||
metadata = oldbible.get_metadata()
|
||||
webbible = False
|
||||
@ -595,7 +568,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(temp_dir, clean_filename(name))
|
||||
del self.newbibles[number]
|
||||
critical_error_message_box(
|
||||
translate('BiblesPlugin.UpgradeWizardForm',
|
||||
@ -606,9 +579,8 @@ class BibleUpgradeForm(OpenLPWizard):
|
||||
self.incrementProgressBar(unicode(translate(
|
||||
'BiblesPlugin.UpgradeWizardForm',
|
||||
'Upgrading Bible %s of %s: "%s"\nFailed')) %
|
||||
(number + 1, self.maxBibles, name),
|
||||
(number + 1, max_bibles, name),
|
||||
self.progressBar.maximum() - self.progressBar.value())
|
||||
number += 1
|
||||
continue
|
||||
bible = BiblesResourcesDB.get_webbible(
|
||||
meta_data[u'download name'],
|
||||
@ -621,14 +593,13 @@ 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(temp_dir, clean_filename(name))
|
||||
del self.newbibles[number]
|
||||
self.incrementProgressBar(unicode(translate(
|
||||
'BiblesPlugin.UpgradeWizardForm',
|
||||
'Upgrading Bible %s of %s: "%s"\nFailed')) %
|
||||
(number + 1, self.maxBibles, name),
|
||||
(number + 1, max_bibles, name),
|
||||
self.progressBar.maximum() - self.progressBar.value())
|
||||
number += 1
|
||||
continue
|
||||
self.progressBar.setMaximum(len(books))
|
||||
for book in books:
|
||||
@ -639,7 +610,7 @@ class BibleUpgradeForm(OpenLPWizard):
|
||||
'BiblesPlugin.UpgradeWizardForm',
|
||||
'Upgrading Bible %s of %s: "%s"\n'
|
||||
'Upgrading %s ...')) %
|
||||
(number + 1, self.maxBibles, name, book))
|
||||
(number + 1, max_bibles, name, book))
|
||||
book_ref_id = self.newbibles[number].\
|
||||
get_book_ref_id_by_name(book, len(books), language_id)
|
||||
if not book_ref_id:
|
||||
@ -647,7 +618,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(name))
|
||||
delete_database(temp_dir, clean_filename(name))
|
||||
del self.newbibles[number]
|
||||
bible_failed = True
|
||||
break
|
||||
@ -678,14 +649,13 @@ 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(name))
|
||||
delete_database(temp_dir, clean_filename(name))
|
||||
del self.newbibles[number]
|
||||
self.incrementProgressBar(unicode(translate(
|
||||
'BiblesPlugin.UpgradeWizardForm',
|
||||
'Upgrading Bible %s of %s: "%s"\nFailed')) %
|
||||
(number + 1, self.maxBibles, name),
|
||||
(number + 1, max_bibles, name),
|
||||
self.progressBar.maximum() - self.progressBar.value())
|
||||
number += 1
|
||||
continue
|
||||
books = oldbible.get_books()
|
||||
self.progressBar.setMaximum(len(books))
|
||||
@ -697,14 +667,14 @@ class BibleUpgradeForm(OpenLPWizard):
|
||||
'BiblesPlugin.UpgradeWizardForm',
|
||||
'Upgrading Bible %s of %s: "%s"\n'
|
||||
'Upgrading %s ...')) %
|
||||
(number + 1, self.maxBibles, name, book[u'name']))
|
||||
(number + 1, max_bibles, name, book[u'name']))
|
||||
book_ref_id = self.newbibles[number].\
|
||||
get_book_ref_id_by_name(book[u'name'], len(books),
|
||||
language_id)
|
||||
if not book_ref_id:
|
||||
log.warn(u'Upgrading books from %s " '\
|
||||
'failed - aborted by user' % name)
|
||||
delete_database(self.path, clean_filename(name))
|
||||
delete_database(temp_dir, clean_filename(name))
|
||||
del self.newbibles[number]
|
||||
bible_failed = True
|
||||
break
|
||||
@ -729,21 +699,21 @@ class BibleUpgradeForm(OpenLPWizard):
|
||||
if not bible_failed:
|
||||
self.newbibles[number].create_meta(u'Version', name)
|
||||
oldbible.close_connection()
|
||||
delete_file(os.path.join(self.path, filename[0]))
|
||||
delete_file(os.path.join(temp_dir, filename[0]))
|
||||
self.incrementProgressBar(unicode(translate(
|
||||
'BiblesPlugin.UpgradeWizardForm',
|
||||
'Upgrading Bible %s of %s: "%s"\n'
|
||||
'Complete')) %
|
||||
(number + 1, self.maxBibles, name))
|
||||
self.success[biblenumber] = True
|
||||
(number + 1, max_bibles, name))
|
||||
self.success[number] = True
|
||||
else:
|
||||
self.incrementProgressBar(unicode(translate(
|
||||
'BiblesPlugin.UpgradeWizardForm',
|
||||
'Upgrading Bible %s of %s: "%s"\nFailed')) %
|
||||
(number + 1, self.maxBibles, name),
|
||||
(number + 1, max_bibles, name),
|
||||
self.progressBar.maximum() - self.progressBar.value())
|
||||
delete_database(self.path, clean_filename(name))
|
||||
number += 1
|
||||
delete_database(temp_dir, clean_filename(name))
|
||||
shutil.rmtree(temp_dir, True)
|
||||
|
||||
def postWizard(self):
|
||||
"""
|
||||
@ -752,7 +722,7 @@ class BibleUpgradeForm(OpenLPWizard):
|
||||
successful_import = 0
|
||||
failed_import = 0
|
||||
for number, filename in enumerate(self.files):
|
||||
if number in self.success and self.success[number] == True:
|
||||
if self.success.has_key(number) and self.success[number]:
|
||||
successful_import += 1
|
||||
elif self.checkBox[number].checkState() == QtCore.Qt.Checked:
|
||||
failed_import += 1
|
||||
@ -776,7 +746,6 @@ class BibleUpgradeForm(OpenLPWizard):
|
||||
'Bible(s): %s successful%s')) % (successful_import,
|
||||
failed_import_text))
|
||||
else:
|
||||
self.progressLabel.setText(
|
||||
translate('BiblesPlugin.UpgradeWizardForm', 'Upgrade '
|
||||
'failed.'))
|
||||
self.progressLabel.setText(translate(
|
||||
'BiblesPlugin.UpgradeWizardForm', 'Upgrade failed.'))
|
||||
OpenLPWizard.postWizard(self)
|
||||
|
@ -169,6 +169,7 @@ class BibleDB(QtCore.QObject, Manager):
|
||||
self.wizard = None
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'openlp_stop_wizard'), self.stop_import)
|
||||
print kwargs, (self.file, self.path)
|
||||
|
||||
def stop_import(self):
|
||||
"""
|
||||
@ -210,7 +211,7 @@ class BibleDB(QtCore.QObject, Manager):
|
||||
The book_reference_id from bibles_resources.sqlite of the book.
|
||||
|
||||
``testament``
|
||||
*Defaults to 1.* The testament_reference_id from
|
||||
*Defaults to 1.* The testament_reference_id from
|
||||
bibles_resources.sqlite of the testament this book belongs to.
|
||||
"""
|
||||
log.debug(u'BibleDB.create_book("%s", "%s")', name, bk_ref_id)
|
||||
@ -329,7 +330,7 @@ class BibleDB(QtCore.QObject, Manager):
|
||||
return self.get_object_filtered(Book, Book.book_reference_id.like(id))
|
||||
|
||||
def get_book_ref_id_by_name(self, book, maxbooks, language_id=None):
|
||||
log.debug(u'BibleDB.get_book_ref_id_by_name:("%s", "%s")', book,
|
||||
log.debug(u'BibleDB.get_book_ref_id_by_name:("%s", "%s")', book,
|
||||
language_id)
|
||||
if BiblesResourcesDB.get_book(book, True):
|
||||
book_temp = BiblesResourcesDB.get_book(book, True)
|
||||
@ -471,7 +472,7 @@ class BibleDB(QtCore.QObject, Manager):
|
||||
|
||||
def get_language(self, bible_name=None):
|
||||
"""
|
||||
If no language is given it calls a dialog window where the user could
|
||||
If no language is given it calls a dialog window where the user could
|
||||
select the bible language.
|
||||
Return the language id of a bible.
|
||||
|
||||
@ -521,9 +522,9 @@ class BiblesResourcesDB(QtCore.QObject, Manager):
|
||||
some resources which are used in the Bibles plugin.
|
||||
A wrapper class around a small SQLite database which contains the download
|
||||
resources, a biblelist from the different download resources, the books,
|
||||
chapter counts and verse counts for the web download Bibles, a language
|
||||
reference, the testament reference and some alternative book names. This
|
||||
class contains a singleton "cursor" so that only one connection to the
|
||||
chapter counts and verse counts for the web download Bibles, a language
|
||||
reference, the testament reference and some alternative book names. This
|
||||
class contains a singleton "cursor" so that only one connection to the
|
||||
SQLite database is ever used.
|
||||
"""
|
||||
cursor = None
|
||||
@ -582,7 +583,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager):
|
||||
|
||||
``name``
|
||||
The name or abbreviation of the book.
|
||||
|
||||
|
||||
``lower``
|
||||
True if the comparsion should be only lowercase
|
||||
"""
|
||||
@ -592,7 +593,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager):
|
||||
if lower:
|
||||
books = BiblesResourcesDB.run_sql(u'SELECT id, testament_id, name, '
|
||||
u'abbreviation, chapters FROM book_reference WHERE '
|
||||
u'LOWER(name) = ? OR LOWER(abbreviation) = ?',
|
||||
u'LOWER(name) = ? OR LOWER(abbreviation) = ?',
|
||||
(name.lower(), name.lower()))
|
||||
else:
|
||||
books = BiblesResourcesDB.run_sql(u'SELECT id, testament_id, name, '
|
||||
@ -621,7 +622,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager):
|
||||
if not isinstance(id, int):
|
||||
id = int(id)
|
||||
books = BiblesResourcesDB.run_sql(u'SELECT id, testament_id, name, '
|
||||
u'abbreviation, chapters FROM book_reference WHERE id = ?',
|
||||
u'abbreviation, chapters FROM book_reference WHERE id = ?',
|
||||
(id, ))
|
||||
if books:
|
||||
return {
|
||||
@ -645,12 +646,12 @@ class BiblesResourcesDB(QtCore.QObject, Manager):
|
||||
``chapter``
|
||||
The chapter number.
|
||||
"""
|
||||
log.debug(u'BiblesResourcesDB.get_chapter("%s", "%s")', book_id,
|
||||
log.debug(u'BiblesResourcesDB.get_chapter("%s", "%s")', book_id,
|
||||
chapter)
|
||||
if not isinstance(chapter, int):
|
||||
chapter = int(chapter)
|
||||
chapters = BiblesResourcesDB.run_sql(u'SELECT id, book_reference_id, '
|
||||
u'chapter, verse_count FROM chapters WHERE book_reference_id = ?',
|
||||
u'chapter, verse_count FROM chapters WHERE book_reference_id = ?',
|
||||
(book_id,))
|
||||
if chapters:
|
||||
return {
|
||||
@ -687,7 +688,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager):
|
||||
``chapter``
|
||||
The number of the chapter.
|
||||
"""
|
||||
log.debug(u'BiblesResourcesDB.get_verse_count("%s", "%s")', book_id,
|
||||
log.debug(u'BiblesResourcesDB.get_verse_count("%s", "%s")', book_id,
|
||||
chapter)
|
||||
details = BiblesResourcesDB.get_chapter(book_id, chapter)
|
||||
if details:
|
||||
@ -715,7 +716,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager):
|
||||
}
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
@staticmethod
|
||||
def get_webbibles(source):
|
||||
"""
|
||||
@ -737,7 +738,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager):
|
||||
u'id': bible[0],
|
||||
u'name': bible[1],
|
||||
u'abbreviation': bible[2],
|
||||
u'language_id': bible[3],
|
||||
u'language_id': bible[3],
|
||||
u'download_source_id': bible[4]
|
||||
}
|
||||
for bible in bibles
|
||||
@ -752,11 +753,11 @@ class BiblesResourcesDB(QtCore.QObject, Manager):
|
||||
|
||||
``abbreviation``
|
||||
The abbreviation of the webbible.
|
||||
|
||||
|
||||
``source``
|
||||
The source of the webbible.
|
||||
"""
|
||||
log.debug(u'BiblesResourcesDB.get_webbibles("%s", "%s")', abbreviation,
|
||||
log.debug(u'BiblesResourcesDB.get_webbibles("%s", "%s")', abbreviation,
|
||||
source)
|
||||
if not isinstance(abbreviation, unicode):
|
||||
abbreviation = unicode(abbreviation)
|
||||
@ -765,14 +766,14 @@ class BiblesResourcesDB(QtCore.QObject, Manager):
|
||||
source = BiblesResourcesDB.get_download_source(source)
|
||||
bible = BiblesResourcesDB.run_sql(u'SELECT id, name, abbreviation, '
|
||||
u'language_id, download_source_id FROM webbibles WHERE '
|
||||
u'download_source_id = ? AND abbreviation = ?', (source[u'id'],
|
||||
u'download_source_id = ? AND abbreviation = ?', (source[u'id'],
|
||||
abbreviation))
|
||||
if bible:
|
||||
return {
|
||||
u'id': bible[0][0],
|
||||
u'name': bible[0][1],
|
||||
u'abbreviation': bible[0][2],
|
||||
u'language_id': bible[0][3],
|
||||
u'language_id': bible[0][3],
|
||||
u'download_source_id': bible[0][4]
|
||||
}
|
||||
else:
|
||||
@ -785,11 +786,11 @@ class BiblesResourcesDB(QtCore.QObject, Manager):
|
||||
|
||||
``name``
|
||||
The name to search the id.
|
||||
|
||||
|
||||
``language_id``
|
||||
The language_id for which language should be searched
|
||||
"""
|
||||
log.debug(u'BiblesResourcesDB.get_alternative_book_name("%s", "%s")',
|
||||
log.debug(u'BiblesResourcesDB.get_alternative_book_name("%s", "%s")',
|
||||
name, language_id)
|
||||
if language_id:
|
||||
books = BiblesResourcesDB.run_sql(u'SELECT book_reference_id, name '
|
||||
@ -806,7 +807,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager):
|
||||
@staticmethod
|
||||
def get_language(name):
|
||||
"""
|
||||
Return a dict containing the language id, name and code by name or
|
||||
Return a dict containing the language id, name and code by name or
|
||||
abbreviation.
|
||||
|
||||
``name``
|
||||
@ -865,7 +866,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager):
|
||||
|
||||
class AlternativeBookNamesDB(QtCore.QObject, Manager):
|
||||
"""
|
||||
This class represents a database-bound alternative book names system.
|
||||
This class represents a database-bound alternative book names system.
|
||||
"""
|
||||
cursor = None
|
||||
conn = None
|
||||
@ -874,7 +875,7 @@ class AlternativeBookNamesDB(QtCore.QObject, Manager):
|
||||
def get_cursor():
|
||||
"""
|
||||
Return the cursor object. Instantiate one if it doesn't exist yet.
|
||||
If necessary loads up the database and creates the tables if the
|
||||
If necessary loads up the database and creates the tables if the
|
||||
database doesn't exist.
|
||||
"""
|
||||
if AlternativeBookNamesDB.cursor is None:
|
||||
@ -904,7 +905,7 @@ class AlternativeBookNamesDB(QtCore.QObject, Manager):
|
||||
|
||||
``parameters``
|
||||
Any variable parameters to add to the query
|
||||
|
||||
|
||||
``commit``
|
||||
If a commit statement is necessary this should be True.
|
||||
"""
|
||||
@ -921,11 +922,11 @@ class AlternativeBookNamesDB(QtCore.QObject, Manager):
|
||||
|
||||
``name``
|
||||
The name to search the id.
|
||||
|
||||
|
||||
``language_id``
|
||||
The language_id for which language should be searched
|
||||
"""
|
||||
log.debug(u'AlternativeBookNamesDB.get_book_reference_id("%s", "%s")',
|
||||
log.debug(u'AlternativeBookNamesDB.get_book_reference_id("%s", "%s")',
|
||||
name, language_id)
|
||||
if language_id:
|
||||
books = AlternativeBookNamesDB.run_sql(u'SELECT book_reference_id, '
|
||||
@ -962,11 +963,11 @@ class AlternativeBookNamesDB(QtCore.QObject, Manager):
|
||||
|
||||
class OldBibleDB(QtCore.QObject, Manager):
|
||||
"""
|
||||
This class conects to the old bible databases to reimport them to the new
|
||||
This class conects to the old bible databases to reimport them to the new
|
||||
database scheme.
|
||||
"""
|
||||
cursor = None
|
||||
|
||||
|
||||
def __init__(self, parent, **kwargs):
|
||||
"""
|
||||
The constructor loads up the database and creates and initialises the
|
||||
|
@ -153,7 +153,7 @@ class BibleManager(object):
|
||||
if name is None:
|
||||
delete_file(os.path.join(self.path, filename))
|
||||
continue
|
||||
# Find old database versions
|
||||
# Find old database versions.
|
||||
if bible.is_old_database():
|
||||
self.old_bible_databases.append([filename, name])
|
||||
bible.session.close()
|
||||
@ -220,7 +220,7 @@ class BibleManager(object):
|
||||
return [
|
||||
{
|
||||
u'name': book.name,
|
||||
u'book_reference_id': book.book_reference_id,
|
||||
u'book_reference_id': book.book_reference_id,
|
||||
u'chapters': self.db_cache[bible].get_chapter_count(book)
|
||||
}
|
||||
for book in self.db_cache[bible].get_books()
|
||||
@ -229,10 +229,10 @@ class BibleManager(object):
|
||||
def get_chapter_count(self, bible, book):
|
||||
"""
|
||||
Returns the number of Chapters for a given book.
|
||||
|
||||
|
||||
``bible``
|
||||
Unicode. The Bible to get the list of books from.
|
||||
|
||||
|
||||
``book``
|
||||
The book object to get the chapter count for.
|
||||
"""
|
||||
@ -295,7 +295,7 @@ class BibleManager(object):
|
||||
if db_book:
|
||||
book_id = db_book.book_reference_id
|
||||
log.debug(u'Book name corrected to "%s"', db_book.name)
|
||||
new_reflist.append((book_id, item[1], item[2],
|
||||
new_reflist.append((book_id, item[1], item[2],
|
||||
item[3]))
|
||||
else:
|
||||
log.debug(u'OpenLP failed to find book %s', item[0])
|
||||
|
@ -612,7 +612,7 @@ class BibleMediaItem(MediaManagerItem):
|
||||
if restore:
|
||||
old_text = unicode(combo.currentText())
|
||||
combo.clear()
|
||||
combo.addItems([unicode(i) for i in range(range_from, range_to + 1)])
|
||||
combo.addItems(map(unicode, range(range_from, range_to + 1)))
|
||||
if restore and combo.findText(old_text) != -1:
|
||||
combo.setCurrentIndex(combo.findText(old_text))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user