bible renamings

This commit is contained in:
Andreas Preikschat 2013-04-18 19:45:14 +02:00
parent 85ab27ab0c
commit 098d733ad1
22 changed files with 465 additions and 499 deletions

View File

@ -39,39 +39,39 @@ class Ui_FirstTimeLanguageDialog(object):
""" """
The UI widgets of the language selection dialog. The UI widgets of the language selection dialog.
""" """
def setupUi(self, languageDialog): def setupUi(self, language_dialog):
""" """
Set up the UI. Set up the UI.
""" """
languageDialog.setObjectName(u'languageDialog') language_dialog.setObjectName(u'language_dialog')
languageDialog.resize(300, 50) language_dialog.resize(300, 50)
self.dialogLayout = QtGui.QVBoxLayout(languageDialog) self.dialog_layout = QtGui.QVBoxLayout(language_dialog)
self.dialogLayout.setContentsMargins(8, 8, 8, 8) self.dialog_layout.setContentsMargins(8, 8, 8, 8)
self.dialogLayout.setSpacing(8) self.dialog_layout.setSpacing(8)
self.dialogLayout.setObjectName(u'dialog_layout') self.dialog_layout.setObjectName(u'dialog_layout')
self.infoLabel = QtGui.QLabel(languageDialog) self.info_label = QtGui.QLabel(language_dialog)
self.infoLabel.setObjectName(u'infoLabel') self.info_label.setObjectName(u'info_label')
self.dialogLayout.addWidget(self.infoLabel) self.dialog_layout.addWidget(self.info_label)
self.languageLayout = QtGui.QHBoxLayout() self.language_layout = QtGui.QHBoxLayout()
self.languageLayout.setObjectName(u'languageLayout') self.language_layout.setObjectName(u'language_layout')
self.languageLabel = QtGui.QLabel(languageDialog) self.language_label = QtGui.QLabel(language_dialog)
self.languageLabel.setObjectName(u'languageLabel') self.language_label.setObjectName(u'language_label')
self.languageLayout.addWidget(self.languageLabel) self.language_layout.addWidget(self.language_label)
self.languageComboBox = QtGui.QComboBox(languageDialog) self.language_combo_box = QtGui.QComboBox(language_dialog)
self.languageComboBox.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToContents) self.language_combo_box.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToContents)
self.languageComboBox.setObjectName("languageComboBox") self.language_combo_box.setObjectName("language_combo_box")
self.languageLayout.addWidget(self.languageComboBox) self.language_layout.addWidget(self.language_combo_box)
self.dialogLayout.addLayout(self.languageLayout) self.dialog_layout.addLayout(self.language_layout)
self.button_box = create_button_box(languageDialog, u'button_box', [u'cancel', u'ok']) self.button_box = create_button_box(language_dialog, u'button_box', [u'cancel', u'ok'])
self.dialogLayout.addWidget(self.button_box) self.dialog_layout.addWidget(self.button_box)
self.retranslateUi(languageDialog) self.retranslateUi(language_dialog)
self.setMaximumHeight(self.sizeHint().height()) self.setMaximumHeight(self.sizeHint().height())
def retranslateUi(self, languageDialog): def retranslateUi(self, language_dialog):
""" """
Translate the UI on the fly. Translate the UI on the fly.
""" """
self.setWindowTitle(translate('OpenLP.FirstTimeLanguageForm', 'Select Translation')) self.setWindowTitle(translate('OpenLP.FirstTimeLanguageForm', 'Select Translation'))
self.infoLabel.setText( self.info_label.setText(
translate('OpenLP.FirstTimeLanguageForm', 'Choose the translation you\'d like to use in OpenLP.')) translate('OpenLP.FirstTimeLanguageForm', 'Choose the translation you\'d like to use in OpenLP.'))
self.languageLabel.setText(translate('OpenLP.FirstTimeLanguageForm', 'Translation:')) self.language_label.setText(translate('OpenLP.FirstTimeLanguageForm', 'Translation:'))

View File

@ -47,8 +47,8 @@ class FirstTimeLanguageForm(QtGui.QDialog, Ui_FirstTimeLanguageDialog):
QtGui.QDialog.__init__(self, parent) QtGui.QDialog.__init__(self, parent)
self.setupUi(self) self.setupUi(self)
self.qmList = LanguageManager.get_qm_list() self.qmList = LanguageManager.get_qm_list()
self.languageComboBox.addItem(u'Autodetect') self.language_combo_box.addItem(u'Autodetect')
self.languageComboBox.addItems(sorted(self.qmList.keys())) self.language_combo_box.addItems(sorted(self.qmList.keys()))
def exec_(self): def exec_(self):
""" """
@ -61,12 +61,12 @@ class FirstTimeLanguageForm(QtGui.QDialog, Ui_FirstTimeLanguageDialog):
Run when the dialog is OKed. Run when the dialog is OKed.
""" """
# It's the first row so must be Automatic # It's the first row so must be Automatic
if self.languageComboBox.currentIndex() == 0: if self.language_combo_box.currentIndex() == 0:
LanguageManager.auto_language = True LanguageManager.auto_language = True
LanguageManager.set_language(False, False) LanguageManager.set_language(False, False)
else: else:
LanguageManager.auto_language = False LanguageManager.auto_language = False
action = create_action(None, self.languageComboBox.currentText()) action = create_action(None, self.language_combo_box.currentText())
LanguageManager.set_language(action, False) LanguageManager.set_language(action, False)
return QtGui.QDialog.accept(self) return QtGui.QDialog.accept(self)

View File

@ -27,6 +27,5 @@
# Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Temple Place, Suite 330, Boston, MA 02111-1307 USA #
############################################################################### ###############################################################################
""" """
The :mod:`bibles` module provides the Bible plugin to enable OpenLP to display The :mod:`bibles` module provides the Bible plugin to enable OpenLP to display scripture.
scripture.
""" """

View File

@ -124,18 +124,15 @@ class BiblePlugin(Plugin):
def add_export_menu_Item(self, export_menu): def add_export_menu_Item(self, export_menu):
self.export_bible_item = create_action(export_menu, u'exportBibleItem', self.export_bible_item = create_action(export_menu, u'exportBibleItem',
text=translate('BiblesPlugin', '&Bible'), text=translate('BiblesPlugin', '&Bible'), visible=False)
visible=False)
export_menu.addAction(self.export_bible_item) export_menu.addAction(self.export_bible_item)
def add_tools_menu_item(self, tools_menu): def add_tools_menu_item(self, tools_menu):
""" """
Give the bible plugin the opportunity to add items to the Give the bible plugin the opportunity to add items to the **Tools** menu.
**Tools** menu.
``tools_menu`` ``tools_menu``
The actual **Tools** menu item, so that your actions can The actual **Tools** menu item, so that your actions can use it as their parent.
use it as their parent.
""" """
log.debug(u'add tools menu') log.debug(u'add tools menu')
self.tools_upgrade_item = create_action(tools_menu, u'toolsUpgradeItem', self.tools_upgrade_item = create_action(tools_menu, u'toolsUpgradeItem',
@ -166,25 +163,23 @@ class BiblePlugin(Plugin):
def uses_theme(self, theme): def uses_theme(self, theme):
""" """
Called to find out if the bible plugin is currently using a theme. Called to find out if the bible plugin is currently using a theme. Returns ``True`` if the theme is being used,
Returns ``True`` if the theme is being used, otherwise returns otherwise returns ``False``.
``False``.
""" """
return unicode(self.settings_tab.bible_theme) == theme return unicode(self.settings_tab.bible_theme) == theme
def rename_theme(self, oldTheme, newTheme): def rename_theme(self, old_theme, new_theme):
""" """
Rename the theme the bible plugin is using making the plugin use the Rename the theme the bible plugin is using making the plugin use the
new name. new name.
``oldTheme`` ``old_theme``
The name of the theme the plugin should stop using. Unused for The name of the theme the plugin should stop using. Unused for this particular plugin.
this particular plugin.
``newTheme`` ``new_theme``
The new name the plugin should now use. The new name the plugin should now use.
""" """
self.settings_tab.bible_theme = newTheme self.settings_tab.bible_theme = new_theme
self.settings_tab.save() self.settings_tab.save()
def set_plugin_text_strings(self): def set_plugin_text_strings(self):

View File

@ -28,30 +28,25 @@
############################################################################### ###############################################################################
""" """
Forms in OpenLP are made up of two classes. One class holds all the graphical Forms in OpenLP are made up of two classes. One class holds all the graphical elements, like buttons and lists, and the
elements, like buttons and lists, and the other class holds all the functional other class holds all the functional code, like slots and loading and saving.
code, like slots and loading and saving.
The first class, commonly known as the **Dialog** class, is typically named The first class, commonly known as the **Dialog** class, is typically named ``Ui_<name>Dialog``. It is a slightly
``Ui_<name>Dialog``. It is a slightly modified version of the class that the modified version of the class that the ``pyuic4`` command produces from Qt4's .ui file. Typical modifications will be
``pyuic4`` command produces from Qt4's .ui file. Typical modifications will be converting most strings from "" to u'' and using OpenLP's ``translate()`` function for translating strings.
converting most strings from "" to u'' and using OpenLP's ``translate()``
function for translating strings.
The second class, commonly known as the **Form** class, is typically named The second class, commonly known as the **Form** class, is typically named ``<name>Form``. This class is the one which
``<name>Form``. This class is the one which is instantiated and used. It uses is instantiated and used. It uses dual inheritance to inherit from (usually) QtGui.QDialog and the Ui class mentioned
dual inheritance to inherit from (usually) QtGui.QDialog and the Ui class above, like so::
mentioned above, like so::
class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard): class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard):
def __init__(self, parent, manager, bibleplugin): def __init__(self, parent, manager, bible_plugin):
QtGui.QWizard.__init__(self, parent) QtGui.QWizard.__init__(self, parent)
self.setupUi(self) self.setupUi(self)
This allows OpenLP to use ``self.object`` for all the GUI elements while keeping This allows OpenLP to use ``self.object`` for all the GUI elements while keeping them separate from the functionality,
them separate from the functionality, so that it is easier to recreate the GUI so that it is easier to recreate the GUI from the .ui files later if necessary.
from the .ui files later if necessary.
""" """
from booknameform import BookNameForm from booknameform import BookNameForm
from languageform import LanguageForm from languageform import LanguageForm
@ -59,5 +54,4 @@ from bibleimportform import BibleImportForm
from bibleupgradeform import BibleUpgradeForm from bibleupgradeform import BibleUpgradeForm
from editbibleform import EditBibleForm from editbibleform import EditBibleForm
__all__ = [u'BookNameForm', u'LanguageForm', u'BibleImportForm', __all__ = [u'BookNameForm', u'LanguageForm', u'BibleImportForm', u'BibleUpgradeForm', u'EditBibleForm']
u'BibleUpgradeForm', u'EditBibleForm']

View File

@ -58,12 +58,12 @@ class WebDownload(object):
class BibleImportForm(OpenLPWizard): class BibleImportForm(OpenLPWizard):
""" """
This is the Bible Import Wizard, which allows easy importing of Bibles This is the Bible Import Wizard, which allows easy importing of Bibles into OpenLP from other formats like OSIS,
into OpenLP from other formats like OSIS, CSV and OpenSong. CSV and OpenSong.
""" """
log.info(u'BibleImportForm loaded') log.info(u'BibleImportForm loaded')
def __init__(self, parent, manager, bibleplugin): def __init__(self, parent, manager, bible_plugin):
""" """
Instantiate the wizard, and run any extra setup we need to. Instantiate the wizard, and run any extra setup we need to.
@ -73,12 +73,12 @@ class BibleImportForm(OpenLPWizard):
``manager`` ``manager``
The Bible manager. The Bible manager.
``bibleplugin`` ``bible_plugin``
The Bible plugin. The Bible plugin.
""" """
self.manager = manager self.manager = manager
self.web_bible_list = {} self.web_bible_list = {}
OpenLPWizard.__init__(self, parent, bibleplugin, u'bibleImportWizard', u':/wizards/wizard_importbible.bmp') OpenLPWizard.__init__(self, parent, bible_plugin, u'bibleImportWizard', u':/wizards/wizard_importbible.bmp')
def setupUi(self, image): def setupUi(self, image):
""" """

View File

@ -48,8 +48,8 @@ log = logging.getLogger(__name__)
class BibleUpgradeForm(OpenLPWizard): class BibleUpgradeForm(OpenLPWizard):
""" """
This is the Bible Upgrade 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
into OpenLP from older OpenLP2 database versions. versions.
""" """
log.info(u'BibleUpgradeForm loaded') log.info(u'BibleUpgradeForm loaded')
@ -63,7 +63,7 @@ class BibleUpgradeForm(OpenLPWizard):
``manager`` ``manager``
The Bible manager. The Bible manager.
``bibleplugin`` ``bible_plugin``
The Bible plugin. The Bible plugin.
""" """
self.manager = manager self.manager = manager
@ -74,7 +74,7 @@ class BibleUpgradeForm(OpenLPWizard):
self.temp_dir = os.path.join(unicode(gettempdir(), get_filesystem_encoding()), u'openlp') self.temp_dir = os.path.join(unicode(gettempdir(), get_filesystem_encoding()), u'openlp')
self.files = self.manager.old_bible_databases self.files = self.manager.old_bible_databases
self.success = {} self.success = {}
self.newbibles = {} self.new_bibles = {}
OpenLPWizard.__init__(self, parent, bible_plugin, u'bibleUpgradeWizard', u':/wizards/wizard_importbible.bmp') OpenLPWizard.__init__(self, parent, bible_plugin, u'bibleUpgradeWizard', u':/wizards/wizard_importbible.bmp')
def setupUi(self, image): def setupUi(self, image):
@ -159,41 +159,41 @@ class BibleUpgradeForm(OpenLPWizard):
Add the bible import specific wizard pages. Add the bible import specific wizard pages.
""" """
# Backup Page # Backup Page
self.backupPage = QtGui.QWizardPage() self.backup_page = QtGui.QWizardPage()
self.backupPage.setObjectName(u'BackupPage') self.backup_page.setObjectName(u'BackupPage')
self.backupLayout = QtGui.QVBoxLayout(self.backupPage) self.backupLayout = QtGui.QVBoxLayout(self.backup_page)
self.backupLayout.setObjectName(u'BackupLayout') self.backupLayout.setObjectName(u'BackupLayout')
self.backupInfoLabel = QtGui.QLabel(self.backupPage) self.backupInfoLabel = QtGui.QLabel(self.backup_page)
self.backupInfoLabel.setOpenExternalLinks(True) self.backupInfoLabel.setOpenExternalLinks(True)
self.backupInfoLabel.setTextFormat(QtCore.Qt.RichText) self.backupInfoLabel.setTextFormat(QtCore.Qt.RichText)
self.backupInfoLabel.setWordWrap(True) self.backupInfoLabel.setWordWrap(True)
self.backupInfoLabel.setObjectName(u'backupInfoLabel') self.backupInfoLabel.setObjectName(u'backupInfoLabel')
self.backupLayout.addWidget(self.backupInfoLabel) self.backupLayout.addWidget(self.backupInfoLabel)
self.selectLabel = QtGui.QLabel(self.backupPage) self.selectLabel = QtGui.QLabel(self.backup_page)
self.selectLabel.setObjectName(u'select_label') self.selectLabel.setObjectName(u'select_label')
self.backupLayout.addWidget(self.selectLabel) self.backupLayout.addWidget(self.selectLabel)
self.formLayout = QtGui.QFormLayout() self.formLayout = QtGui.QFormLayout()
self.formLayout.setMargin(0) self.formLayout.setMargin(0)
self.formLayout.setObjectName(u'FormLayout') self.formLayout.setObjectName(u'FormLayout')
self.backupDirectoryLabel = QtGui.QLabel(self.backupPage) self.backupDirectoryLabel = QtGui.QLabel(self.backup_page)
self.backupDirectoryLabel.setObjectName(u'backupDirectoryLabel') self.backupDirectoryLabel.setObjectName(u'backupDirectoryLabel')
self.backupDirectoryLayout = QtGui.QHBoxLayout() self.backupDirectoryLayout = QtGui.QHBoxLayout()
self.backupDirectoryLayout.setObjectName(u'BackupDirectoryLayout') self.backupDirectoryLayout.setObjectName(u'BackupDirectoryLayout')
self.backupDirectoryEdit = QtGui.QLineEdit(self.backupPage) self.backupDirectoryEdit = QtGui.QLineEdit(self.backup_page)
self.backupDirectoryEdit.setObjectName(u'BackupFolderEdit') self.backupDirectoryEdit.setObjectName(u'BackupFolderEdit')
self.backupDirectoryLayout.addWidget(self.backupDirectoryEdit) self.backupDirectoryLayout.addWidget(self.backupDirectoryEdit)
self.backupBrowseButton = QtGui.QToolButton(self.backupPage) self.backupBrowseButton = QtGui.QToolButton(self.backup_page)
self.backupBrowseButton.setIcon(self.open_icon) self.backupBrowseButton.setIcon(self.open_icon)
self.backupBrowseButton.setObjectName(u'BackupBrowseButton') self.backupBrowseButton.setObjectName(u'BackupBrowseButton')
self.backupDirectoryLayout.addWidget(self.backupBrowseButton) self.backupDirectoryLayout.addWidget(self.backupBrowseButton)
self.formLayout.addRow(self.backupDirectoryLabel, self.backupDirectoryLayout) self.formLayout.addRow(self.backupDirectoryLabel, self.backupDirectoryLayout)
self.backupLayout.addLayout(self.formLayout) self.backupLayout.addLayout(self.formLayout)
self.noBackupCheckBox = QtGui.QCheckBox(self.backupPage) self.noBackupCheckBox = QtGui.QCheckBox(self.backup_page)
self.noBackupCheckBox.setObjectName('NoBackupCheckBox') self.noBackupCheckBox.setObjectName('NoBackupCheckBox')
self.backupLayout.addWidget(self.noBackupCheckBox) self.backupLayout.addWidget(self.noBackupCheckBox)
self.spacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Minimum) self.spacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Minimum)
self.backupLayout.addItem(self.spacer) self.backupLayout.addItem(self.spacer)
self.addPage(self.backupPage) self.addPage(self.backup_page)
# Select Page # Select Page
self.selectPage = QtGui.QWizardPage() self.selectPage = QtGui.QWizardPage()
self.selectPage.setObjectName(u'SelectPage') self.selectPage.setObjectName(u'SelectPage')
@ -247,8 +247,8 @@ class BibleUpgradeForm(OpenLPWizard):
self.information_label.setText(translate('BiblesPlugin.UpgradeWizardForm', self.information_label.setText(translate('BiblesPlugin.UpgradeWizardForm',
'This wizard will help you to upgrade your existing Bibles from a prior version of OpenLP 2. ' '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 upgrade process.')) 'Click the next button below to start the upgrade process.'))
self.backupPage.setTitle(translate('BiblesPlugin.UpgradeWizardForm', 'Select Backup Directory')) self.backup_page.setTitle(translate('BiblesPlugin.UpgradeWizardForm', 'Select Backup Directory'))
self.backupPage.setSubTitle(translate('BiblesPlugin.UpgradeWizardForm', self.backup_page.setSubTitle(translate('BiblesPlugin.UpgradeWizardForm',
'Please select a backup directory for your Bibles')) 'Please select a backup directory for your Bibles'))
self.backupInfoLabel.setText(translate('BiblesPlugin.UpgradeWizardForm', self.backupInfoLabel.setText(translate('BiblesPlugin.UpgradeWizardForm',
'Previous releases of OpenLP 2.0 are unable to use upgraded Bibles.' 'Previous releases of OpenLP 2.0 are unable to use upgraded Bibles.'
@ -277,7 +277,7 @@ class BibleUpgradeForm(OpenLPWizard):
""" """
if self.currentPage() == self.welcome_page: if self.currentPage() == self.welcome_page:
return True return True
elif self.currentPage() == self.backupPage: elif self.currentPage() == self.backup_page:
if not self.noBackupCheckBox.checkState() == QtCore.Qt.Checked: if not self.noBackupCheckBox.checkState() == QtCore.Qt.Checked:
backup_path = self.backupDirectoryEdit.text() backup_path = self.backupDirectoryEdit.text()
if not backup_path: if not backup_path:
@ -316,7 +316,7 @@ class BibleUpgradeForm(OpenLPWizard):
settings.beginGroup(self.plugin.settings_section) settings.beginGroup(self.plugin.settings_section)
self.stop_import_flag = False self.stop_import_flag = False
self.success.clear() self.success.clear()
self.newbibles.clear() self.new_bibles.clear()
self.clearScrollArea() self.clearScrollArea()
self.files = self.manager.old_bible_databases self.files = self.manager.old_bible_databases
self.addScrollArea() self.addScrollArea()
@ -372,8 +372,8 @@ class BibleUpgradeForm(OpenLPWizard):
name = filename[1] name = filename[1]
self.progress_label.setText(translate('BiblesPlugin.UpgradeWizardForm', self.progress_label.setText(translate('BiblesPlugin.UpgradeWizardForm',
'Upgrading Bible %s of %s: "%s"\nUpgrading ...') % (number + 1, max_bibles, name)) 'Upgrading Bible %s of %s: "%s"\nUpgrading ...') % (number + 1, max_bibles, name))
self.newbibles[number] = BibleDB(self.media_item, path=self.path, name=name, file=filename[0]) self.new_bibles[number] = BibleDB(self.media_item, path=self.path, name=name, file=filename[0])
self.newbibles[number].register(self.plugin.upgrade_wizard) self.new_bibles[number].register(self.plugin.upgrade_wizard)
metadata = old_bible.get_metadata() metadata = old_bible.get_metadata()
web_bible = False web_bible = False
meta_data = {} meta_data = {}
@ -387,7 +387,7 @@ class BibleUpgradeForm(OpenLPWizard):
# Copy the metadata # Copy the metadata
meta_data[meta[u'key']] = meta[u'value'] meta_data[meta[u'key']] = meta[u'value']
if meta[u'key'] != u'name' and meta[u'key'] != u'dbversion': if meta[u'key'] != u'name' and meta[u'key'] != u'dbversion':
self.newbibles[number].save_meta(meta[u'key'], meta[u'value']) self.new_bibles[number].save_meta(meta[u'key'], meta[u'value'])
if meta[u'key'] == u'download_source': if meta[u'key'] == u'download_source':
web_bible = True web_bible = True
self.includeWebBible = True self.includeWebBible = True
@ -403,8 +403,8 @@ class BibleUpgradeForm(OpenLPWizard):
if not books: if not books:
log.error(u'Upgrading books from %s - download name: "%s" failed' % ( log.error(u'Upgrading books from %s - download name: "%s" failed' % (
meta_data[u'download_source'], meta_data[u'download_name'])) meta_data[u'download_source'], meta_data[u'download_name']))
self.newbibles[number].session.close() self.new_bibles[number].session.close()
del self.newbibles[number] del self.new_bibles[number]
critical_error_message_box( critical_error_message_box(
translate('BiblesPlugin.UpgradeWizardForm', 'Download Error'), translate('BiblesPlugin.UpgradeWizardForm', 'Download Error'),
translate('BiblesPlugin.UpgradeWizardForm', translate('BiblesPlugin.UpgradeWizardForm',
@ -419,14 +419,14 @@ class BibleUpgradeForm(OpenLPWizard):
meta_data[u'download_source'].lower()) meta_data[u'download_source'].lower())
if bible and bible[u'language_id']: if bible and bible[u'language_id']:
language_id = bible[u'language_id'] language_id = bible[u'language_id']
self.newbibles[number].save_meta(u'language_id', self.new_bibles[number].save_meta(u'language_id',
language_id) language_id)
else: else:
language_id = self.newbibles[number].get_language(name) language_id = self.new_bibles[number].get_language(name)
if not language_id: if not language_id:
log.warn(u'Upgrading from "%s" failed' % filename[0]) log.warn(u'Upgrading from "%s" failed' % filename[0])
self.newbibles[number].session.close() self.new_bibles[number].session.close()
del self.newbibles[number] del self.new_bibles[number]
self.increment_progress_bar(translate('BiblesPlugin.UpgradeWizardForm', self.increment_progress_bar(translate('BiblesPlugin.UpgradeWizardForm',
'Upgrading Bible %s of %s: "%s"\nFailed') % (number + 1, max_bibles, name), 'Upgrading Bible %s of %s: "%s"\nFailed') % (number + 1, max_bibles, name),
self.progress_bar.maximum() - self.progress_bar.value()) self.progress_bar.maximum() - self.progress_bar.value())
@ -439,17 +439,17 @@ class BibleUpgradeForm(OpenLPWizard):
break break
self.increment_progress_bar(translate('BiblesPlugin.UpgradeWizardForm', self.increment_progress_bar(translate('BiblesPlugin.UpgradeWizardForm',
'Upgrading Bible %s of %s: "%s"\nUpgrading %s ...') % (number + 1, max_bibles, name, book)) 'Upgrading Bible %s of %s: "%s"\nUpgrading %s ...') % (number + 1, max_bibles, name, book))
book_ref_id = self.newbibles[number].\ book_ref_id = self.new_bibles[number].\
get_book_ref_id_by_name(book, len(books), language_id) get_book_ref_id_by_name(book, len(books), language_id)
if not book_ref_id: if not book_ref_id:
log.warn(u'Upgrading books from %s - download name: "%s" aborted by user' % ( log.warn(u'Upgrading books from %s - download name: "%s" aborted by user' % (
meta_data[u'download_source'], meta_data[u'download_name'])) meta_data[u'download_source'], meta_data[u'download_name']))
self.newbibles[number].session.close() self.new_bibles[number].session.close()
del self.newbibles[number] del self.new_bibles[number]
self.success[number] = False self.success[number] = False
break break
book_details = BiblesResourcesDB.get_book_by_id(book_ref_id) book_details = BiblesResourcesDB.get_book_by_id(book_ref_id)
db_book = self.newbibles[number].create_book(book, db_book = self.new_bibles[number].create_book(book,
book_ref_id, book_details[u'testament_id']) book_ref_id, book_details[u'testament_id'])
# Try to import already downloaded verses. # Try to import already downloaded verses.
oldbook = old_bible.get_book(book) oldbook = old_bible.get_book(book)
@ -462,19 +462,19 @@ class BibleUpgradeForm(OpenLPWizard):
if self.stop_import_flag: if self.stop_import_flag:
self.success[number] = False self.success[number] = False
break break
self.newbibles[number].create_verse(db_book.id, self.new_bibles[number].create_verse(db_book.id,
int(verse[u'chapter']), int(verse[u'chapter']),
int(verse[u'verse']), unicode(verse[u'text'])) int(verse[u'verse']), unicode(verse[u'text']))
self.application.process_events() self.application.process_events()
self.newbibles[number].session.commit() self.new_bibles[number].session.commit()
else: else:
language_id = self.newbibles[number].get_object(BibleMeta, u'language_id') language_id = self.new_bibles[number].get_object(BibleMeta, u'language_id')
if not language_id: if not language_id:
language_id = self.newbibles[number].get_language(name) language_id = self.new_bibles[number].get_language(name)
if not language_id: if not language_id:
log.warn(u'Upgrading books from "%s" failed' % name) log.warn(u'Upgrading books from "%s" failed' % name)
self.newbibles[number].session.close() self.new_bibles[number].session.close()
del self.newbibles[number] del self.new_bibles[number]
self.increment_progress_bar(translate('BiblesPlugin.UpgradeWizardForm', self.increment_progress_bar(translate('BiblesPlugin.UpgradeWizardForm',
'Upgrading Bible %s of %s: "%s"\nFailed') % (number + 1, max_bibles, name), 'Upgrading Bible %s of %s: "%s"\nFailed') % (number + 1, max_bibles, name),
self.progress_bar.maximum() - self.progress_bar.value()) self.progress_bar.maximum() - self.progress_bar.value())
@ -489,41 +489,41 @@ class BibleUpgradeForm(OpenLPWizard):
self.increment_progress_bar(translate('BiblesPlugin.UpgradeWizardForm', self.increment_progress_bar(translate('BiblesPlugin.UpgradeWizardForm',
'Upgrading Bible %s of %s: "%s"\nUpgrading %s ...') % 'Upgrading Bible %s of %s: "%s"\nUpgrading %s ...') %
(number + 1, max_bibles, 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) book_ref_id = self.new_bibles[number].get_book_ref_id_by_name(book[u'name'], len(books), language_id)
if not book_ref_id: if not book_ref_id:
log.warn(u'Upgrading books from %s " failed - aborted by user' % name) log.warn(u'Upgrading books from %s " failed - aborted by user' % name)
self.newbibles[number].session.close() self.new_bibles[number].session.close()
del self.newbibles[number] del self.new_bibles[number]
self.success[number] = False self.success[number] = False
break break
book_details = BiblesResourcesDB.get_book_by_id(book_ref_id) book_details = BiblesResourcesDB.get_book_by_id(book_ref_id)
db_book = self.newbibles[number].create_book(book[u'name'], db_book = self.new_bibles[number].create_book(book[u'name'],
book_ref_id, book_details[u'testament_id']) book_ref_id, book_details[u'testament_id'])
verses = old_bible.get_verses(book[u'id']) verses = old_bible.get_verses(book[u'id'])
if not verses: if not verses:
log.warn(u'No verses found to import for book "%s"', book[u'name']) log.warn(u'No verses found to import for book "%s"', book[u'name'])
self.newbibles[number].delete_book(db_book) self.new_bibles[number].delete_book(db_book)
continue continue
for verse in verses: for verse in verses:
if self.stop_import_flag: if self.stop_import_flag:
self.success[number] = False self.success[number] = False
break break
self.newbibles[number].create_verse(db_book.id, self.new_bibles[number].create_verse(db_book.id,
int(verse[u'chapter']), int(verse[u'chapter']),
int(verse[u'verse']), unicode(verse[u'text'])) int(verse[u'verse']), unicode(verse[u'text']))
self.application.process_events() self.application.process_events()
self.newbibles[number].session.commit() self.new_bibles[number].session.commit()
if not self.success.get(number, True): if not self.success.get(number, True):
self.increment_progress_bar(translate('BiblesPlugin.UpgradeWizardForm', self.increment_progress_bar(translate('BiblesPlugin.UpgradeWizardForm',
'Upgrading Bible %s of %s: "%s"\nFailed') % (number + 1, max_bibles, name), 'Upgrading Bible %s of %s: "%s"\nFailed') % (number + 1, max_bibles, name),
self.progress_bar.maximum() - self.progress_bar.value()) self.progress_bar.maximum() - self.progress_bar.value())
else: else:
self.success[number] = True self.success[number] = True
self.newbibles[number].save_meta(u'name', name) self.new_bibles[number].save_meta(u'name', name)
self.increment_progress_bar(translate('BiblesPlugin.UpgradeWizardForm', self.increment_progress_bar(translate('BiblesPlugin.UpgradeWizardForm',
'Upgrading Bible %s of %s: "%s"\nComplete') % (number + 1, max_bibles, name)) 'Upgrading Bible %s of %s: "%s"\nComplete') % (number + 1, max_bibles, name))
if number in self.newbibles: if number in self.new_bibles:
self.newbibles[number].session.close() self.new_bibles[number].session.close()
# Close the last bible's connection if possible. # Close the last bible's connection if possible.
if old_bible is not None: if old_bible is not None:
old_bible.close_connection() old_bible.close_connection()

View File

@ -33,66 +33,66 @@ from openlp.core.lib import translate
from openlp.core.lib.ui import create_button_box from openlp.core.lib.ui import create_button_box
class Ui_BookNameDialog(object): class Ui_BookNameDialog(object):
def setupUi(self, bookNameDialog): def setupUi(self, book_name_dialog):
bookNameDialog.setObjectName(u'bookNameDialog') book_name_dialog.setObjectName(u'book_name_dialog')
bookNameDialog.resize(400, 271) book_name_dialog.resize(400, 271)
self.bookNameLayout = QtGui.QVBoxLayout(bookNameDialog) self.book_name_layout = QtGui.QVBoxLayout(book_name_dialog)
self.bookNameLayout.setSpacing(8) self.book_name_layout.setSpacing(8)
self.bookNameLayout.setMargin(8) self.book_name_layout.setMargin(8)
self.bookNameLayout.setObjectName(u'bookNameLayout') self.book_name_layout.setObjectName(u'book_name_layout')
self.infoLabel = QtGui.QLabel(bookNameDialog) self.info_label = QtGui.QLabel(book_name_dialog)
self.infoLabel.setWordWrap(True) self.info_label.setWordWrap(True)
self.infoLabel.setObjectName(u'infoLabel') self.info_label.setObjectName(u'info_label')
self.bookNameLayout.addWidget(self.infoLabel) self.book_name_layout.addWidget(self.info_label)
self.correspondingLayout = QtGui.QGridLayout() self.corresponding_layout = QtGui.QGridLayout()
self.correspondingLayout.setColumnStretch(1, 1) self.corresponding_layout.setColumnStretch(1, 1)
self.correspondingLayout.setSpacing(8) self.corresponding_layout.setSpacing(8)
self.correspondingLayout.setObjectName(u'correspondingLayout') self.corresponding_layout.setObjectName(u'corresponding_layout')
self.currentLabel = QtGui.QLabel(bookNameDialog) self.currentLabel = QtGui.QLabel(book_name_dialog)
self.currentLabel.setObjectName(u'currentLabel') self.currentLabel.setObjectName(u'currentLabel')
self.correspondingLayout.addWidget(self.currentLabel, 0, 0, 1, 1) self.corresponding_layout.addWidget(self.currentLabel, 0, 0, 1, 1)
self.currentBookLabel = QtGui.QLabel(bookNameDialog) self.current_book_label = QtGui.QLabel(book_name_dialog)
self.currentBookLabel.setObjectName(u'currentBookLabel') self.current_book_label.setObjectName(u'current_book_label')
self.correspondingLayout.addWidget(self.currentBookLabel, 0, 1, 1, 1) self.corresponding_layout.addWidget(self.current_book_label, 0, 1, 1, 1)
self.correspondingLabel = QtGui.QLabel(bookNameDialog) self.correspondingLabel = QtGui.QLabel(book_name_dialog)
self.correspondingLabel.setObjectName(u'correspondingLabel') self.correspondingLabel.setObjectName(u'correspondingLabel')
self.correspondingLayout.addWidget(self.correspondingLabel, 1, 0, 1, 1) self.corresponding_layout.addWidget(self.correspondingLabel, 1, 0, 1, 1)
self.correspondingComboBox = QtGui.QComboBox(bookNameDialog) self.corresponding_combo_box = QtGui.QComboBox(book_name_dialog)
self.correspondingComboBox.setObjectName(u'correspondingComboBox') self.corresponding_combo_box.setObjectName(u'corresponding_combo_box')
self.correspondingLayout.addWidget(self.correspondingComboBox, 1, 1, 1, 1) self.corresponding_layout.addWidget(self.corresponding_combo_box, 1, 1, 1, 1)
self.bookNameLayout.addLayout(self.correspondingLayout) self.book_name_layout.addLayout(self.corresponding_layout)
self.optionsGroupBox = QtGui.QGroupBox(bookNameDialog) self.options_group_box = QtGui.QGroupBox(book_name_dialog)
self.optionsGroupBox.setObjectName(u'optionsGroupBox') self.options_group_box.setObjectName(u'options_group_box')
self.optionsLayout = QtGui.QVBoxLayout(self.optionsGroupBox) self.options_layout = QtGui.QVBoxLayout(self.options_group_box)
self.optionsLayout.setSpacing(8) self.options_layout.setSpacing(8)
self.optionsLayout.setMargin(8) self.options_layout.setMargin(8)
self.optionsLayout.setObjectName(u'optionsLayout') self.options_layout.setObjectName(u'options_layout')
self.oldTestamentCheckBox = QtGui.QCheckBox(self.optionsGroupBox) self.old_testament_check_box = QtGui.QCheckBox(self.options_group_box)
self.oldTestamentCheckBox.setObjectName(u'oldTestamentCheckBox') self.old_testament_check_box.setObjectName(u'old_testament_check_box')
self.oldTestamentCheckBox.setCheckState(QtCore.Qt.Checked) self.old_testament_check_box.setCheckState(QtCore.Qt.Checked)
self.optionsLayout.addWidget(self.oldTestamentCheckBox) self.options_layout.addWidget(self.old_testament_check_box)
self.newTestamentCheckBox = QtGui.QCheckBox(self.optionsGroupBox) self.new_testament_check_box = QtGui.QCheckBox(self.options_group_box)
self.newTestamentCheckBox.setObjectName(u'newTestamentCheckBox') self.new_testament_check_box.setObjectName(u'new_testament_check_box')
self.newTestamentCheckBox.setCheckState(QtCore.Qt.Checked) self.new_testament_check_box.setCheckState(QtCore.Qt.Checked)
self.optionsLayout.addWidget(self.newTestamentCheckBox) self.options_layout.addWidget(self.new_testament_check_box)
self.apocryphaCheckBox = QtGui.QCheckBox(self.optionsGroupBox) self.apocrypha_check_box = QtGui.QCheckBox(self.options_group_box)
self.apocryphaCheckBox.setObjectName(u'apocryphaCheckBox') self.apocrypha_check_box.setObjectName(u'apocrypha_check_box')
self.apocryphaCheckBox.setCheckState(QtCore.Qt.Checked) self.apocrypha_check_box.setCheckState(QtCore.Qt.Checked)
self.optionsLayout.addWidget(self.apocryphaCheckBox) self.options_layout.addWidget(self.apocrypha_check_box)
self.bookNameLayout.addWidget(self.optionsGroupBox) self.book_name_layout.addWidget(self.options_group_box)
self.button_box = create_button_box(bookNameDialog, u'button_box', [u'cancel', u'ok']) self.button_box = create_button_box(book_name_dialog, u'button_box', [u'cancel', u'ok'])
self.bookNameLayout.addWidget(self.button_box) self.book_name_layout.addWidget(self.button_box)
self.retranslateUi(bookNameDialog) self.retranslateUi(book_name_dialog)
def retranslateUi(self, bookNameDialog): def retranslateUi(self, book_name_dialog):
bookNameDialog.setWindowTitle(translate('BiblesPlugin.BookNameDialog', 'Select Book Name')) book_name_dialog.setWindowTitle(translate('BiblesPlugin.BookNameDialog', 'Select Book Name'))
self.infoLabel.setText(translate('BiblesPlugin.BookNameDialog', self.info_label.setText(translate('BiblesPlugin.BookNameDialog',
'The following book name cannot be matched up internally. ' 'The following book name cannot be matched up internally. '
'Please select the corresponding name from the list.')) 'Please select the corresponding name from the list.'))
self.currentLabel.setText(translate('BiblesPlugin.BookNameDialog', 'Current name:')) self.currentLabel.setText(translate('BiblesPlugin.BookNameDialog', 'Current name:'))
self.correspondingLabel.setText(translate('BiblesPlugin.BookNameDialog', 'Corresponding name:')) self.correspondingLabel.setText(translate('BiblesPlugin.BookNameDialog', 'Corresponding name:'))
self.optionsGroupBox.setTitle(translate('BiblesPlugin.BookNameDialog', 'Show Books From')) self.options_group_box.setTitle(translate('BiblesPlugin.BookNameDialog', 'Show Books From'))
self.oldTestamentCheckBox.setText(translate('BiblesPlugin.BookNameDialog', 'Old Testament')) self.old_testament_check_box.setText(translate('BiblesPlugin.BookNameDialog', 'Old Testament'))
self.newTestamentCheckBox.setText(translate('BiblesPlugin.BookNameDialog', 'New Testament')) self.new_testament_check_box.setText(translate('BiblesPlugin.BookNameDialog', 'New Testament'))
self.apocryphaCheckBox.setText(translate('BiblesPlugin.BookNameDialog', 'Apocrypha')) self.apocrypha_check_box.setText(translate('BiblesPlugin.BookNameDialog', 'Apocrypha'))

View File

@ -66,61 +66,61 @@ class BookNameForm(QDialog, Ui_BookNameDialog):
""" """
Set up the signals used in the booknameform. Set up the signals used in the booknameform.
""" """
self.oldTestamentCheckBox.stateChanged.connect(self.onCheckBoxIndexChanged) self.old_testament_check_box.stateChanged.connect(self.onCheckBoxIndexChanged)
self.newTestamentCheckBox.stateChanged.connect(self.onCheckBoxIndexChanged) self.new_testament_check_box.stateChanged.connect(self.onCheckBoxIndexChanged)
self.apocryphaCheckBox.stateChanged.connect(self.onCheckBoxIndexChanged) self.apocrypha_check_box.stateChanged.connect(self.onCheckBoxIndexChanged)
def onCheckBoxIndexChanged(self, index): def onCheckBoxIndexChanged(self, index):
""" """
Reload Combobox if CheckBox state has changed Reload Combobox if CheckBox state has changed
""" """
self.reloadComboBox() self.reload_combo_box()
def reloadComboBox(self): def reload_combo_box(self):
""" """
Reload the Combobox items Reload the Combobox items
""" """
self.correspondingComboBox.clear() self.corresponding_combo_box.clear()
items = BiblesResourcesDB.get_books() items = BiblesResourcesDB.get_books()
for item in items: for item in items:
addBook = True add_book = True
for book in self.books: for book in self.books:
if book.book_reference_id == item[u'id']: if book.book_reference_id == item[u'id']:
addBook = False add_book = False
break break
if self.oldTestamentCheckBox.checkState() == QtCore.Qt.Unchecked and item[u'testament_id'] == 1: if self.old_testament_check_box.checkState() == QtCore.Qt.Unchecked and item[u'testament_id'] == 1:
addBook = False add_book = False
elif self.newTestamentCheckBox.checkState() == QtCore.Qt.Unchecked and item[u'testament_id'] == 2: elif self.new_testament_check_box.checkState() == QtCore.Qt.Unchecked and item[u'testament_id'] == 2:
addBook = False add_book = False
elif self.apocryphaCheckBox.checkState() == QtCore.Qt.Unchecked and item[u'testament_id'] == 3: elif self.apocrypha_check_box.checkState() == QtCore.Qt.Unchecked and item[u'testament_id'] == 3:
addBook = False add_book = False
if addBook: if add_book:
self.correspondingComboBox.addItem(self.book_names[item[u'abbreviation']]) self.corresponding_combo_box.addItem(self.book_names[item[u'abbreviation']])
def exec_(self, name, books, maxbooks): def exec_(self, name, books, max_books):
self.books = books self.books = books
log.debug(maxbooks) log.debug(max_books)
if maxbooks <= 27: if max_books <= 27:
self.oldTestamentCheckBox.setCheckState(QtCore.Qt.Unchecked) self.old_testament_check_box.setCheckState(QtCore.Qt.Unchecked)
self.apocryphaCheckBox.setCheckState(QtCore.Qt.Unchecked) self.apocrypha_check_box.setCheckState(QtCore.Qt.Unchecked)
elif maxbooks <= 66: elif max_books <= 66:
self.apocryphaCheckBox.setCheckState(QtCore.Qt.Unchecked) self.apocrypha_check_box.setCheckState(QtCore.Qt.Unchecked)
self.reloadComboBox() self.reload_combo_box()
self.currentBookLabel.setText(unicode(name)) self.current_book_label.setText(unicode(name))
self.correspondingComboBox.setFocus() self.corresponding_combo_box.setFocus()
return QDialog.exec_(self) return QDialog.exec_(self)
def accept(self): def accept(self):
if self.correspondingComboBox.currentText() == u'': if not self.corresponding_combo_box.currentText():
critical_error_message_box(message=translate('BiblesPlugin.BookNameForm', 'You need to select a book.')) critical_error_message_box(message=translate('BiblesPlugin.BookNameForm', 'You need to select a book.'))
self.correspondingComboBox.setFocus() self.corresponding_combo_box.setFocus()
return False return False
else: else:
cor_book = self.correspondingComboBox.currentText() cor_book = self.corresponding_combo_box.currentText()
for character in u'\\.^$*+?{}[]()': for character in u'\\.^$*+?{}[]()':
cor_book = cor_book.replace(character, u'\\' + character) cor_book = cor_book.replace(character, u'\\' + character)
books = filter(lambda key: books = filter(
re.match(cor_book, unicode(self.book_names[key]), re.UNICODE), self.book_names.keys()) lambda key: re.match(cor_book, unicode(self.book_names[key]), re.UNICODE), self.book_names.keys())
books = filter(None, map(BiblesResourcesDB.get_book, books)) books = filter(None, map(BiblesResourcesDB.get_book, books))
if books: if books:
self.book_id = books[0][u'id'] self.book_id = books[0][u'id']

View File

@ -36,118 +36,118 @@ from openlp.plugins.bibles.lib.db import BiblesResourcesDB
class Ui_EditBibleDialog(object): class Ui_EditBibleDialog(object):
def setupUi(self, editBibleDialog): def setupUi(self, edit_bible_dialog):
editBibleDialog.setObjectName(u'editBibleDialog') edit_bible_dialog.setObjectName(u'edit_bible_dialog')
editBibleDialog.resize(520, 400) edit_bible_dialog.resize(520, 400)
editBibleDialog.setWindowIcon(build_icon(u':/icon/openlp-logo-16x16.png')) edit_bible_dialog.setWindowIcon(build_icon(u':/icon/openlp-logo-16x16.png'))
editBibleDialog.setModal(True) edit_bible_dialog.setModal(True)
self.dialogLayout = QtGui.QVBoxLayout(editBibleDialog) self.dialog_layout = QtGui.QVBoxLayout(edit_bible_dialog)
self.dialogLayout.setSpacing(8) self.dialog_layout.setSpacing(8)
self.dialogLayout.setContentsMargins(8, 8, 8, 8) self.dialog_layout.setContentsMargins(8, 8, 8, 8)
self.dialogLayout.setObjectName(u'dialog_layout') self.dialog_layout.setObjectName(u'dialog_layout')
self.bibleTabWidget = QtGui.QTabWidget(editBibleDialog) self.bible_tab_widget = QtGui.QTabWidget(edit_bible_dialog)
self.bibleTabWidget.setObjectName(u'BibleTabWidget') self.bible_tab_widget.setObjectName(u'BibleTabWidget')
# Meta tab # Meta tab
self.metaTab = QtGui.QWidget() self.meta_tab = QtGui.QWidget()
self.metaTab.setObjectName(u'metaTab') self.meta_tab.setObjectName(u'meta_tab')
self.metaTabLayout = QtGui.QVBoxLayout(self.metaTab) self.meta_tab_layout = QtGui.QVBoxLayout(self.meta_tab)
self.metaTabLayout.setObjectName(u'metaTabLayout') self.meta_tab_layout.setObjectName(u'meta_tab_layout')
self.licenseDetailsGroupBox = QtGui.QGroupBox(self.metaTab) self.license_details_group_box = QtGui.QGroupBox(self.meta_tab)
self.licenseDetailsGroupBox.setObjectName(u'licenseDetailsGroupBox') self.license_details_group_box.setObjectName(u'license_details_group_box')
self.licenseDetailsLayout = QtGui.QFormLayout(self.licenseDetailsGroupBox) self.license_details_layout = QtGui.QFormLayout(self.license_details_group_box)
self.licenseDetailsLayout.setObjectName(u'licenseDetailsLayout') self.license_details_layout.setObjectName(u'license_details_layout')
self.versionNameLabel = QtGui.QLabel(self.licenseDetailsGroupBox) self.version_name_label = QtGui.QLabel(self.license_details_group_box)
self.versionNameLabel.setObjectName(u'versionNameLabel') self.version_name_label.setObjectName(u'version_name_label')
self.versionNameEdit = QtGui.QLineEdit(self.licenseDetailsGroupBox) self.version_name_edit = QtGui.QLineEdit(self.license_details_group_box)
self.versionNameEdit.setObjectName(u'versionNameEdit') self.version_name_edit.setObjectName(u'version_name_edit')
self.versionNameLabel.setBuddy(self.versionNameEdit) self.version_name_label.setBuddy(self.version_name_edit)
self.licenseDetailsLayout.addRow(self.versionNameLabel, self.versionNameEdit) self.license_details_layout.addRow(self.version_name_label, self.version_name_edit)
self.copyrightLabel = QtGui.QLabel(self.licenseDetailsGroupBox) self.copyright_label = QtGui.QLabel(self.license_details_group_box)
self.copyrightLabel.setObjectName(u'copyrightLabel') self.copyright_label.setObjectName(u'copyright_label')
self.copyrightEdit = QtGui.QLineEdit(self.licenseDetailsGroupBox) self.copyright_edit = QtGui.QLineEdit(self.license_details_group_box)
self.copyrightEdit.setObjectName(u'copyright_edit') self.copyright_edit.setObjectName(u'copyright_edit')
self.copyrightLabel.setBuddy(self.copyrightEdit) self.copyright_label.setBuddy(self.copyright_edit)
self.licenseDetailsLayout.addRow(self.copyrightLabel, self.copyrightEdit) self.license_details_layout.addRow(self.copyright_label, self.copyright_edit)
self.permissionsLabel = QtGui.QLabel(self.licenseDetailsGroupBox) self.permissions_label = QtGui.QLabel(self.license_details_group_box)
self.permissionsLabel.setObjectName(u'permissionsLabel') self.permissions_label.setObjectName(u'permissions_label')
self.permissionsEdit = QtGui.QLineEdit(self.licenseDetailsGroupBox) self.permissions_edit = QtGui.QLineEdit(self.license_details_group_box)
self.permissionsEdit.setObjectName(u'permissionsEdit') self.permissions_edit.setObjectName(u'permissions_edit')
self.permissionsLabel.setBuddy(self.permissionsEdit) self.permissions_label.setBuddy(self.permissions_edit)
self.licenseDetailsLayout.addRow(self.permissionsLabel, self.permissionsEdit) self.license_details_layout.addRow(self.permissions_label, self.permissions_edit)
self.metaTabLayout.addWidget(self.licenseDetailsGroupBox) self.meta_tab_layout.addWidget(self.license_details_group_box)
self.languageSelectionGroupBox = QtGui.QGroupBox(self.metaTab) self.language_selection_group_box = QtGui.QGroupBox(self.meta_tab)
self.languageSelectionGroupBox.setObjectName(u'languageSelectionGroupBox') self.language_selection_group_box.setObjectName(u'language_selection_group_box')
self.languageSelectionLayout = QtGui.QVBoxLayout(self.languageSelectionGroupBox) self.language_selection_layout = QtGui.QVBoxLayout(self.language_selection_group_box)
self.languageSelectionLabel = QtGui.QLabel(self.languageSelectionGroupBox) self.language_selection_label = QtGui.QLabel(self.language_selection_group_box)
self.languageSelectionLabel.setObjectName(u'languageSelectionLabel') self.language_selection_label.setObjectName(u'language_selection_label')
self.languageSelectionComboBox = QtGui.QComboBox(self.languageSelectionGroupBox) self.language_selection_combo_box = QtGui.QComboBox(self.language_selection_group_box)
self.languageSelectionComboBox.setObjectName(u'languageSelectionComboBox') self.language_selection_combo_box.setObjectName(u'language_selection_combo_box')
self.languageSelectionComboBox.addItems([u'', u'', u'', u'']) self.language_selection_combo_box.addItems([u'', u'', u'', u''])
self.languageSelectionLayout.addWidget(self.languageSelectionLabel) self.language_selection_layout.addWidget(self.language_selection_label)
self.languageSelectionLayout.addWidget(self.languageSelectionComboBox) self.language_selection_layout.addWidget(self.language_selection_combo_box)
self.metaTabLayout.addWidget(self.languageSelectionGroupBox) self.meta_tab_layout.addWidget(self.language_selection_group_box)
self.metaTabLayout.addStretch() self.meta_tab_layout.addStretch()
self.bibleTabWidget.addTab(self.metaTab, u'') self.bible_tab_widget.addTab(self.meta_tab, u'')
# Book name tab # Book name tab
self.bookNameTab = QtGui.QWidget() self.book_name_tab = QtGui.QWidget()
self.bookNameTab.setObjectName(u'bookNameTab') self.book_name_tab.setObjectName(u'book_name_tab')
self.bookNameTabLayout = QtGui.QVBoxLayout(self.bookNameTab) self.book_name_tab_layout = QtGui.QVBoxLayout(self.book_name_tab)
self.bookNameTabLayout.setObjectName(u'bookNameTabLayout') self.book_name_tab_layout.setObjectName(u'book_name_tab_layout')
self.bookNameNotice = QtGui.QLabel(self.bookNameTab) self.book_name_notice = QtGui.QLabel(self.book_name_tab)
self.bookNameNotice.setObjectName(u'bookNameNotice') self.book_name_notice.setObjectName(u'book_name_notice')
self.bookNameNotice.setWordWrap(True) self.book_name_notice.setWordWrap(True)
self.bookNameTabLayout.addWidget(self.bookNameNotice) self.book_name_tab_layout.addWidget(self.book_name_notice)
self.scrollArea = QtGui.QScrollArea(self.bookNameTab) self.scroll_area = QtGui.QScrollArea(self.book_name_tab)
self.scrollArea.setWidgetResizable(True) self.scroll_area.setWidgetResizable(True)
self.scrollArea.setObjectName(u'scrollArea') self.scroll_area.setObjectName(u'scroll_area')
self.scrollArea.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.scroll_area.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.bookNameWidget = QtGui.QWidget(self.scrollArea) self.book_name_widget = QtGui.QWidget(self.scroll_area)
self.bookNameWidget.setObjectName(u'bookNameWidget') self.book_name_widget.setObjectName(u'book_name_widget')
self.bookNameWidgetLayout = QtGui.QFormLayout(self.bookNameWidget) self.book_name_widget_layout = QtGui.QFormLayout(self.book_name_widget)
self.bookNameWidgetLayout.setObjectName(u'bookNameWidgetLayout') self.book_name_widget_layout.setObjectName(u'book_name_widget_layout')
self.bookNameLabel = {} self.book_name_label = {}
self.bookNameEdit= {} self.book_name_edit= {}
for book in BiblesResourcesDB.get_books(): for book in BiblesResourcesDB.get_books():
self.bookNameLabel[book[u'abbreviation']] = QtGui.QLabel(self.bookNameWidget) self.book_name_label[book[u'abbreviation']] = QtGui.QLabel(self.book_name_widget)
self.bookNameLabel[book[u'abbreviation']].setObjectName(u'bookNameLabel[%s]' % book[u'abbreviation']) self.book_name_label[book[u'abbreviation']].setObjectName(u'book_name_label[%s]' % book[u'abbreviation'])
self.bookNameEdit[book[u'abbreviation']] = QtGui.QLineEdit(self.bookNameWidget) self.book_name_edit[book[u'abbreviation']] = QtGui.QLineEdit(self.book_name_widget)
self.bookNameEdit[book[u'abbreviation']].setObjectName(u'bookNameEdit[%s]' % book[u'abbreviation']) self.book_name_edit[book[u'abbreviation']].setObjectName(u'book_name_edit[%s]' % book[u'abbreviation'])
self.bookNameWidgetLayout.addRow( self.book_name_widget_layout.addRow(
self.bookNameLabel[book[u'abbreviation']], self.book_name_label[book[u'abbreviation']],
self.bookNameEdit[book[u'abbreviation']]) self.book_name_edit[book[u'abbreviation']])
self.scrollArea.setWidget(self.bookNameWidget) self.scroll_area.setWidget(self.book_name_widget)
self.bookNameTabLayout.addWidget(self.scrollArea) self.book_name_tab_layout.addWidget(self.scroll_area)
self.bookNameTabLayout.addStretch() self.book_name_tab_layout.addStretch()
self.bibleTabWidget.addTab(self.bookNameTab, u'') self.bible_tab_widget.addTab(self.book_name_tab, u'')
# Last few bits # Last few bits
self.dialogLayout.addWidget(self.bibleTabWidget) self.dialog_layout.addWidget(self.bible_tab_widget)
self.button_box = create_button_box(editBibleDialog, u'button_box', [u'cancel', u'save']) self.button_box = create_button_box(edit_bible_dialog, u'button_box', [u'cancel', u'save'])
self.dialogLayout.addWidget(self.button_box) self.dialog_layout.addWidget(self.button_box)
self.retranslateUi(editBibleDialog) self.retranslateUi(edit_bible_dialog)
QtCore.QMetaObject.connectSlotsByName(editBibleDialog) QtCore.QMetaObject.connectSlotsByName(edit_bible_dialog)
def retranslateUi(self, editBibleDialog): def retranslateUi(self, edit_bible_dialog):
self.book_names = BibleStrings().BookNames self.book_names = BibleStrings().BookNames
editBibleDialog.setWindowTitle(translate('BiblesPlugin.EditBibleForm', 'Bible Editor')) edit_bible_dialog.setWindowTitle(translate('BiblesPlugin.EditBibleForm', 'Bible Editor'))
# Meta tab # Meta tab
self.bibleTabWidget.setTabText( self.bibleTabWidget.indexOf(self.metaTab), self.bible_tab_widget.setTabText( self.bible_tab_widget.indexOf(self.meta_tab),
translate('SongsPlugin.EditBibleForm', 'Meta Data')) translate('SongsPlugin.EditBibleForm', 'Meta Data'))
self.licenseDetailsGroupBox.setTitle(translate('BiblesPlugin.EditBibleForm', 'License Details')) self.license_details_group_box.setTitle(translate('BiblesPlugin.EditBibleForm', 'License Details'))
self.versionNameLabel.setText(translate('BiblesPlugin.EditBibleForm', 'Version name:')) self.version_name_label.setText(translate('BiblesPlugin.EditBibleForm', 'Version name:'))
self.copyrightLabel.setText(translate('BiblesPlugin.EditBibleForm', 'Copyright:')) self.copyright_label.setText(translate('BiblesPlugin.EditBibleForm', 'Copyright:'))
self.permissionsLabel.setText(translate('BiblesPlugin.EditBibleForm', 'Permissions:')) self.permissions_label.setText(translate('BiblesPlugin.EditBibleForm', 'Permissions:'))
self.languageSelectionGroupBox.setTitle(translate('BiblesPlugin.EditBibleForm', 'Default Bible Language')) self.language_selection_group_box.setTitle(translate('BiblesPlugin.EditBibleForm', 'Default Bible Language'))
self.languageSelectionLabel.setText(translate('BiblesPlugin.EditBibleForm', self.language_selection_label.setText(translate('BiblesPlugin.EditBibleForm',
'Book name language in search field, search results and on display:')) 'Book name language in search field, search results and on display:'))
self.languageSelectionComboBox.setItemText(0, translate('BiblesPlugin.EditBibleForm', 'Global Settings')) self.language_selection_combo_box.setItemText(0, translate('BiblesPlugin.EditBibleForm', 'Global Settings'))
self.languageSelectionComboBox.setItemText(LanguageSelection.Bible + 1, self.language_selection_combo_box.setItemText(LanguageSelection.Bible + 1,
translate('BiblesPlugin.EditBibleForm', 'Bible Language')) translate('BiblesPlugin.EditBibleForm', 'Bible Language'))
self.languageSelectionComboBox.setItemText(LanguageSelection.Application + 1, self.language_selection_combo_box.setItemText(LanguageSelection.Application + 1,
translate('BiblesPlugin.EditBibleForm', 'Application Language')) translate('BiblesPlugin.EditBibleForm', 'Application Language'))
self.languageSelectionComboBox.setItemText(LanguageSelection.English + 1, self.language_selection_combo_box.setItemText(LanguageSelection.English + 1,
translate('BiblesPlugin.EditBibleForm', 'English')) translate('BiblesPlugin.EditBibleForm', 'English'))
# Book name tab # Book name tab
self.bibleTabWidget.setTabText(self.bibleTabWidget.indexOf(self.bookNameTab), self.bible_tab_widget.setTabText(self.bible_tab_widget.indexOf(self.book_name_tab),
translate('SongsPlugin.EditBibleForm', 'Custom Book Names')) translate('SongsPlugin.EditBibleForm', 'Custom Book Names'))
for book in BiblesResourcesDB.get_books(): for book in BiblesResourcesDB.get_books():
self.bookNameLabel[book[u'abbreviation']].setText(u'%s:' % unicode(self.book_names[book[u'abbreviation']])) self.book_name_label[book[u'abbreviation']].setText(u'%s:' % unicode(self.book_names[book[u'abbreviation']]))

View File

@ -65,33 +65,33 @@ class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog):
""" """
log.debug(u'Load Bible') log.debug(u'Load Bible')
self.bible = bible self.bible = bible
self.versionNameEdit.setText(self.manager.get_meta_data(self.bible, u'name').value) self.version_name_edit.setText(self.manager.get_meta_data(self.bible, u'name').value)
self.copyrightEdit.setText(self.manager.get_meta_data(self.bible, u'copyright').value) self.copyright_edit.setText(self.manager.get_meta_data(self.bible, u'copyright').value)
self.permissionsEdit.setText(self.manager.get_meta_data(self.bible, u'permissions').value) self.permissions_edit.setText(self.manager.get_meta_data(self.bible, u'permissions').value)
book_name_language = self.manager.get_meta_data(self.bible, u'book_name_language') book_name_language = self.manager.get_meta_data(self.bible, u'book_name_language')
if book_name_language and book_name_language.value != u'None': if book_name_language and book_name_language.value != u'None':
self.languageSelectionComboBox.setCurrentIndex(int(book_name_language.value) + 1) self.language_selection_combo_box.setCurrentIndex(int(book_name_language.value) + 1)
self.books = {} self.books = {}
self.webbible = self.manager.get_meta_data(self.bible, u'download_source') self.webbible = self.manager.get_meta_data(self.bible, u'download_source')
if self.webbible: if self.webbible:
self.bookNameNotice.setText(translate('BiblesPlugin.EditBibleForm', self.book_name_notice.setText(translate('BiblesPlugin.EditBibleForm',
'This is a Web Download Bible.\nIt is not possible to customize the Book Names.')) 'This is a Web Download Bible.\nIt is not possible to customize the Book Names.'))
self.scrollArea.hide() self.scroll_area.hide()
else: else:
self.bookNameNotice.setText(translate('BiblesPlugin.EditBibleForm', self.book_name_notice.setText(translate('BiblesPlugin.EditBibleForm',
'To use the customized book names, "Bible language" must be selected on the Meta Data tab or, ' 'To use the customized book names, "Bible language" must be selected on the Meta Data tab or, '
'if "Global settings" is selected, on the Bible page in Configure OpenLP.')) 'if "Global settings" is selected, on the Bible page in Configure OpenLP.'))
for book in BiblesResourcesDB.get_books(): for book in BiblesResourcesDB.get_books():
self.books[book[u'abbreviation']] = self.manager.get_book_by_id(self.bible, book[u'id']) self.books[book[u'abbreviation']] = self.manager.get_book_by_id(self.bible, book[u'id'])
if self.books[book[u'abbreviation']] and not self.webbible: if self.books[book[u'abbreviation']] and not self.webbible:
self.bookNameEdit[book[u'abbreviation']].setText(self.books[book[u'abbreviation']].name) self.book_name_edit[book[u'abbreviation']].setText(self.books[book[u'abbreviation']].name)
else: else:
# It is necessary to remove the Widget otherwise there still # It is necessary to remove the Widget otherwise there still
# exists the vertical spacing in QFormLayout # exists the vertical spacing in QFormLayout
self.bookNameWidgetLayout.removeWidget(self.bookNameLabel[book[u'abbreviation']]) self.book_name_widget_layout.removeWidget(self.book_name_label[book[u'abbreviation']])
self.bookNameLabel[book[u'abbreviation']].hide() self.book_name_label[book[u'abbreviation']].hide()
self.bookNameWidgetLayout.removeWidget(self.bookNameEdit[book[u'abbreviation']]) self.book_name_widget_layout.removeWidget(self.book_name_edit[book[u'abbreviation']])
self.bookNameEdit[book[u'abbreviation']].hide() self.book_name_edit[book[u'abbreviation']].hide()
def reject(self): def reject(self):
""" """
@ -106,10 +106,10 @@ class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog):
Exit Dialog and save data Exit Dialog and save data
""" """
log.debug(u'BibleEditForm.accept') log.debug(u'BibleEditForm.accept')
version = self.versionNameEdit.text() version = self.version_name_edit.text()
copyright = self.copyrightEdit.text() copyright = self.copyright_edit.text()
permissions = self.permissionsEdit.text() permissions = self.permissions_edit.text()
book_name_language = self.languageSelectionComboBox.currentIndex() - 1 book_name_language = self.language_selection_combo_box.currentIndex() - 1
if book_name_language == -1: if book_name_language == -1:
book_name_language = None book_name_language = None
if not self.validateMeta(version, copyright): if not self.validateMeta(version, copyright):
@ -118,7 +118,7 @@ class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog):
custom_names = {} custom_names = {}
for abbr, book in self.books.iteritems(): for abbr, book in self.books.iteritems():
if book: if book:
custom_names[abbr] = self.bookNameEdit[abbr].text() custom_names[abbr] = self.book_name_edit[abbr].text()
if book.name != custom_names[abbr]: if book.name != custom_names[abbr]:
if not self.validateBook(custom_names[abbr], abbr): if not self.validateBook(custom_names[abbr], abbr):
return return
@ -139,19 +139,19 @@ class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog):
Validate the Meta before saving. Validate the Meta before saving.
""" """
if not name: if not name:
self.versionNameEdit.setFocus() self.version_name_edit.setFocus()
critical_error_message_box(UiStrings().EmptyField, critical_error_message_box(UiStrings().EmptyField,
translate('BiblesPlugin.BibleEditForm', 'You need to specify a version name for your Bible.')) translate('BiblesPlugin.BibleEditForm', 'You need to specify a version name for your Bible.'))
return False return False
elif not copyright: elif not copyright:
self.copyrightEdit.setFocus() self.copyright_edit.setFocus()
critical_error_message_box(UiStrings().EmptyField, critical_error_message_box(UiStrings().EmptyField,
translate('BiblesPlugin.BibleEditForm', translate('BiblesPlugin.BibleEditForm',
'You need to set a copyright for your Bible. Bibles in the Public Domain need to be marked as such.')) 'You need to set a copyright for your Bible. Bibles in the Public Domain need to be marked as such.'))
return False return False
elif self.manager.exists(name) and self.manager.get_meta_data(self.bible, u'name').value != \ elif self.manager.exists(name) and self.manager.get_meta_data(self.bible, u'name').value != \
name: name:
self.versionNameEdit.setFocus() self.version_name_edit.setFocus()
critical_error_message_box(translate('BiblesPlugin.BibleEditForm', 'Bible Exists'), critical_error_message_box(translate('BiblesPlugin.BibleEditForm', 'Bible Exists'),
translate('BiblesPlugin.BibleEditForm', 'This Bible already exists. Please import ' translate('BiblesPlugin.BibleEditForm', 'This Bible already exists. Please import '
'a different Bible or first delete the existing one.')) 'a different Bible or first delete the existing one.'))
@ -164,13 +164,13 @@ class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog):
""" """
book_regex = re.compile(u'[\d]*[^\d]+$') book_regex = re.compile(u'[\d]*[^\d]+$')
if not new_book_name: if not new_book_name:
self.bookNameEdit[abbreviation].setFocus() self.book_name_edit[abbreviation].setFocus()
critical_error_message_box(UiStrings().EmptyField, critical_error_message_box(UiStrings().EmptyField,
translate('BiblesPlugin.BibleEditForm', 'You need to specify a book name for "%s".') % translate('BiblesPlugin.BibleEditForm', 'You need to specify a book name for "%s".') %
self.book_names[abbreviation]) self.book_names[abbreviation])
return False return False
elif not book_regex.match(new_book_name): elif not book_regex.match(new_book_name):
self.bookNameEdit[abbreviation].setFocus() self.book_name_edit[abbreviation].setFocus()
critical_error_message_box(UiStrings().EmptyField, critical_error_message_box(UiStrings().EmptyField,
translate('BiblesPlugin.BibleEditForm', translate('BiblesPlugin.BibleEditForm',
'The book name "%s" is not correct.\nNumbers can only be used at the beginning and must\nbe ' 'The book name "%s" is not correct.\nNumbers can only be used at the beginning and must\nbe '
@ -180,8 +180,8 @@ class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog):
if book: if book:
if abbr == abbreviation: if abbr == abbreviation:
continue continue
if self.bookNameEdit[abbr].text() == new_book_name: if self.book_name_edit[abbr].text() == new_book_name:
self.bookNameEdit[abbreviation].setFocus() self.book_name_edit[abbreviation].setFocus()
critical_error_message_box( critical_error_message_box(
translate('BiblesPlugin.BibleEditForm', 'Duplicate Book Name'), translate('BiblesPlugin.BibleEditForm', 'Duplicate Book Name'),
translate('BiblesPlugin.BibleEditForm', 'The Book Name "%s" has been entered more than once.') translate('BiblesPlugin.BibleEditForm', 'The Book Name "%s" has been entered more than once.')

View File

@ -33,44 +33,44 @@ from openlp.core.lib import translate
from openlp.core.lib.ui import create_button_box from openlp.core.lib.ui import create_button_box
class Ui_LanguageDialog(object): class Ui_LanguageDialog(object):
def setupUi(self, languageDialog): def setupUi(self, language_dialog):
languageDialog.setObjectName(u'languageDialog') language_dialog.setObjectName(u'language_dialog')
languageDialog.resize(400, 165) language_dialog.resize(400, 165)
self.languageLayout = QtGui.QVBoxLayout(languageDialog) self.language_layout = QtGui.QVBoxLayout(language_dialog)
self.languageLayout.setSpacing(8) self.language_layout.setSpacing(8)
self.languageLayout.setMargin(8) self.language_layout.setMargin(8)
self.languageLayout.setObjectName(u'languageLayout') self.language_layout.setObjectName(u'language_layout')
self.bibleLabel = QtGui.QLabel(languageDialog) self.bible_label = QtGui.QLabel(language_dialog)
self.bibleLabel.setObjectName(u'bibleLabel') self.bible_label.setObjectName(u'bible_label')
self.languageLayout.addWidget(self.bibleLabel) self.language_layout.addWidget(self.bible_label)
self.infoLabel = QtGui.QLabel(languageDialog) self.info_label = QtGui.QLabel(language_dialog)
self.infoLabel.setWordWrap(True) self.info_label.setWordWrap(True)
self.infoLabel.setObjectName(u'infoLabel') self.info_label.setObjectName(u'info_label')
self.languageLayout.addWidget(self.infoLabel) self.language_layout.addWidget(self.info_label)
self.languageHBoxLayout = QtGui.QHBoxLayout() self.language_h_box_layout = QtGui.QHBoxLayout()
self.languageHBoxLayout.setSpacing(8) self.language_h_box_layout.setSpacing(8)
self.languageHBoxLayout.setObjectName(u'languageHBoxLayout') self.language_h_box_layout.setObjectName(u'language_h_box_layout')
self.languageLabel = QtGui.QLabel(languageDialog) self.language_label = QtGui.QLabel(language_dialog)
self.languageLabel.setObjectName(u'languageLabel') self.language_label.setObjectName(u'language_label')
self.languageHBoxLayout.addWidget(self.languageLabel) self.language_h_box_layout.addWidget(self.language_label)
self.languageComboBox = QtGui.QComboBox(languageDialog) self.language_combo_box = QtGui.QComboBox(language_dialog)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.Fixed) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0) sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0) sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.languageComboBox.sizePolicy().hasHeightForWidth()) sizePolicy.setHeightForWidth(self.language_combo_box.sizePolicy().hasHeightForWidth())
self.languageComboBox.setSizePolicy(sizePolicy) self.language_combo_box.setSizePolicy(sizePolicy)
self.languageComboBox.setObjectName(u'languageComboBox') self.language_combo_box.setObjectName(u'language_combo_box')
self.languageHBoxLayout.addWidget(self.languageComboBox) self.language_h_box_layout.addWidget(self.language_combo_box)
self.languageLayout.addLayout(self.languageHBoxLayout) self.language_layout.addLayout(self.language_h_box_layout)
self.button_box = create_button_box(languageDialog, u'button_box', [u'cancel', u'ok']) self.button_box = create_button_box(language_dialog, u'button_box', [u'cancel', u'ok'])
self.languageLayout.addWidget(self.button_box) self.language_layout.addWidget(self.button_box)
self.retranslateUi(languageDialog) self.retranslateUi(language_dialog)
def retranslateUi(self, languageDialog): def retranslateUi(self, language_dialog):
languageDialog.setWindowTitle(translate('BiblesPlugin.LanguageDialog', 'Select Language')) language_dialog.setWindowTitle(translate('BiblesPlugin.LanguageDialog', 'Select Language'))
self.bibleLabel.setText(translate('BiblesPlugin.LanguageDialog', '')) self.bible_label.setText(translate('BiblesPlugin.LanguageDialog', ''))
self.infoLabel.setText(translate('BiblesPlugin.LanguageDialog', self.info_label.setText(translate('BiblesPlugin.LanguageDialog',
'OpenLP is unable to determine the language of this translation of the Bible. Please select the language ' 'OpenLP is unable to determine the language of this translation of the Bible. Please select the language '
'from the list below.')) 'from the list below.'))
self.languageLabel.setText(translate('BiblesPlugin.LanguageDialog', 'Language:')) self.language_label.setText(translate('BiblesPlugin.LanguageDialog', 'Language:'))

View File

@ -40,8 +40,10 @@ from openlp.plugins.bibles.forms.languagedialog import \
Ui_LanguageDialog Ui_LanguageDialog
from openlp.plugins.bibles.lib.db import BiblesResourcesDB from openlp.plugins.bibles.lib.db import BiblesResourcesDB
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
class LanguageForm(QDialog, Ui_LanguageDialog): class LanguageForm(QDialog, Ui_LanguageDialog):
""" """
Class to manage a dialog which ask the user for a language. Class to manage a dialog which ask the user for a language.
@ -56,19 +58,17 @@ class LanguageForm(QDialog, Ui_LanguageDialog):
self.setupUi(self) self.setupUi(self)
def exec_(self, bible_name): def exec_(self, bible_name):
self.languageComboBox.addItem(u'') self.language_combo_box.addItem(u'')
if bible_name: if bible_name:
self.bibleLabel.setText(unicode(bible_name)) self.bible_label.setText(unicode(bible_name))
items = BiblesResourcesDB.get_languages() items = BiblesResourcesDB.get_languages()
self.languageComboBox.addItems([item[u'name'] for item in items]) self.language_combo_box.addItems([item[u'name'] for item in items])
return QDialog.exec_(self) return QDialog.exec_(self)
def accept(self): def accept(self):
if not self.languageComboBox.currentText(): if not self.language_combo_box.currentText():
critical_error_message_box( critical_error_message_box(message=translate('BiblesPlugin.LanguageForm', 'You need to choose a language.'))
message=translate('BiblesPlugin.LanguageForm', self.language_combo_box.setFocus()
'You need to choose a language.'))
self.languageComboBox.setFocus()
return False return False
else: else:
return QDialog.accept(self) return QDialog.accept(self)

View File

@ -38,9 +38,11 @@ from openlp.core.lib import Settings, translate
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
REFERENCE_MATCHES = {} REFERENCE_MATCHES = {}
REFERENCE_SEPARATORS = {} REFERENCE_SEPARATORS = {}
class LayoutStyle(object): class LayoutStyle(object):
""" """
An enumeration for bible screen layout styles. An enumeration for bible screen layout styles.
@ -62,8 +64,7 @@ class DisplayStyle(object):
class LanguageSelection(object): class LanguageSelection(object):
""" """
An enumeration for bible bookname language. An enumeration for bible bookname language. And standard strings for use throughout the bibles plugin.
And standard strings for use throughout the bibles plugin.
""" """
Bible = 0 Bible = 0
Application = 1 Application = 1
@ -178,8 +179,7 @@ class BibleStrings(object):
def update_reference_separators(): def update_reference_separators():
""" """
Updates separators and matches for parsing and formating scripture Updates separators and matches for parsing and formating scripture references.
references.
""" """
default_separators = translate('BiblesPlugin', default_separators = translate('BiblesPlugin',
':|v|V|verse|verses;;-|to;;,|and;;end Double-semicolon delimited separators for parsing references. ' ':|v|V|verse|verses;;-|to;;,|and;;end Double-semicolon delimited separators for parsing references. '
@ -245,9 +245,8 @@ def get_reference_match(match_type):
def parse_reference(reference, bible, language_selection, book_ref_id=False): def parse_reference(reference, bible, language_selection, book_ref_id=False):
""" """
This is the next generation über-awesome function that takes a person's This is the next generation über-awesome function that takes a person's typed in string and converts it to a list
typed in string and converts it to a list of references to be queried from of references to be queried from the Bible database files.
the Bible database files.
``reference`` ``reference``
A string. The Bible reference to parse. A string. The Bible reference to parse.
@ -256,16 +255,14 @@ def parse_reference(reference, bible, language_selection, book_ref_id=False):
A object. The Bible database object. A object. The Bible database object.
``language_selection`` ``language_selection``
An int. The language selection the user has choosen in settings An int. The language selection the user has choosen in settings section.
section.
``book_ref_id`` ``book_ref_id``
A string. The book reference id. A string. The book reference id.
Returns ``None`` or a reference list. Returns ``None`` or a reference list.
The reference list is a list of tuples, with each tuple structured like The reference list is a list of tuples, with each tuple structured like this::
this::
(book, chapter, from_verse, to_verse) (book, chapter, from_verse, to_verse)
@ -275,8 +272,7 @@ def parse_reference(reference, bible, language_selection, book_ref_id=False):
**Reference string details:** **Reference string details:**
Each reference starts with the book name and a chapter number. These are Each reference starts with the book name and a chapter number. These are both mandatory.
both mandatory.
* ``John 3`` refers to Gospel of John chapter 3 * ``John 3`` refers to Gospel of John chapter 3
@ -289,38 +285,31 @@ def parse_reference(reference, bible, language_selection, book_ref_id=False):
* ``John 3:16`` refers to John chapter 3 verse 16 * ``John 3:16`` refers to John chapter 3 verse 16
* ``John 3:16-4:3`` refers to John chapter 3 verse 16 to chapter 4 verse 3 * ``John 3:16-4:3`` refers to John chapter 3 verse 16 to chapter 4 verse 3
After a verse reference all further single values are treat as verse in After a verse reference all further single values are treat as verse in the last selected chapter.
the last selected chapter.
* ``John 3:16-18`` refers to John chapter 3 verses 16 to 18 * ``John 3:16-18`` refers to John chapter 3 verses 16 to 18
After a list separator it is possible to refer to additional verses. They After a list separator it is possible to refer to additional verses. They are build analog to the first ones. This
are build analog to the first ones. This way it is possible to define each way it is possible to define each number of verse references. It is not possible to refer to verses in additional
number of verse references. It is not possible to refer to verses in books.
additional books.
* ``John 3:16,18`` refers to John chapter 3 verses 16 and 18 * ``John 3:16,18`` refers to John chapter 3 verses 16 and 18
* ``John 3:16-18,20`` refers to John chapter 3 verses 16 to 18 and 20 * ``John 3:16-18,20`` refers to John chapter 3 verses 16 to 18 and 20
* ``John 3:16-18,4:1`` refers to John chapter 3 verses 16 to 18 and * ``John 3:16-18,4:1`` refers to John chapter 3 verses 16 to 18 and chapter 4 verse 1
chapter 4 verse 1
If there is a range separator without further verse declaration the last If there is a range separator without further verse declaration the last refered chapter is addressed until the end.
refered chapter is addressed until the end.
``range_regex`` is a regular expression which matches for verse range ``range_regex`` is a regular expression which matches for verse range declarations:
declarations:
``(?:(?P<from_chapter>[0-9]+)%(sep_v)s)?`` ``(?:(?P<from_chapter>[0-9]+)%(sep_v)s)?``
It starts with a optional chapter reference ``from_chapter`` followed by It starts with a optional chapter reference ``from_chapter`` followed by a verse separator.
a verse separator.
``(?P<from_verse>[0-9]+)`` ``(?P<from_verse>[0-9]+)``
The verse reference ``from_verse`` is manditory The verse reference ``from_verse`` is manditory
``(?P<range_to>%(sep_r)s(?:`` ... ``|%(sep_e)s)?)?`` ``(?P<range_to>%(sep_r)s(?:`` ... ``|%(sep_e)s)?)?``
A ``range_to`` declaration is optional. It starts with a range separator A ``range_to`` declaration is optional. It starts with a range separator and contains optional a chapter and
and contains optional a chapter and verse declaration or a end verse declaration or a end separator.
separator.
``(?:(?P<to_chapter>[0-9]+)%(sep_v)s)?`` ``(?:(?P<to_chapter>[0-9]+)%(sep_v)s)?``
The ``to_chapter`` reference with separator is equivalent to group 1. The ``to_chapter`` reference with separator is equivalent to group 1.
@ -328,17 +317,15 @@ def parse_reference(reference, bible, language_selection, book_ref_id=False):
``(?P<to_verse>[0-9]+)`` ``(?P<to_verse>[0-9]+)``
The ``to_verse`` reference is equivalent to group 2. The ``to_verse`` reference is equivalent to group 2.
The full reference is matched against get_reference_match(u'full'). This The full reference is matched against get_reference_match(u'full'). This regular expression looks like this:
regular expression looks like this:
``^\s*(?!\s)(?P<book>[\d]*[^\d]+)(?<!\s)\s*`` ``^\s*(?!\s)(?P<book>[\d]*[^\d]+)(?<!\s)\s*``
The ``book`` group starts with the first non-whitespace character. There The ``book`` group starts with the first non-whitespace character. There are optional leading digits followed by
are optional leading digits followed by non-digits. The group ends non-digits. The group ends before the whitspace in front of the next digit.
before the whitspace in front of the next digit.
``(?P<ranges>(?:%(range_regex)s(?:%(sep_l)s(?!\s*$)|(?=\s*$)))+)\s*$`` ``(?P<ranges>(?:%(range_regex)s(?:%(sep_l)s(?!\s*$)|(?=\s*$)))+)\s*$``
The second group contains all ``ranges``. This can be multiple The second group contains all ``ranges``. This can be multiple declarations of range_regex separated by a list
declarations of range_regex separated by a list separator. separator.
""" """
log.debug(u'parse_reference("%s")', reference) log.debug(u'parse_reference("%s")', reference)

View File

@ -27,8 +27,7 @@
# Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Temple Place, Suite 330, Boston, MA 02111-1307 USA #
############################################################################### ###############################################################################
""" """
The :mod:`cvsbible` modules provides a facility to import bibles from a set of The :mod:`cvsbible` modules provides a facility to import bibles from a set of CSV files.
CSV files.
The module expects two mandatory files containing the books and the verses. The module expects two mandatory files containing the books and the verses.
@ -55,8 +54,7 @@ There are two acceptable formats of the verses file. They are:
or or
"Genesis",1,2,"And the earth was without form, and void; and...." "Genesis",1,2,"And the earth was without form, and void; and...."
All CSV files are expected to use a comma (',') as the delimiter and double All CSV files are expected to use a comma (',') as the delimiter and double quotes ('"') as the quote symbol.
quotes ('"') as the quote symbol.
""" """
import logging import logging
import chardet import chardet
@ -65,8 +63,10 @@ import csv
from openlp.core.lib import translate from openlp.core.lib import translate
from openlp.plugins.bibles.lib.db import BibleDB, BiblesResourcesDB from openlp.plugins.bibles.lib.db import BibleDB, BiblesResourcesDB
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
class CSVBible(BibleDB): class CSVBible(BibleDB):
""" """
This class provides a specialisation for importing of CSV Bibles. This class provides a specialisation for importing of CSV Bibles.
@ -75,9 +75,8 @@ class CSVBible(BibleDB):
def __init__(self, parent, **kwargs): def __init__(self, parent, **kwargs):
""" """
Loads a Bible from a set of CSV files. Loads a Bible from a set of CSV files. This class assumes the files contain all the information and a clean
This class assumes the files contain all the information and bible is being loaded.
a clean bible is being loaded.
""" """
log.info(self.__class__.__name__) log.info(self.__class__.__name__)
BibleDB.__init__(self, parent, **kwargs) BibleDB.__init__(self, parent, **kwargs)

View File

@ -511,7 +511,7 @@ class BibleDB(QtCore.QObject, Manager):
language = None language = None
language_form = LanguageForm(self.wizard) language_form = LanguageForm(self.wizard)
if language_form.exec_(bible_name): if language_form.exec_(bible_name):
language = unicode(language_form.languageComboBox.currentText()) language = unicode(language_form.language_combo_box.currentText())
if not language: if not language:
return False return False
language = BiblesResourcesDB.get_language(language) language = BiblesResourcesDB.get_language(language)

View File

@ -27,8 +27,7 @@
# Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Temple Place, Suite 330, Boston, MA 02111-1307 USA #
############################################################################### ###############################################################################
""" """
The :mod:`http` module enables OpenLP to retrieve scripture from bible The :mod:`http` module enables OpenLP to retrieve scripture from bible websites.
websites.
""" """
import logging import logging
import re import re

View File

@ -61,8 +61,8 @@ class BibleMediaItem(MediaManagerItem):
def __init__(self, parent, plugin): def __init__(self, parent, plugin):
self.icon_path = u'songs/song' self.icon_path = u'songs/song'
self.lockIcon = build_icon(u':/bibles/bibles_search_lock.png') self.lock_icon = build_icon(u':/bibles/bibles_search_lock.png')
self.unlockIcon = build_icon(u':/bibles/bibles_search_unlock.png') self.unlock_icon = build_icon(u':/bibles/bibles_search_unlock.png')
MediaManagerItem.__init__(self, parent, plugin) MediaManagerItem.__init__(self, parent, plugin)
# Place to store the search results for both bibles. # Place to store the search results for both bibles.
self.settings = self.plugin.settings_tab self.settings = self.plugin.settings_tab
@ -73,7 +73,7 @@ class BibleMediaItem(MediaManagerItem):
self.check_search_result() self.check_search_result()
Registry().register_function(u'bibles_load_list', self.reload_bibles) Registry().register_function(u'bibles_load_list', self.reload_bibles)
def __checkSecondBible(self, bible, second_bible): def __check_second_bible(self, bible, second_bible):
""" """
Check if the first item is a second bible item or not. Check if the first item is a second bible item or not.
""" """
@ -84,7 +84,7 @@ class BibleMediaItem(MediaManagerItem):
self.displayResults(bible, second_bible) self.displayResults(bible, second_bible)
return return
else: else:
item_second_bible = self._decodeQtObject(bitem, 'second_bible') item_second_bible = self._decode_qt_object(bitem, 'second_bible')
if item_second_bible and second_bible or not item_second_bible and not second_bible: if item_second_bible and second_bible or not item_second_bible and not second_bible:
self.displayResults(bible, second_bible) self.displayResults(bible, second_bible)
elif critical_error_message_box( elif critical_error_message_box(
@ -95,7 +95,7 @@ class BibleMediaItem(MediaManagerItem):
self.list_view.clear() self.list_view.clear()
self.displayResults(bible, second_bible) self.displayResults(bible, second_bible)
def _decodeQtObject(self, bitem, key): def _decode_qt_object(self, bitem, key):
reference = bitem.data(QtCore.Qt.UserRole) reference = bitem.data(QtCore.Qt.UserRole)
obj = reference[unicode(key)] obj = reference[unicode(key)]
return unicode(obj).strip() return unicode(obj).strip()
@ -159,7 +159,7 @@ class BibleMediaItem(MediaManagerItem):
search_button_layout.setObjectName(prefix + u'search_button_layout') search_button_layout.setObjectName(prefix + u'search_button_layout')
search_button_layout.addStretch() search_button_layout.addStretch()
lockButton = QtGui.QToolButton(tab) lockButton = QtGui.QToolButton(tab)
lockButton.setIcon(self.unlockIcon) lockButton.setIcon(self.unlock_icon)
lockButton.setCheckable(True) lockButton.setCheckable(True)
lockButton.setObjectName(prefix + u'LockButton') lockButton.setObjectName(prefix + u'LockButton')
search_button_layout.addWidget(lockButton) search_button_layout.addWidget(lockButton)
@ -509,9 +509,9 @@ class BibleMediaItem(MediaManagerItem):
def onLockButtonToggled(self, checked): def onLockButtonToggled(self, checked):
if checked: if checked:
self.sender().setIcon(self.lockIcon) self.sender().setIcon(self.lock_icon)
else: else:
self.sender().setIcon(self.unlockIcon) self.sender().setIcon(self.unlock_icon)
def onQuickStyleComboBoxChanged(self): def onQuickStyleComboBoxChanged(self):
self.settings.layout_style = self.quickStyleComboBox.currentIndex() self.settings.layout_style = self.quickStyleComboBox.currentIndex()
@ -633,7 +633,7 @@ class BibleMediaItem(MediaManagerItem):
if not self.advancedLockButton.isChecked(): if not self.advancedLockButton.isChecked():
self.list_view.clear() self.list_view.clear()
if self.list_view.count() != 0: if self.list_view.count() != 0:
self.__checkSecondBible(bible, second_bible) self.__check_second_bible(bible, second_bible)
elif self.search_results: elif self.search_results:
self.displayResults(bible, second_bible) self.displayResults(bible, second_bible)
self.advancedSearchButton.setEnabled(True) self.advancedSearchButton.setEnabled(True)
@ -689,7 +689,7 @@ class BibleMediaItem(MediaManagerItem):
if not self.quickLockButton.isChecked(): if not self.quickLockButton.isChecked():
self.list_view.clear() self.list_view.clear()
if self.list_view.count() != 0 and self.search_results: if self.list_view.count() != 0 and self.search_results:
self.__checkSecondBible(bible, second_bible) self.__check_second_bible(bible, second_bible)
elif self.search_results: elif self.search_results:
self.displayResults(bible, second_bible) self.displayResults(bible, second_bible)
self.quickSearchButton.setEnabled(True) self.quickSearchButton.setEnabled(True)
@ -787,19 +787,19 @@ class BibleMediaItem(MediaManagerItem):
raw_title = [] raw_title = []
verses = VerseReferenceList() verses = VerseReferenceList()
for bitem in items: for bitem in items:
book = self._decodeQtObject(bitem, 'book') book = self._decode_qt_object(bitem, 'book')
chapter = int(self._decodeQtObject(bitem, 'chapter')) chapter = int(self._decode_qt_object(bitem, 'chapter'))
verse = int(self._decodeQtObject(bitem, 'verse')) verse = int(self._decode_qt_object(bitem, 'verse'))
bible = self._decodeQtObject(bitem, 'bible') bible = self._decode_qt_object(bitem, 'bible')
version = self._decodeQtObject(bitem, 'version') version = self._decode_qt_object(bitem, 'version')
copyright = self._decodeQtObject(bitem, 'copyright') copyright = self._decode_qt_object(bitem, 'copyright')
permissions = self._decodeQtObject(bitem, 'permissions') permissions = self._decode_qt_object(bitem, 'permissions')
text = self._decodeQtObject(bitem, 'text') text = self._decode_qt_object(bitem, 'text')
second_bible = self._decodeQtObject(bitem, 'second_bible') second_bible = self._decode_qt_object(bitem, 'second_bible')
second_version = self._decodeQtObject(bitem, 'second_version') second_version = self._decode_qt_object(bitem, 'second_version')
second_copyright = self._decodeQtObject(bitem, 'second_copyright') second_copyright = self._decode_qt_object(bitem, 'second_copyright')
second_permissions = self._decodeQtObject(bitem, 'second_permissions') second_permissions = self._decode_qt_object(bitem, 'second_permissions')
second_text = self._decodeQtObject(bitem, 'second_text') second_text = self._decode_qt_object(bitem, 'second_text')
verses.add(book, chapter, verse, version, copyright, permissions) verses.add(book, chapter, verse, version, copyright, permissions)
verse_text = self.formatVerse(old_chapter, chapter, verse) verse_text = self.formatVerse(old_chapter, chapter, verse)
if second_bible: if second_bible:
@ -867,13 +867,13 @@ class BibleMediaItem(MediaManagerItem):
""" """
verse_separator = get_reference_separator(u'sep_v_display') verse_separator = get_reference_separator(u'sep_v_display')
range_separator = get_reference_separator(u'sep_r_display') range_separator = get_reference_separator(u'sep_r_display')
old_chapter = self._decodeQtObject(old_bitem, 'chapter') old_chapter = self._decode_qt_object(old_bitem, 'chapter')
old_verse = self._decodeQtObject(old_bitem, 'verse') old_verse = self._decode_qt_object(old_bitem, 'verse')
start_book = self._decodeQtObject(start_bitem, 'book') start_book = self._decode_qt_object(start_bitem, 'book')
start_chapter = self._decodeQtObject(start_bitem, 'chapter') start_chapter = self._decode_qt_object(start_bitem, 'chapter')
start_verse = self._decodeQtObject(start_bitem, 'verse') start_verse = self._decode_qt_object(start_bitem, 'verse')
start_bible = self._decodeQtObject(start_bitem, 'bible') start_bible = self._decode_qt_object(start_bitem, 'bible')
start_second_bible = self._decodeQtObject(start_bitem, 'second_bible') start_second_bible = self._decode_qt_object(start_bitem, 'second_bible')
if start_second_bible: if start_second_bible:
bibles = u'%s, %s' % (start_bible, start_second_bible) bibles = u'%s, %s' % (start_bible, start_second_bible)
else: else:
@ -901,16 +901,16 @@ class BibleMediaItem(MediaManagerItem):
The item we were previously dealing with. The item we were previously dealing with.
""" """
# Get all the necessary meta data. # Get all the necessary meta data.
book = self._decodeQtObject(bitem, 'book') book = self._decode_qt_object(bitem, 'book')
chapter = int(self._decodeQtObject(bitem, 'chapter')) chapter = int(self._decode_qt_object(bitem, 'chapter'))
verse = int(self._decodeQtObject(bitem, 'verse')) verse = int(self._decode_qt_object(bitem, 'verse'))
bible = self._decodeQtObject(bitem, 'bible') bible = self._decode_qt_object(bitem, 'bible')
second_bible = self._decodeQtObject(bitem, 'second_bible') second_bible = self._decode_qt_object(bitem, 'second_bible')
old_book = self._decodeQtObject(old_bitem, 'book') old_book = self._decode_qt_object(old_bitem, 'book')
old_chapter = int(self._decodeQtObject(old_bitem, 'chapter')) old_chapter = int(self._decode_qt_object(old_bitem, 'chapter'))
old_verse = int(self._decodeQtObject(old_bitem, 'verse')) old_verse = int(self._decode_qt_object(old_bitem, 'verse'))
old_bible = self._decodeQtObject(old_bitem, 'bible') old_bible = self._decode_qt_object(old_bitem, 'bible')
old_second_bible = self._decodeQtObject(old_bitem, 'second_bible') old_second_bible = self._decode_qt_object(old_bitem, 'second_bible')
if old_bible != bible or old_second_bible != second_bible or old_book != book: if old_bible != bible or old_second_bible != second_bible or old_book != book:
# The bible, second bible or book has changed. # The bible, second bible or book has changed.
return True return True

View File

@ -34,16 +34,18 @@ from openlp.core.lib import translate
from openlp.core.lib.ui import critical_error_message_box from openlp.core.lib.ui import critical_error_message_box
from openlp.plugins.bibles.lib.db import BibleDB, BiblesResourcesDB from openlp.plugins.bibles.lib.db import BibleDB, BiblesResourcesDB
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
class OpenSongBible(BibleDB): class OpenSongBible(BibleDB):
""" """
OpenSong Bible format importer class. OpenSong Bible format importer class.
""" """
def __init__(self, parent, **kwargs): def __init__(self, parent, **kwargs):
""" """
Constructor to create and set up an instance of the OpenSongBible Constructor to create and set up an instance of the OpenSongBible class. This class is used to import Bibles
class. This class is used to import Bibles from OpenSong's XML format. from OpenSong's XML format.
""" """
log.debug(self.__class__.__name__) log.debug(self.__class__.__name__)
BibleDB.__init__(self, parent, **kwargs) BibleDB.__init__(self, parent, **kwargs)
@ -75,9 +77,8 @@ class OpenSongBible(BibleDB):
file = None file = None
success = True success = True
try: try:
# NOTE: We don't need to do any of the normal encoding detection # NOTE: We don't need to do any of the normal encoding detection here, because lxml does it's own encoding
# here, because lxml does it's own encoding detection, and the two # detection, and the two mechanisms together interfere with each other.
# mechanisms together interfere with each other.
file = open(self.filename, u'r') file = open(self.filename, u'r')
opensong = objectify.parse(file) opensong = objectify.parse(file)
bible = opensong.getroot() bible = opensong.getroot()
@ -116,16 +117,11 @@ class OpenSongBible(BibleDB):
if len(verse_parts) > 1: if len(verse_parts) > 1:
number = int(verse_parts[0]) number = int(verse_parts[0])
except TypeError: except TypeError:
log.warn(u'Illegal verse number: %s', log.warn(u'Illegal verse number: %s', unicode(verse.attrib[u'n']))
unicode(verse.attrib[u'n']))
verse_number = number verse_number = number
else: else:
verse_number += 1 verse_number += 1
self.create_verse( self.create_verse(db_book.id, chapter_number, verse_number, self.get_text(verse))
db_book.id,
chapter_number,
verse_number,
self.get_text(verse))
self.wizard.increment_progress_bar(translate('BiblesPlugin.Opensong', 'Importing %s %s...', self.wizard.increment_progress_bar(translate('BiblesPlugin.Opensong', 'Importing %s %s...',
'Importing <book name> <chapter>...')) % (db_book.name, chapter_number) 'Importing <book name> <chapter>...')) % (db_book.name, chapter_number)
self.session.commit() self.session.commit()

View File

@ -39,9 +39,11 @@ from openlp.plugins.bibles.lib.db import BibleDB, BiblesResourcesDB
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
def replacement(match): def replacement(match):
return match.group(2).upper() return match.group(2).upper()
class OSISBible(BibleDB): class OSISBible(BibleDB):
""" """
`OSIS <http://www.bibletechnologies.net/>`_ Bible format importer class. `OSIS <http://www.bibletechnologies.net/>`_ Bible format importer class.
@ -53,8 +55,7 @@ class OSISBible(BibleDB):
BibleDB.__init__(self, parent, **kwargs) BibleDB.__init__(self, parent, **kwargs)
self.filename = kwargs[u'filename'] self.filename = kwargs[u'filename']
self.language_regex = re.compile(r'<language.*>(.*?)</language>') self.language_regex = re.compile(r'<language.*>(.*?)</language>')
self.verse_regex = re.compile( self.verse_regex = re.compile(r'<verse osisID="([a-zA-Z0-9 ]*).([0-9]*).([0-9]*)">(.*?)</verse>')
r'<verse osisID="([a-zA-Z0-9 ]*).([0-9]*).([0-9]*)">(.*?)</verse>')
self.note_regex = re.compile(r'<note(.*?)>(.*?)</note>') self.note_regex = re.compile(r'<note(.*?)>(.*?)</note>')
self.title_regex = re.compile(r'<title(.*?)>(.*?)</title>') self.title_regex = re.compile(r'<title(.*?)>(.*?)</title>')
self.milestone_regex = re.compile(r'<milestone(.*?)/>') self.milestone_regex = re.compile(r'<milestone(.*?)/>')
@ -68,8 +69,7 @@ class OSISBible(BibleDB):
self.q1_regex = re.compile(r'<q(.*?)level="1"(.*?)>') self.q1_regex = re.compile(r'<q(.*?)level="1"(.*?)>')
self.q2_regex = re.compile(r'<q(.*?)level="2"(.*?)>') self.q2_regex = re.compile(r'<q(.*?)level="2"(.*?)>')
self.trans_regex = re.compile(r'<transChange(.*?)>(.*?)</transChange>') self.trans_regex = re.compile(r'<transChange(.*?)>(.*?)</transChange>')
self.divine_name_regex = re.compile( self.divine_name_regex = re.compile(r'<divineName(.*?)>(.*?)</divineName>')
r'<divineName(.*?)>(.*?)</divineName>')
self.spaces_regex = re.compile(r'([ ]{2,})') self.spaces_regex = re.compile(r'([ ]{2,})')
filepath = os.path.join( filepath = os.path.join(
AppLocation.get_directory(AppLocation.PluginsDir), u'bibles', u'resources', u'osisbooks.csv') AppLocation.get_directory(AppLocation.PluginsDir), u'bibles', u'resources', u'osisbooks.csv')
@ -158,10 +158,8 @@ class OSISBible(BibleDB):
self.wizard.increment_progress_bar(translate('BiblesPlugin.OsisImport', 'Importing %s %s...', self.wizard.increment_progress_bar(translate('BiblesPlugin.OsisImport', 'Importing %s %s...',
'Importing <book name> <chapter>...') % (book_details[u'name'], chapter)) 'Importing <book name> <chapter>...') % (book_details[u'name'], chapter))
last_chapter = chapter last_chapter = chapter
# All of this rigmarol below is because the mod2osis # All of this rigmarol below is because the mod2osis tool from the Sword library embeds XML in the
# tool from the Sword library embeds XML in the OSIS # OSIS but neglects to enclose the verse text (with XML) in <[CDATA[ ]]> tags.
# but neglects to enclose the verse text (with XML) in
# <[CDATA[ ]]> tags.
verse_text = self.note_regex.sub(u'', verse_text) verse_text = self.note_regex.sub(u'', verse_text)
verse_text = self.title_regex.sub(u'', verse_text) verse_text = self.title_regex.sub(u'', verse_text)
verse_text = self.milestone_regex.sub(u'', verse_text) verse_text = self.milestone_regex.sub(u'', verse_text)

View File

@ -27,8 +27,7 @@
# Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Temple Place, Suite 330, Boston, MA 02111-1307 USA #
############################################################################### ###############################################################################
""" """
The :mod:`upgrade` module provides a way for the database and schema that is the The :mod:`upgrade` module provides a way for the database and schema that is the backend for the Bibles plugin.
backend for the Bibles plugin
""" """
import logging import logging

View File

@ -29,8 +29,8 @@
class VerseReferenceList(object): class VerseReferenceList(object):
""" """
The VerseReferenceList class encapsulates a list of verse references, but The VerseReferenceList class encapsulates a list of verse references, but maintains the order in which they were
maintains the order in which they were added. added.
""" """
def __init__(self): def __init__(self):