forked from openlp/openlp
change name from reimport to upgrade
fix speed problem while changing the advanced bible change some "for" loops
This commit is contained in:
parent
8e1ef8c890
commit
d7dc4def53
@ -32,6 +32,7 @@ from openlp.core.lib import Plugin, StringContent, build_icon, translate
|
||||
from openlp.core.lib.ui import base_action, UiStrings
|
||||
from openlp.core.utils.actions import ActionList
|
||||
from openlp.plugins.bibles.lib import BibleManager, BiblesTab, BibleMediaItem
|
||||
from openlp.plugins.bibles.forms import BibleUpgradeForm
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@ -58,7 +59,7 @@ class BiblePlugin(Plugin):
|
||||
#action_list.add_action(self.exportBibleItem, UiStrings().Export)
|
||||
# Set to invisible until we can export bibles
|
||||
self.exportBibleItem.setVisible(False)
|
||||
self.toolsReimportItem.setVisible(True)
|
||||
self.toolsUpgradeItem.setVisible(True)
|
||||
|
||||
def finalise(self):
|
||||
"""
|
||||
@ -90,7 +91,7 @@ class BiblePlugin(Plugin):
|
||||
|
||||
def addToolsMenuItem(self, tools_menu):
|
||||
"""
|
||||
Give the alerts plugin the opportunity to add items to the
|
||||
Give the bible plugin the opportunity to add items to the
|
||||
**Tools** menu.
|
||||
|
||||
``tools_menu``
|
||||
@ -98,25 +99,28 @@ class BiblePlugin(Plugin):
|
||||
use it as their parent.
|
||||
"""
|
||||
log.info(u'add tools menu')
|
||||
self.toolsReimportItem = QtGui.QAction(tools_menu)
|
||||
self.toolsReimportItem.setObjectName(u'toolsReimportItem')
|
||||
self.toolsReimportItem.setText(
|
||||
translate('BiblePlugin', 'Re-&import older bible databases'))
|
||||
self.toolsReimportItem.setStatusTip(
|
||||
translate('BiblePlugin', 'Re-import the bible databases to addapt '
|
||||
self.toolsUpgradeItem = QtGui.QAction(tools_menu)
|
||||
self.toolsUpgradeItem.setObjectName(u'toolsUpgradeItem')
|
||||
self.toolsUpgradeItem.setText(
|
||||
translate('BiblePlugin', '&Upgrade older bible databases'))
|
||||
self.toolsUpgradeItem.setStatusTip(
|
||||
translate('BiblePlugin', 'Upgrade the bible databases to addapt '
|
||||
'the database scheme.'))
|
||||
tools_menu.addAction(self.toolsReimportItem)
|
||||
QtCore.QObject.connect(self.toolsReimportItem,
|
||||
QtCore.SIGNAL(u'triggered()'), self.onToolsReimportItemTriggered)
|
||||
self.toolsReimportItem.setVisible(False)
|
||||
tools_menu.addAction(self.toolsUpgradeItem)
|
||||
QtCore.QObject.connect(self.toolsUpgradeItem,
|
||||
QtCore.SIGNAL(u'triggered()'), self.onToolsUpgradeItemTriggered)
|
||||
self.toolsUpgradeItem.setVisible(False)
|
||||
|
||||
def onToolsReimportItemTriggered(self):
|
||||
def onToolsUpgradeItemTriggered(self):
|
||||
"""
|
||||
Re-import older bible databases.
|
||||
Upgrade older bible databases.
|
||||
"""
|
||||
#self.manager.import_old_bible_databases()
|
||||
if self.mediaItem:
|
||||
self.mediaItem.onReImportClick()
|
||||
if not hasattr(self, u'upgrade_wizard'):
|
||||
self.upgrade_wizard = BibleUpgradeForm(self.formparent,
|
||||
self.manager, self)
|
||||
# If the import was not cancelled then reload.
|
||||
if self.upgrade_wizard.exec_():
|
||||
self.mediaItem.reloadBibles()
|
||||
|
||||
def onBibleImportClick(self):
|
||||
if self.mediaItem:
|
||||
|
@ -53,6 +53,7 @@ from the .ui files later if necessary.
|
||||
from booknameform import BookNameForm
|
||||
from languageform import LanguageForm
|
||||
from bibleimportform import BibleImportForm
|
||||
from biblereimportform import BibleReImportForm
|
||||
from bibleupgradeform import BibleUpgradeForm
|
||||
|
||||
__all__ = ['BibleImportForm']
|
||||
__all__ = [u'BookNameForm', u'LanguageForm', u'BibleImportForm',
|
||||
u'BibleUpgradeForm']
|
||||
|
@ -45,12 +45,12 @@ from openlp.plugins.bibles.lib.http import BSExtract, BGExtract, CWExtract
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class BibleReImportForm(OpenLPWizard):
|
||||
class BibleUpgradeForm(OpenLPWizard):
|
||||
"""
|
||||
This is the Bible ReImport Wizard, which allows easy importing of Bibles
|
||||
This is the Bible Upgrade Wizard, which allows easy importing of Bibles
|
||||
into OpenLP from older OpenLP2 database versions.
|
||||
"""
|
||||
log.info(u'BibleReImportForm loaded')
|
||||
log.info(u'BibleUpgradeForm loaded')
|
||||
|
||||
def __init__(self, parent, manager, bibleplugin):
|
||||
"""
|
||||
@ -66,7 +66,7 @@ class BibleReImportForm(OpenLPWizard):
|
||||
The Bible plugin.
|
||||
"""
|
||||
self.manager = manager
|
||||
self.parent = parent
|
||||
self.mediaItem = bibleplugin.mediaItem
|
||||
self.suffix = u'.sqlite'
|
||||
self.settingsSection = u'bibles/bibles'
|
||||
self.oldsettingsSection = u'bibles'
|
||||
@ -80,7 +80,7 @@ class BibleReImportForm(OpenLPWizard):
|
||||
self.newbibles = {}
|
||||
self.maxBibles = len(self.files)
|
||||
self.stop_import_flag = False
|
||||
OpenLPWizard.__init__(self, parent, bibleplugin, u'bibleImportWizard',
|
||||
OpenLPWizard.__init__(self, parent, bibleplugin, u'bibleUpgradeWizard',
|
||||
u':/wizards/wizard_importbible.bmp')
|
||||
|
||||
def setupUi(self, image):
|
||||
@ -113,7 +113,7 @@ class BibleReImportForm(OpenLPWizard):
|
||||
|
||||
def onCheckBoxIndexChanged(self, index):
|
||||
'''
|
||||
Some cleanup while finishing
|
||||
Show/ Hide warnings if CheckBox state has changed
|
||||
'''
|
||||
for number, filename in enumerate(self.files):
|
||||
if not self.checkBox[number].checkState() == 2:
|
||||
@ -121,8 +121,8 @@ class BibleReImportForm(OpenLPWizard):
|
||||
self.formWidget[number].hide()
|
||||
else:
|
||||
if os.path.exists(os.path.join(self.newpath, filename)):
|
||||
self.verticalWidget[number].setVisible(1)
|
||||
self.formWidget[number].setVisible(1)
|
||||
self.verticalWidget[number].show()
|
||||
self.formWidget[number].show()
|
||||
|
||||
def reject(self):
|
||||
"""
|
||||
@ -161,7 +161,7 @@ class BibleReImportForm(OpenLPWizard):
|
||||
|
||||
def customInit(self):
|
||||
"""
|
||||
Perform any custom initialisation for bible importing.
|
||||
Perform any custom initialisation for bible upgrading.
|
||||
"""
|
||||
self.manager.set_process_dialog(self)
|
||||
self.restart()
|
||||
@ -213,7 +213,7 @@ class BibleReImportForm(OpenLPWizard):
|
||||
self.formWidget = {}
|
||||
self.formLayoutAttention = {}
|
||||
for number, filename in enumerate(self.files):
|
||||
bible = OldBibleDB(self.parent, path=self.oldpath, file=filename)
|
||||
bible = OldBibleDB(self.mediaItem, path=self.oldpath, file=filename)
|
||||
self.checkBox[number] = QtGui.QCheckBox(self.scrollAreaContents)
|
||||
checkBoxName = u'checkBox['+unicode(number)+u']'
|
||||
self.checkBox[number].setObjectName(checkBoxName)
|
||||
@ -233,7 +233,7 @@ class BibleReImportForm(OpenLPWizard):
|
||||
versionInfoPixmapName = u'versionInfoPixmap['+unicode(number)+u']'
|
||||
self.versionInfoPixmap[number].setObjectName(versionInfoPixmapName)
|
||||
self.versionInfoPixmap[number].setPixmap(QtGui.QPixmap(
|
||||
u':/bibles/bibles_reimport_alert.png'))
|
||||
u':/bibles/bibles_upgrade_alert.png'))
|
||||
self.versionInfoPixmap[number].setAlignment(QtCore.Qt.AlignRight)
|
||||
self.horizontalLayout[number].addWidget(
|
||||
self.versionInfoPixmap[number])
|
||||
@ -325,41 +325,41 @@ class BibleReImportForm(OpenLPWizard):
|
||||
"""
|
||||
Allow for localisation of the bible import wizard.
|
||||
"""
|
||||
self.setWindowTitle(translate('BiblesPlugin.ReImportWizardForm',
|
||||
'Bible ReImport Wizard'))
|
||||
self.setWindowTitle(translate('BiblesPlugin.UpgradeWizardForm',
|
||||
'Bible Upgrade Wizard'))
|
||||
self.titleLabel.setText(WizardStrings.HeaderStyle %
|
||||
translate('OpenLP.Ui', 'Welcome to the Bible ReImport Wizard'))
|
||||
translate('OpenLP.Ui', 'Welcome to the Bible Upgrade Wizard'))
|
||||
self.informationLabel.setText(
|
||||
translate('BiblesPlugin.ReImportWizardForm',
|
||||
'This wizard will help you to reimport your existing Bibles from a '
|
||||
translate('BiblesPlugin.UpgradeWizardForm',
|
||||
'This wizard will help you to upgrade your existing Bibles from a '
|
||||
'prior version of OpenLP 2. Click the next button below to start '
|
||||
'the process by selecting the bibles to reimport.'))
|
||||
'the process by selecting the bibles to upgrade.'))
|
||||
self.selectPage.setTitle(
|
||||
translate('BiblesPlugin.ReImportWizardForm',
|
||||
translate('BiblesPlugin.UpgradeWizardForm',
|
||||
'Please choose'))
|
||||
self.selectPage.setSubTitle(
|
||||
translate('BiblesPlugin.ReImportWizardForm',
|
||||
'Please choose the bibles which should be reimported'))
|
||||
translate('BiblesPlugin.UpgradeWizardForm',
|
||||
'Please choose the bibles which should be upgraded'))
|
||||
for number, bible in enumerate(self.files):
|
||||
self.versionNameLabel[number].setText(
|
||||
translate('BiblesPlugin.ReImportWizardForm', 'Version name:'))
|
||||
translate('BiblesPlugin.UpgradeWizardForm', 'Version name:'))
|
||||
self.versionInfoLabel[number].setText(
|
||||
translate('BiblesPlugin.ReImportWizardForm', 'This '
|
||||
translate('BiblesPlugin.UpgradeWizardForm', 'This '
|
||||
'bible still exists. Please change the name or uncheck it.'))
|
||||
self.progressPage.setTitle(WizardStrings.Importing)
|
||||
self.progressPage.setSubTitle(
|
||||
translate('BiblesPlugin.ReImportWizardForm',
|
||||
'Please wait while your Bibles are imported.'))
|
||||
translate('BiblesPlugin.UpgradeWizardForm',
|
||||
'Please wait while your Bibles are upgraded.'))
|
||||
self.progressLabel.setText(WizardStrings.Ready)
|
||||
self.progressBar.setFormat(u'%p%')
|
||||
self.deleteCheckBox.setText(
|
||||
translate('BiblesPlugin.ReImportWizardForm', 'Delete old bible '
|
||||
'database(s) from bibles which was imported\nsucessful right now'))
|
||||
translate('BiblesPlugin.UpgradeWizardForm', 'Delete old bible '
|
||||
'database(s) from bibles which was upgraded\nsucessful right now'))
|
||||
self.deleteAllCheckBox.setText(
|
||||
translate('BiblesPlugin.ReImportWizardForm', 'Delete all old bible '
|
||||
'database(s) (including not imported bibles)'))
|
||||
translate('BiblesPlugin.UpgradeWizardForm', 'Delete all old bible '
|
||||
'database(s) (including not upgraded bibles)'))
|
||||
self.progressLabelAfter.setText(
|
||||
translate('BiblesPlugin.ReImportWizardForm', '\nIf OpenLP should '
|
||||
translate('BiblesPlugin.UpgradeWizardForm', '\nIf OpenLP should '
|
||||
'delete the old bible databases please choose:'))
|
||||
|
||||
def validateCurrentPage(self):
|
||||
@ -373,21 +373,21 @@ class BibleReImportForm(OpenLPWizard):
|
||||
if not self.checkBox[number].checkState() == 2:
|
||||
continue
|
||||
version_name = unicode(self.versionNameEdit[number].text())
|
||||
oldbible = OldBibleDB(self.parent, path=self.oldpath,
|
||||
oldbible = OldBibleDB(self.mediaItem, path=self.oldpath,
|
||||
file=filename)
|
||||
oldname = oldbible.get_name()
|
||||
if not version_name:
|
||||
critical_error_message_box(UiStrings().EmptyField,
|
||||
translate('BiblesPlugin.ReImportWizardForm',
|
||||
translate('BiblesPlugin.UpgradeWizardForm',
|
||||
'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.ReImportWizardForm',
|
||||
translate('BiblesPlugin.UpgradeWizardForm',
|
||||
'Bible Exists'),
|
||||
translate('BiblesPlugin.ReImportWizardForm',
|
||||
'This Bible already exists. Please import '
|
||||
translate('BiblesPlugin.UpgradeWizardForm',
|
||||
'This Bible already exists. Please upgrade '
|
||||
'a different Bible, delete the existing one or '
|
||||
'uncheck.'))
|
||||
self.versionNameEdit[number].setFocus()
|
||||
@ -395,10 +395,10 @@ class BibleReImportForm(OpenLPWizard):
|
||||
elif os.path.exists(os.path.join(self.newpath, filename)) and \
|
||||
version_name == oldname:
|
||||
critical_error_message_box(
|
||||
translate('BiblesPlugin.ReImportWizardForm',
|
||||
translate('BiblesPlugin.UpgradeWizardForm',
|
||||
'Bible Exists'),
|
||||
translate('BiblesPlugin.ReImportWizardForm',
|
||||
'This Bible already exists. Please import '
|
||||
translate('BiblesPlugin.UpgradeWizardForm',
|
||||
'This Bible already exists. Please upgrade '
|
||||
'a different Bible, delete the existing one or '
|
||||
'uncheck.'))
|
||||
self.versionNameEdit[number].setFocus()
|
||||
@ -406,10 +406,10 @@ class BibleReImportForm(OpenLPWizard):
|
||||
elif os.path.exists(os.path.join(self.newpath,
|
||||
self.clean_filename(version_name))):
|
||||
critical_error_message_box(
|
||||
translate('BiblesPlugin.ReImportWizardForm',
|
||||
translate('BiblesPlugin.UpgradeWizardForm',
|
||||
'Bible Exists'),
|
||||
translate('BiblesPlugin.ReImportWizardForm',
|
||||
'This Bible already exists. Please import '
|
||||
translate('BiblesPlugin.UpgradeWizardForm',
|
||||
'This Bible already exists. Please upgrade '
|
||||
'a different Bible, delete the existing one or '
|
||||
'uncheck.'))
|
||||
self.versionNameEdit[number].setFocus()
|
||||
@ -422,7 +422,7 @@ class BibleReImportForm(OpenLPWizard):
|
||||
"""
|
||||
Set default values for the wizard pages.
|
||||
"""
|
||||
log.debug(u'BibleReImport setDefaults')
|
||||
log.debug(u'BibleUpgrade setDefaults')
|
||||
settings = QtCore.QSettings()
|
||||
settings.beginGroup(self.plugin.settingsSection)
|
||||
self.stop_import_flag = False
|
||||
@ -440,8 +440,8 @@ class BibleReImportForm(OpenLPWizard):
|
||||
for number, filename in enumerate(self.files):
|
||||
self.checkBox[number].setCheckState(2)
|
||||
if os.path.exists(os.path.join(self.newpath, filename)):
|
||||
self.verticalWidget[number].setVisible(1)
|
||||
self.formWidget[number].setVisible(1)
|
||||
self.verticalWidget[number].show()
|
||||
self.formWidget[number].show()
|
||||
else:
|
||||
self.verticalWidget[number].hide()
|
||||
self.formWidget[number].hide()
|
||||
@ -456,24 +456,24 @@ class BibleReImportForm(OpenLPWizard):
|
||||
|
||||
def preWizard(self):
|
||||
"""
|
||||
Prepare the UI for the import.
|
||||
Prepare the UI for the upgrade.
|
||||
"""
|
||||
OpenLPWizard.preWizard(self)
|
||||
self.progressLabel.setText(translate(
|
||||
'BiblesPlugin.ImportWizardForm',
|
||||
'Starting Importing bible...'))
|
||||
'BiblesPlugin.UpgradeWizardForm',
|
||||
'Starting upgrading bible(s)...'))
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
|
||||
def performWizard(self):
|
||||
"""
|
||||
Perform the actual import.
|
||||
Perform the actual upgrade.
|
||||
"""
|
||||
include_webbible = False
|
||||
proxy_server = None
|
||||
if self.maxBibles == 0:
|
||||
self.progressLabel.setText(
|
||||
translate('BiblesPlugin.ReImportWizardForm', 'Sorry, but OpenLP'
|
||||
' could not find a Bible to reimport.'))
|
||||
translate('BiblesPlugin.UpgradeWizardForm', 'Sorry, but OpenLP'
|
||||
' could not find a Bible to upgrade.'))
|
||||
self.progressBar.hide()
|
||||
return
|
||||
self.maxBibles = 0
|
||||
@ -487,24 +487,25 @@ class BibleReImportForm(OpenLPWizard):
|
||||
if not self.checkBox[biblenumber].checkState() == 2:
|
||||
continue
|
||||
self.progressBar.reset()
|
||||
oldbible = OldBibleDB(self.parent, path=self.oldpath, file=filename)
|
||||
oldbible = OldBibleDB(self.mediaItem, path=self.oldpath,
|
||||
file=filename)
|
||||
name = oldbible.get_name()
|
||||
if name is None:
|
||||
delete_file(os.path.join(self.oldpath, filename))
|
||||
self.incrementProgressBar(unicode(translate(
|
||||
'BiblesPlugin.ReImportWizardForm',
|
||||
'Reimporting Bible %s of %s: "%s"\nFailed')) %
|
||||
'BiblesPlugin.UpgradeWizardForm',
|
||||
'Upgrading Bible %s of %s: "%s"\nFailed')) %
|
||||
(number+1, self.maxBibles, name),
|
||||
self.progressBar.maximum()-self.progressBar.value())
|
||||
number += 1
|
||||
continue
|
||||
self.progressLabel.setText(unicode(translate(
|
||||
'BiblesPlugin.ReImportWizardForm',
|
||||
'Reimporting Bible %s of %s: "%s"\nImporting ...')) %
|
||||
'BiblesPlugin.UpgradeWizardForm',
|
||||
'Upgrading Bible %s of %s: "%s"\nImporting ...')) %
|
||||
(number+1, self.maxBibles, name))
|
||||
if os.path.exists(os.path.join(self.newpath, filename)):
|
||||
name = unicode(self.versionNameEdit[biblenumber].text())
|
||||
self.newbibles[number] = BibleDB(self.parent, path=self.oldpath,
|
||||
self.newbibles[number] = BibleDB(self.mediaItem, path=self.oldpath,
|
||||
name=name)
|
||||
metadata = oldbible.get_metadata()
|
||||
webbible = False
|
||||
@ -538,16 +539,16 @@ class BibleReImportForm(OpenLPWizard):
|
||||
clean_filename(self.newbibles[number].get_name()))
|
||||
del self.newbibles[number]
|
||||
critical_error_message_box(
|
||||
translate('BiblesPlugin.ReImportWizardForm',
|
||||
translate('BiblesPlugin.UpgradeWizardForm',
|
||||
'Download Error'),
|
||||
translate('BiblesPlugin.ReImportWizardForm',
|
||||
'To Re-Import your webbibles a Internet connection is '
|
||||
translate('BiblesPlugin.UpgradeWizardForm',
|
||||
'To upgrade your webbibles a Internet connection is '
|
||||
'necessary. Please check your Internet connection, and '
|
||||
'if this error continues to occur please consider '
|
||||
'reporting a bug.'))
|
||||
self.incrementProgressBar(unicode(translate(
|
||||
'BiblesPlugin.ReImportWizardForm',
|
||||
'Reimporting Bible %s of %s: "%s"\nFailed')) %
|
||||
'BiblesPlugin.UpgradeWizardForm',
|
||||
'Upgrading Bible %s of %s: "%s"\nFailed')) %
|
||||
(number+1, self.maxBibles, name),
|
||||
self.progressBar.maximum()-self.progressBar.value())
|
||||
number += 1
|
||||
@ -562,14 +563,14 @@ class BibleReImportForm(OpenLPWizard):
|
||||
else:
|
||||
language_id = self.newbibles[number].get_language()
|
||||
if not language_id:
|
||||
log.exception(u'Re-Importing from "%s" '\
|
||||
log.exception(u'Upgrading from "%s" '\
|
||||
'failed' % filename)
|
||||
delete_database(self.newpath, self.newbibles[number].\
|
||||
clean_filename(self.newbibles[number].get_name()))
|
||||
del self.newbibles[number]
|
||||
self.incrementProgressBar(unicode(translate(
|
||||
'BiblesPlugin.ReImportWizardForm',
|
||||
'Reimporting Bible %s of %s: "%s"\nFailed')) %
|
||||
'BiblesPlugin.UpgradeWizardForm',
|
||||
'Upgrading Bible %s of %s: "%s"\nFailed')) %
|
||||
(number+1, self.maxBibles, name),
|
||||
self.progressBar.maximum()-self.progressBar.value())
|
||||
number += 1
|
||||
@ -577,8 +578,8 @@ class BibleReImportForm(OpenLPWizard):
|
||||
self.progressBar.setMaximum(len(books))
|
||||
for book in books:
|
||||
self.incrementProgressBar(unicode(translate(
|
||||
'BiblesPlugin.ReImportWizardForm',
|
||||
'Reimporting Bible %s of %s: "%s"\n'
|
||||
'BiblesPlugin.UpgradeWizardForm',
|
||||
'Upgrading Bible %s of %s: "%s"\n'
|
||||
'Importing %s ...')) %
|
||||
(number+1, self.maxBibles, name, book))
|
||||
book_ref_id = self.newbibles[number].\
|
||||
@ -608,8 +609,8 @@ class BibleReImportForm(OpenLPWizard):
|
||||
clean_filename(self.newbibles[number].get_name()))
|
||||
del self.newbibles[number]
|
||||
self.incrementProgressBar(unicode(translate(
|
||||
'BiblesPlugin.ReImportWizardForm',
|
||||
'Reimporting Bible %s of %s: "%s"\nFailed')) %
|
||||
'BiblesPlugin.UpgradeWizardForm',
|
||||
'Upgrading Bible %s of %s: "%s"\nFailed')) %
|
||||
(number+1, self.maxBibles, name),
|
||||
self.progressBar.maximum()-self.progressBar.value())
|
||||
number += 1
|
||||
@ -618,8 +619,8 @@ class BibleReImportForm(OpenLPWizard):
|
||||
self.progressBar.setMaximum(len(books))
|
||||
for book in books:
|
||||
self.incrementProgressBar(unicode(translate(
|
||||
'BiblesPlugin.ReImportWizardForm',
|
||||
'Reimporting Bible %s of %s: "%s"\n'
|
||||
'BiblesPlugin.UpgradeWizardForm',
|
||||
'Upgrading Bible %s of %s: "%s"\n'
|
||||
'Importing %s ...')) %
|
||||
(number+1, self.maxBibles, name, book[u'name']))
|
||||
book_ref_id = self.newbibles[number].\
|
||||
@ -643,19 +644,19 @@ class BibleReImportForm(OpenLPWizard):
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
if not bible_failed:
|
||||
self.incrementProgressBar(unicode(translate(
|
||||
'BiblesPlugin.ReImportWizardForm',
|
||||
'Reimporting Bible %s of %s: "%s"\n'
|
||||
'BiblesPlugin.UpgradeWizardForm',
|
||||
'Upgrading Bible %s of %s: "%s"\n'
|
||||
'Done')) %
|
||||
(number+1, self.maxBibles, name))
|
||||
self.success[biblenumber] = True
|
||||
else:
|
||||
self.incrementProgressBar(unicode(translate(
|
||||
'BiblesPlugin.ReImportWizardForm',
|
||||
'Reimporting Bible %s of %s: "%s"\nFailed')) %
|
||||
'BiblesPlugin.UpgradeWizardForm',
|
||||
'Upgrading Bible %s of %s: "%s"\nFailed')) %
|
||||
(number+1, self.maxBibles, name),
|
||||
self.progressBar.maximum()-self.progressBar.value())
|
||||
number += 1
|
||||
self.parent.reloadBibles()
|
||||
self.mediaItem.reloadBibles()
|
||||
successful_import = 0
|
||||
failed_import = 0
|
||||
for number, success in self.success.iteritems():
|
||||
@ -665,34 +666,34 @@ class BibleReImportForm(OpenLPWizard):
|
||||
failed_import += 1
|
||||
if failed_import > 0:
|
||||
failed_import_text = unicode(translate(
|
||||
'BiblesPlugin.ReImportWizardForm',
|
||||
' - %s reimport fail')) % failed_import
|
||||
'BiblesPlugin.UpgradeWizardForm',
|
||||
' - %s upgrade fail')) % failed_import
|
||||
else:
|
||||
failed_import_text = u''
|
||||
if successful_import > 0:
|
||||
if include_webbible:
|
||||
self.progressLabel.setText(unicode(
|
||||
translate('BiblesPlugin.ReImportWizardForm', 'Reimport %s '
|
||||
translate('BiblesPlugin.UpgradeWizardForm', 'Upgrade %s '
|
||||
'bible(s) successful%s.\nPlease note, that verses from '
|
||||
'webbibles will be downloaded\non demand and thus an '
|
||||
'internet connection is required.')) %
|
||||
(successful_import, failed_import_text))
|
||||
else:
|
||||
self.progressLabel.setText(unicode(
|
||||
translate('BiblesPlugin.ReImportWizardForm', 'Reimport %s '
|
||||
translate('BiblesPlugin.UpgradeWizardForm', 'Upgrade %s '
|
||||
'bible(s) successful.%s')) % (successful_import,
|
||||
failed_import_text))
|
||||
self.deleteCheckBox.setVisible(1)
|
||||
self.deleteCheckBox.show()
|
||||
bibles = u''
|
||||
for bible in self.newbibles.itervalues():
|
||||
name = bible.get_name()
|
||||
bibles += u'\n"' + name + u'"'
|
||||
self.deleteCheckBox.setToolTip(unicode(translate(
|
||||
'BiblesPlugin.ReImportWizardForm',
|
||||
'Sucessful imported bible(s):%s')) % bibles)
|
||||
'BiblesPlugin.UpgradeWizardForm',
|
||||
'Sucessful upgraded bible(s):%s')) % bibles)
|
||||
else:
|
||||
self.progressLabel.setText(
|
||||
translate('BiblesPlugin.ReImportWizardForm', 'Reimport '
|
||||
translate('BiblesPlugin.UpgradeWizardForm', 'Upgrade '
|
||||
'failed.'))
|
||||
self.progressLabelAfter.setVisible(1)
|
||||
self.deleteAllCheckBox.setVisible(1)
|
||||
self.progressLabelAfter.show()
|
||||
self.deleteAllCheckBox.show()
|
@ -35,7 +35,7 @@ from sqlalchemy import Column, ForeignKey, or_, Table, types
|
||||
from sqlalchemy.orm import class_mapper, mapper, relation
|
||||
from sqlalchemy.orm.exc import UnmappedClassError
|
||||
|
||||
from openlp.core.lib import Receiver, translate
|
||||
from openlp.core.lib import Receiver, translate, check_directory_exists
|
||||
from openlp.core.lib.db import BaseModel, init_db, Manager
|
||||
from openlp.core.lib.ui import critical_error_message_box
|
||||
from openlp.core.utils import AppLocation
|
||||
@ -295,14 +295,14 @@ class BibleDB(QtCore.QObject, Manager):
|
||||
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'%'))
|
||||
return db_book
|
||||
return self.get_object_filtered(Book, Book.name.like(book + u'%'))
|
||||
|
||||
def get_books(self):
|
||||
"""
|
||||
A wrapper so both local and web bibles have a get_books() method that
|
||||
manager can call. Used in the media manager advanced search tab.
|
||||
"""
|
||||
log.debug(u'BibleDB.get_books()')
|
||||
return self.get_all_objects(Book, order_by_ref=Book.id)
|
||||
|
||||
def get_book_by_book_ref_id(self, id):
|
||||
@ -313,9 +313,7 @@ class BibleDB(QtCore.QObject, Manager):
|
||||
The reference id of the book to return.
|
||||
"""
|
||||
log.debug(u'BibleDB.get_book_by_book_ref_id("%s")', id)
|
||||
db_book = self.get_object_filtered(Book,
|
||||
Book.book_reference_id.like(id))
|
||||
return db_book
|
||||
return self.get_object_filtered(Book, Book.book_reference_id.like(id))
|
||||
|
||||
def get_book_ref_id_by_name(self, book, language_id=None):
|
||||
log.debug(u'BibleDB.get_book_ref_id_by_name:("%s", "%s")', book,
|
||||
@ -421,16 +419,16 @@ class BibleDB(QtCore.QObject, Manager):
|
||||
verses = verses.all()
|
||||
return verses
|
||||
|
||||
def get_chapter_count(self, book_id):
|
||||
def get_chapter_count(self, book):
|
||||
"""
|
||||
Return the number of chapters in a book.
|
||||
|
||||
``book``
|
||||
The book to get the chapter count for.
|
||||
The book object to get the chapter count for.
|
||||
"""
|
||||
log.debug(u'BibleDB.get_chapter_count("%s")', book_id)
|
||||
log.debug(u'BibleDB.get_chapter_count("%s")', book.name)
|
||||
count = self.session.query(Verse.chapter).join(Book)\
|
||||
.filter(Book.book_reference_id==book_id)\
|
||||
.filter(Book.name==book.name)\
|
||||
.distinct().count()
|
||||
if not count:
|
||||
return 0
|
||||
@ -541,16 +539,16 @@ class BiblesResourcesDB(QtCore.QObject, Manager):
|
||||
log.debug(u'BiblesResourcesDB.get_books()')
|
||||
books = BiblesResourcesDB.run_sql(u'SELECT id, testament_id, name, '
|
||||
u'abbreviation, chapters FROM book_reference ORDER BY id')
|
||||
book_list = []
|
||||
for book in books:
|
||||
book_list.append({
|
||||
u'id': book[0],
|
||||
u'testament_id': book[1],
|
||||
u'name': unicode(book[2]),
|
||||
u'abbreviation': unicode(book[3]),
|
||||
u'chapters': book[4]
|
||||
})
|
||||
return book_list
|
||||
return [
|
||||
{
|
||||
u'id': book[0],
|
||||
u'testament_id': book[1],
|
||||
u'name': unicode(book[2]),
|
||||
u'abbreviation': unicode(book[3]),
|
||||
u'chapters': book[4]
|
||||
}
|
||||
for book in books
|
||||
]
|
||||
|
||||
@staticmethod
|
||||
def get_book(name):
|
||||
@ -700,16 +698,16 @@ class BiblesResourcesDB(QtCore.QObject, Manager):
|
||||
u'language_id, download_source_id FROM webbibles WHERE '
|
||||
u'download_source_id = ?', (source[u'id'],))
|
||||
if bibles:
|
||||
bibles_temp = []
|
||||
for bible in bibles:
|
||||
bibles_temp.append({
|
||||
u'id': bible[0],
|
||||
u'name': bible[1],
|
||||
u'abbreviation': bible[2],
|
||||
u'language_id': bible[3],
|
||||
u'download_source_id': bible[4]
|
||||
})
|
||||
return bibles_temp
|
||||
return [
|
||||
{
|
||||
u'id': bible[0],
|
||||
u'name': bible[1],
|
||||
u'abbreviation': bible[2],
|
||||
u'language_id': bible[3],
|
||||
u'download_source_id': bible[4]
|
||||
}
|
||||
for bible in bibles
|
||||
]
|
||||
else:
|
||||
return None
|
||||
|
||||
@ -736,14 +734,13 @@ class BiblesResourcesDB(QtCore.QObject, Manager):
|
||||
u'download_source_id = ? AND abbreviation = ?', (source[u'id'],
|
||||
abbreviation))
|
||||
if bible:
|
||||
bibles_temp = {
|
||||
return {
|
||||
u'id': bible[0][0],
|
||||
u'name': bible[0][1],
|
||||
u'abbreviation': bible[0][2],
|
||||
u'language_id': bible[0][3],
|
||||
u'download_source_id': bible[0][4]
|
||||
}
|
||||
return bibles_temp
|
||||
else:
|
||||
return None
|
||||
|
||||
@ -806,14 +803,14 @@ class BiblesResourcesDB(QtCore.QObject, Manager):
|
||||
languages = BiblesResourcesDB.run_sql(u'SELECT id, name, code FROM '
|
||||
u'language ORDER by name')
|
||||
if languages:
|
||||
languages_temp = []
|
||||
for language in languages:
|
||||
languages_temp.append({
|
||||
u'id': language[0],
|
||||
u'name': unicode(language[1]),
|
||||
u'code': unicode(language[2])
|
||||
})
|
||||
return languages_temp
|
||||
return [
|
||||
{
|
||||
u'id': language[0],
|
||||
u'name': unicode(language[1]),
|
||||
u'code': unicode(language[2])
|
||||
}
|
||||
for language in languages
|
||||
]
|
||||
else:
|
||||
return None
|
||||
|
||||
@ -825,13 +822,13 @@ class BiblesResourcesDB(QtCore.QObject, Manager):
|
||||
log.debug(u'BiblesResourcesDB.get_testament_reference()')
|
||||
testaments = BiblesResourcesDB.run_sql(u'SELECT id, name FROM '
|
||||
u'testament_reference ORDER BY id')
|
||||
testament_list = []
|
||||
for testament in testaments:
|
||||
testament_list.append({
|
||||
u'id': testament[0],
|
||||
u'name': unicode(testament[1])
|
||||
})
|
||||
return testament_list
|
||||
return [
|
||||
{
|
||||
u'id': testament[0],
|
||||
u'name': unicode(testament[1])
|
||||
}
|
||||
for testament in testaments
|
||||
]
|
||||
|
||||
|
||||
class AlternativeBookNamesDB(QtCore.QObject, Manager):
|
||||
@ -849,12 +846,8 @@ class AlternativeBookNamesDB(QtCore.QObject, Manager):
|
||||
database doesn't exist.
|
||||
"""
|
||||
if AlternativeBookNamesDB.cursor is None:
|
||||
if not os.path.exists(os.path.join(
|
||||
AppLocation.get_directory(AppLocation.DataDir), u'bibles',
|
||||
u'resources')):
|
||||
os.mkdir(os.path.join(
|
||||
AppLocation.get_directory(AppLocation.DataDir), u'bibles',
|
||||
u'resources'))
|
||||
check_directory_exists(os.path.join(AppLocation.get_directory(
|
||||
AppLocation.DataDir), u'bibles', u'resources'))
|
||||
filepath = os.path.join(
|
||||
AppLocation.get_directory(AppLocation.DataDir), u'bibles',
|
||||
u'resources', u'alternative_book_names.sqlite')
|
||||
@ -933,10 +926,9 @@ class AlternativeBookNamesDB(QtCore.QObject, Manager):
|
||||
"""
|
||||
log.debug(u'AlternativeBookNamesDB.create_alternative_book_name("%s", '
|
||||
'"%s", "%s"', name, book_reference_id, language_id)
|
||||
alternative_book_name = AlternativeBookNamesDB.run_sql(u'INSERT INTO '
|
||||
return AlternativeBookNamesDB.run_sql(u'INSERT INTO '
|
||||
u'alternative_book_names(book_reference_id, language_id, name) '
|
||||
u'VALUES (?, ?, ?)', (book_reference_id, language_id, name), True)
|
||||
return alternative_book_name
|
||||
|
||||
|
||||
class OldBibleDB(QtCore.QObject, Manager):
|
||||
@ -1014,15 +1006,15 @@ class OldBibleDB(QtCore.QObject, Manager):
|
||||
metadata = self.run_sql(u'SELECT key, value FROM metadata '
|
||||
u'ORDER BY rowid')
|
||||
if metadata:
|
||||
metadata_list = []
|
||||
for meta in metadata:
|
||||
metadata_list.append({
|
||||
u'key': unicode(meta[0]),
|
||||
u'value': unicode(meta[1])
|
||||
})
|
||||
return [
|
||||
{
|
||||
u'key': unicode(meta[0]),
|
||||
u'value': unicode(meta[1])
|
||||
}
|
||||
for meta in metadata
|
||||
]
|
||||
else:
|
||||
metadata_list = None
|
||||
return metadata_list
|
||||
return None
|
||||
|
||||
def get_books(self):
|
||||
"""
|
||||
@ -1030,15 +1022,16 @@ class OldBibleDB(QtCore.QObject, Manager):
|
||||
"""
|
||||
books = self.run_sql(u'SELECT name, id FROM book ORDER BY id')
|
||||
if books:
|
||||
return [
|
||||
{
|
||||
u'name': unicode(book[0]),
|
||||
u'id':int(book[1])
|
||||
}
|
||||
for book in books
|
||||
]
|
||||
book_list = []
|
||||
for book in books:
|
||||
book_list.append({
|
||||
u'name': unicode(book[0]),
|
||||
u'id':int(book[1])
|
||||
})
|
||||
else:
|
||||
book_list = None
|
||||
return book_list
|
||||
return None
|
||||
|
||||
def get_verses(self, book_id):
|
||||
"""
|
||||
@ -1047,15 +1040,14 @@ class OldBibleDB(QtCore.QObject, Manager):
|
||||
verses = self.run_sql(u'SELECT book_id, chapter, verse, text FROM '
|
||||
u'verse WHERE book_id = ? ORDER BY id', (book_id, ))
|
||||
if verses:
|
||||
verse_list = []
|
||||
for verse in verses:
|
||||
verse_list.append({
|
||||
u'book_id': int(verse[0]),
|
||||
u'chapter': int(verse[1]),
|
||||
u'verse': int(verse[2]),
|
||||
u'text': unicode(verse[3])
|
||||
})
|
||||
return [
|
||||
{
|
||||
u'book_id': int(verse[0]),
|
||||
u'chapter': int(verse[1]),
|
||||
u'verse': int(verse[2]),
|
||||
u'text': unicode(verse[3])
|
||||
}
|
||||
for verse in verses
|
||||
]
|
||||
else:
|
||||
verse_list = None
|
||||
return verse_list
|
||||
|
||||
return None
|
||||
|
@ -241,10 +241,10 @@ class BSExtract(object):
|
||||
send_error_message(u'parse')
|
||||
return None
|
||||
content = content.findAll(u'li')
|
||||
books = []
|
||||
for book in content:
|
||||
return [
|
||||
books.append(book.contents[0].contents[0])
|
||||
return books
|
||||
for book in content
|
||||
]
|
||||
|
||||
|
||||
class CWExtract(object):
|
||||
@ -507,12 +507,15 @@ class HTTPBible(BibleDB):
|
||||
log.debug(u'HTTPBible.get_books("%s")', Book.name)
|
||||
return self.get_all_objects(Book, order_by_ref=Book.id)
|
||||
|
||||
def get_chapter_count(self, book_id):
|
||||
def get_chapter_count(self, book):
|
||||
"""
|
||||
Return the number of chapters in a particular book.
|
||||
|
||||
``book``
|
||||
The book object to get the chapter count for.
|
||||
"""
|
||||
log.debug(u'HTTPBible.get_chapter_count("%s")', book_id)
|
||||
return BiblesResourcesDB.get_chapter_count(book_id)
|
||||
log.debug(u'HTTPBible.get_chapter_count("%s")', book.name)
|
||||
return BiblesResourcesDB.get_chapter_count(book.book_reference_id)
|
||||
|
||||
def get_verse_count(self, book_id, chapter):
|
||||
"""
|
||||
|
@ -208,23 +208,27 @@ class BibleManager(object):
|
||||
Unicode. The Bible to get the list of books from.
|
||||
"""
|
||||
log.debug(u'BibleManager.get_books("%s")', bible)
|
||||
language_id = self.get_meta_data(bible, u'language_id')
|
||||
books = []
|
||||
for book in self.db_cache[bible].get_books():
|
||||
books.append(
|
||||
return [
|
||||
{
|
||||
u'name': book.name,
|
||||
u'chapters': self.db_cache[bible].get_chapter_count(
|
||||
book.book_reference_id)
|
||||
})
|
||||
return books
|
||||
u'name': book.name,
|
||||
u'chapters': self.db_cache[bible].get_chapter_count(
|
||||
book)
|
||||
}
|
||||
for book in self.db_cache[bible].get_books()
|
||||
]
|
||||
|
||||
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.
|
||||
"""
|
||||
log.debug(u'BibleManager.get_book_chapter_count ("%s", "%s")', bible,
|
||||
book)
|
||||
book.name)
|
||||
return self.db_cache[bible].get_chapter_count(book)
|
||||
|
||||
def get_verse_count(self, bible, book, chapter):
|
||||
|
@ -33,7 +33,7 @@ from openlp.core.lib import MediaManagerItem, Receiver, ItemCapabilities, \
|
||||
from openlp.core.lib.searchedit import SearchEdit
|
||||
from openlp.core.lib.ui import UiStrings, add_widget_completer, \
|
||||
media_item_combo_box, critical_error_message_box, find_and_set_in_combo_box
|
||||
from openlp.plugins.bibles.forms import BibleImportForm, BibleReImportForm
|
||||
from openlp.plugins.bibles.forms import BibleImportForm
|
||||
from openlp.plugins.bibles.lib import LayoutStyle, DisplayStyle, \
|
||||
VerseReferenceList, get_reference_match
|
||||
|
||||
@ -310,14 +310,6 @@ class BibleMediaItem(MediaManagerItem):
|
||||
if self.import_wizard.exec_():
|
||||
self.reloadBibles()
|
||||
|
||||
def onReImportClick(self):
|
||||
if not hasattr(self, u'reimport_wizard'):
|
||||
self.reimport_wizard = BibleReImportForm(self, self.parent.manager,
|
||||
self.parent)
|
||||
# If the import was not cancelled then reload.
|
||||
if self.reimport_wizard.exec_():
|
||||
self.reloadBibles()
|
||||
|
||||
def loadBibles(self):
|
||||
log.debug(u'Loading Bibles')
|
||||
self.quickVersionComboBox.clear()
|
||||
|
Before Width: | Height: | Size: 762 B After Width: | Height: | Size: 762 B |
@ -24,7 +24,7 @@
|
||||
<qresource prefix="bibles">
|
||||
<file>bibles_search_text.png</file>
|
||||
<file>bibles_search_reference.png</file>
|
||||
<file>bibles_reimport_alert.png</file>
|
||||
<file>bibles_upgrade_alert.png</file>
|
||||
</qresource>
|
||||
<qresource prefix="plugins">
|
||||
<file>plugin_alerts.png</file>
|
||||
|
Loading…
Reference in New Issue
Block a user