From 098d733ad1ace0fd10ba97d51894f0b45d9aa95f Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 18 Apr 2013 19:45:14 +0200 Subject: [PATCH] bible renamings --- openlp/core/ui/firsttimelanguagedialog.py | 52 ++--- openlp/core/ui/firsttimelanguageform.py | 8 +- openlp/plugins/bibles/__init__.py | 3 +- openlp/plugins/bibles/bibleplugin.py | 63 +++--- openlp/plugins/bibles/forms/__init__.py | 30 ++- .../plugins/bibles/forms/bibleimportform.py | 10 +- .../plugins/bibles/forms/bibleupgradeform.py | 94 ++++---- openlp/plugins/bibles/forms/booknamedialog.py | 110 +++++----- openlp/plugins/bibles/forms/booknameform.py | 62 +++--- .../plugins/bibles/forms/editbibledialog.py | 200 +++++++++--------- openlp/plugins/bibles/forms/editbibleform.py | 48 ++--- openlp/plugins/bibles/forms/languagedialog.py | 68 +++--- openlp/plugins/bibles/forms/languageform.py | 16 +- openlp/plugins/bibles/lib/__init__.py | 61 +++--- openlp/plugins/bibles/lib/csvbible.py | 13 +- openlp/plugins/bibles/lib/db.py | 2 +- openlp/plugins/bibles/lib/http.py | 3 +- openlp/plugins/bibles/lib/mediaitem.py | 80 +++---- openlp/plugins/bibles/lib/opensong.py | 20 +- openlp/plugins/bibles/lib/osis.py | 14 +- openlp/plugins/bibles/lib/upgrade.py | 3 +- .../plugins/bibles/lib/versereferencelist.py | 4 +- 22 files changed, 465 insertions(+), 499 deletions(-) diff --git a/openlp/core/ui/firsttimelanguagedialog.py b/openlp/core/ui/firsttimelanguagedialog.py index 21f4dabcd..55fce4399 100644 --- a/openlp/core/ui/firsttimelanguagedialog.py +++ b/openlp/core/ui/firsttimelanguagedialog.py @@ -39,39 +39,39 @@ class Ui_FirstTimeLanguageDialog(object): """ The UI widgets of the language selection dialog. """ - def setupUi(self, languageDialog): + def setupUi(self, language_dialog): """ Set up the UI. """ - languageDialog.setObjectName(u'languageDialog') - languageDialog.resize(300, 50) - self.dialogLayout = QtGui.QVBoxLayout(languageDialog) - self.dialogLayout.setContentsMargins(8, 8, 8, 8) - self.dialogLayout.setSpacing(8) - self.dialogLayout.setObjectName(u'dialog_layout') - self.infoLabel = QtGui.QLabel(languageDialog) - self.infoLabel.setObjectName(u'infoLabel') - self.dialogLayout.addWidget(self.infoLabel) - self.languageLayout = QtGui.QHBoxLayout() - self.languageLayout.setObjectName(u'languageLayout') - self.languageLabel = QtGui.QLabel(languageDialog) - self.languageLabel.setObjectName(u'languageLabel') - self.languageLayout.addWidget(self.languageLabel) - self.languageComboBox = QtGui.QComboBox(languageDialog) - self.languageComboBox.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToContents) - self.languageComboBox.setObjectName("languageComboBox") - self.languageLayout.addWidget(self.languageComboBox) - self.dialogLayout.addLayout(self.languageLayout) - self.button_box = create_button_box(languageDialog, u'button_box', [u'cancel', u'ok']) - self.dialogLayout.addWidget(self.button_box) - self.retranslateUi(languageDialog) + language_dialog.setObjectName(u'language_dialog') + language_dialog.resize(300, 50) + self.dialog_layout = QtGui.QVBoxLayout(language_dialog) + self.dialog_layout.setContentsMargins(8, 8, 8, 8) + self.dialog_layout.setSpacing(8) + self.dialog_layout.setObjectName(u'dialog_layout') + self.info_label = QtGui.QLabel(language_dialog) + self.info_label.setObjectName(u'info_label') + self.dialog_layout.addWidget(self.info_label) + self.language_layout = QtGui.QHBoxLayout() + self.language_layout.setObjectName(u'language_layout') + self.language_label = QtGui.QLabel(language_dialog) + self.language_label.setObjectName(u'language_label') + self.language_layout.addWidget(self.language_label) + self.language_combo_box = QtGui.QComboBox(language_dialog) + self.language_combo_box.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToContents) + self.language_combo_box.setObjectName("language_combo_box") + self.language_layout.addWidget(self.language_combo_box) + self.dialog_layout.addLayout(self.language_layout) + self.button_box = create_button_box(language_dialog, u'button_box', [u'cancel', u'ok']) + self.dialog_layout.addWidget(self.button_box) + self.retranslateUi(language_dialog) self.setMaximumHeight(self.sizeHint().height()) - def retranslateUi(self, languageDialog): + def retranslateUi(self, language_dialog): """ Translate the UI on the fly. """ 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.')) - self.languageLabel.setText(translate('OpenLP.FirstTimeLanguageForm', 'Translation:')) + self.language_label.setText(translate('OpenLP.FirstTimeLanguageForm', 'Translation:')) diff --git a/openlp/core/ui/firsttimelanguageform.py b/openlp/core/ui/firsttimelanguageform.py index 85e98e114..14b9dadc3 100644 --- a/openlp/core/ui/firsttimelanguageform.py +++ b/openlp/core/ui/firsttimelanguageform.py @@ -47,8 +47,8 @@ class FirstTimeLanguageForm(QtGui.QDialog, Ui_FirstTimeLanguageDialog): QtGui.QDialog.__init__(self, parent) self.setupUi(self) self.qmList = LanguageManager.get_qm_list() - self.languageComboBox.addItem(u'Autodetect') - self.languageComboBox.addItems(sorted(self.qmList.keys())) + self.language_combo_box.addItem(u'Autodetect') + self.language_combo_box.addItems(sorted(self.qmList.keys())) def exec_(self): """ @@ -61,12 +61,12 @@ class FirstTimeLanguageForm(QtGui.QDialog, Ui_FirstTimeLanguageDialog): Run when the dialog is OKed. """ # 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.set_language(False, False) else: 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) return QtGui.QDialog.accept(self) diff --git a/openlp/plugins/bibles/__init__.py b/openlp/plugins/bibles/__init__.py index 1c1510e97..62e6c5f90 100644 --- a/openlp/plugins/bibles/__init__.py +++ b/openlp/plugins/bibles/__init__.py @@ -27,6 +27,5 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### """ -The :mod:`bibles` module provides the Bible plugin to enable OpenLP to display -scripture. +The :mod:`bibles` module provides the Bible plugin to enable OpenLP to display scripture. """ diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index 1f17ae39a..e2888d67a 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -43,25 +43,25 @@ log = logging.getLogger(__name__) __default_settings__ = { - u'bibles/db type': u'sqlite', - u'bibles/last search type': BibleSearch.Reference, - u'bibles/verse layout style': LayoutStyle.VersePerSlide, - u'bibles/book name language': LanguageSelection.Bible, - u'bibles/display brackets': DisplayStyle.NoBrackets, - u'bibles/display new chapter': False, - u'bibles/second bibles': True, - u'bibles/advanced bible': u'', - u'bibles/quick bible': u'', - u'bibles/proxy name': u'', - u'bibles/proxy address': u'', - u'bibles/proxy username': u'', - u'bibles/proxy password': u'', - u'bibles/bible theme': u'', - u'bibles/verse separator': u'', - u'bibles/range separator': u'', - u'bibles/list separator': u'', - u'bibles/end separator': u'', - u'bibles/last directory import': u'' + u'bibles/db type': u'sqlite', + u'bibles/last search type': BibleSearch.Reference, + u'bibles/verse layout style': LayoutStyle.VersePerSlide, + u'bibles/book name language': LanguageSelection.Bible, + u'bibles/display brackets': DisplayStyle.NoBrackets, + u'bibles/display new chapter': False, + u'bibles/second bibles': True, + u'bibles/advanced bible': u'', + u'bibles/quick bible': u'', + u'bibles/proxy name': u'', + u'bibles/proxy address': u'', + u'bibles/proxy username': u'', + u'bibles/proxy password': u'', + u'bibles/bible theme': u'', + u'bibles/verse separator': u'', + u'bibles/range separator': u'', + u'bibles/list separator': u'', + u'bibles/end separator': u'', + u'bibles/last directory import': u'' } @@ -124,18 +124,15 @@ class BiblePlugin(Plugin): def add_export_menu_Item(self, export_menu): self.export_bible_item = create_action(export_menu, u'exportBibleItem', - text=translate('BiblesPlugin', '&Bible'), - visible=False) + text=translate('BiblesPlugin', '&Bible'), visible=False) export_menu.addAction(self.export_bible_item) def add_tools_menu_item(self, tools_menu): """ - Give the bible plugin the opportunity to add items to the - **Tools** menu. + Give the bible plugin the opportunity to add items to the **Tools** menu. ``tools_menu`` - The actual **Tools** menu item, so that your actions can - use it as their parent. + The actual **Tools** menu item, so that your actions can use it as their parent. """ log.debug(u'add tools menu') self.tools_upgrade_item = create_action(tools_menu, u'toolsUpgradeItem', @@ -166,25 +163,23 @@ class BiblePlugin(Plugin): def uses_theme(self, theme): """ - Called to find out if the bible plugin is currently using a theme. - Returns ``True`` if the theme is being used, otherwise returns - ``False``. + Called to find out if the bible plugin is currently using a theme. Returns ``True`` if the theme is being used, + otherwise returns ``False``. """ 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 new name. - ``oldTheme`` - The name of the theme the plugin should stop using. Unused for - this particular plugin. + ``old_theme`` + The name of the theme the plugin should stop using. Unused for this particular plugin. - ``newTheme`` + ``new_theme`` 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() def set_plugin_text_strings(self): diff --git a/openlp/plugins/bibles/forms/__init__.py b/openlp/plugins/bibles/forms/__init__.py index ee0922695..abef5c85c 100644 --- a/openlp/plugins/bibles/forms/__init__.py +++ b/openlp/plugins/bibles/forms/__init__.py @@ -28,30 +28,25 @@ ############################################################################### """ -Forms in OpenLP are made up of two classes. One class holds all the graphical -elements, like buttons and lists, and the other class holds all the functional -code, like slots and loading and saving. +Forms in OpenLP are made up of two classes. One class holds all the graphical elements, like buttons and lists, and the +other class holds all the functional code, like slots and loading and saving. -The first class, commonly known as the **Dialog** class, is typically named -``Ui_Dialog``. It is a slightly modified version of the class that the -``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. +The first class, commonly known as the **Dialog** class, is typically named ``Ui_Dialog``. It is a slightly +modified version of the class that the ``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. -The second class, commonly known as the **Form** class, is typically named -``Form``. This class is the one which is instantiated and used. It uses -dual inheritance to inherit from (usually) QtGui.QDialog and the Ui class -mentioned above, like so:: +The second class, commonly known as the **Form** class, is typically named ``Form``. This class is the one which +is instantiated and used. It uses dual inheritance to inherit from (usually) QtGui.QDialog and the Ui class mentioned +above, like so:: class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard): - def __init__(self, parent, manager, bibleplugin): + def __init__(self, parent, manager, bible_plugin): QtGui.QWizard.__init__(self, parent) self.setupUi(self) -This allows OpenLP to use ``self.object`` for all the GUI elements while keeping -them separate from the functionality, so that it is easier to recreate the GUI -from the .ui files later if necessary. +This allows OpenLP to use ``self.object`` for all the GUI elements while keeping them separate from the functionality, +so that it is easier to recreate the GUI from the .ui files later if necessary. """ from booknameform import BookNameForm from languageform import LanguageForm @@ -59,5 +54,4 @@ from bibleimportform import BibleImportForm from bibleupgradeform import BibleUpgradeForm from editbibleform import EditBibleForm -__all__ = [u'BookNameForm', u'LanguageForm', u'BibleImportForm', - u'BibleUpgradeForm', u'EditBibleForm'] +__all__ = [u'BookNameForm', u'LanguageForm', u'BibleImportForm', u'BibleUpgradeForm', u'EditBibleForm'] diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index f8d771e77..7cdd81229 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -58,12 +58,12 @@ class WebDownload(object): class BibleImportForm(OpenLPWizard): """ - This is the Bible Import Wizard, which allows easy importing of Bibles - into OpenLP from other formats like OSIS, CSV and OpenSong. + This is the Bible Import Wizard, which allows easy importing of Bibles into OpenLP from other formats like OSIS, + CSV and OpenSong. """ 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. @@ -73,12 +73,12 @@ class BibleImportForm(OpenLPWizard): ``manager`` The Bible manager. - ``bibleplugin`` + ``bible_plugin`` The Bible plugin. """ self.manager = manager 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): """ diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index 0127d19be..d8f329ee7 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -48,8 +48,8 @@ log = logging.getLogger(__name__) class BibleUpgradeForm(OpenLPWizard): """ - This is the Bible Upgrade Wizard, which allows easy importing of Bibles - into OpenLP from older OpenLP2 database versions. + This is the Bible Upgrade Wizard, which allows easy importing of Bibles into OpenLP from older OpenLP2 database + versions. """ log.info(u'BibleUpgradeForm loaded') @@ -63,7 +63,7 @@ class BibleUpgradeForm(OpenLPWizard): ``manager`` The Bible manager. - ``bibleplugin`` + ``bible_plugin`` The Bible plugin. """ self.manager = manager @@ -74,7 +74,7 @@ class BibleUpgradeForm(OpenLPWizard): self.temp_dir = os.path.join(unicode(gettempdir(), get_filesystem_encoding()), u'openlp') self.files = self.manager.old_bible_databases self.success = {} - self.newbibles = {} + self.new_bibles = {} OpenLPWizard.__init__(self, parent, bible_plugin, u'bibleUpgradeWizard', u':/wizards/wizard_importbible.bmp') def setupUi(self, image): @@ -159,41 +159,41 @@ class BibleUpgradeForm(OpenLPWizard): Add the bible import specific wizard pages. """ # Backup Page - self.backupPage = QtGui.QWizardPage() - self.backupPage.setObjectName(u'BackupPage') - self.backupLayout = QtGui.QVBoxLayout(self.backupPage) + self.backup_page = QtGui.QWizardPage() + self.backup_page.setObjectName(u'BackupPage') + self.backupLayout = QtGui.QVBoxLayout(self.backup_page) self.backupLayout.setObjectName(u'BackupLayout') - self.backupInfoLabel = QtGui.QLabel(self.backupPage) + self.backupInfoLabel = QtGui.QLabel(self.backup_page) self.backupInfoLabel.setOpenExternalLinks(True) self.backupInfoLabel.setTextFormat(QtCore.Qt.RichText) self.backupInfoLabel.setWordWrap(True) self.backupInfoLabel.setObjectName(u'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.backupLayout.addWidget(self.selectLabel) self.formLayout = QtGui.QFormLayout() self.formLayout.setMargin(0) self.formLayout.setObjectName(u'FormLayout') - self.backupDirectoryLabel = QtGui.QLabel(self.backupPage) + self.backupDirectoryLabel = QtGui.QLabel(self.backup_page) self.backupDirectoryLabel.setObjectName(u'backupDirectoryLabel') self.backupDirectoryLayout = QtGui.QHBoxLayout() self.backupDirectoryLayout.setObjectName(u'BackupDirectoryLayout') - self.backupDirectoryEdit = QtGui.QLineEdit(self.backupPage) + self.backupDirectoryEdit = QtGui.QLineEdit(self.backup_page) self.backupDirectoryEdit.setObjectName(u'BackupFolderEdit') 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.setObjectName(u'BackupBrowseButton') self.backupDirectoryLayout.addWidget(self.backupBrowseButton) self.formLayout.addRow(self.backupDirectoryLabel, self.backupDirectoryLayout) self.backupLayout.addLayout(self.formLayout) - self.noBackupCheckBox = QtGui.QCheckBox(self.backupPage) + self.noBackupCheckBox = QtGui.QCheckBox(self.backup_page) self.noBackupCheckBox.setObjectName('NoBackupCheckBox') self.backupLayout.addWidget(self.noBackupCheckBox) self.spacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Minimum) self.backupLayout.addItem(self.spacer) - self.addPage(self.backupPage) + self.addPage(self.backup_page) # Select Page self.selectPage = QtGui.QWizardPage() self.selectPage.setObjectName(u'SelectPage') @@ -247,8 +247,8 @@ class BibleUpgradeForm(OpenLPWizard): self.information_label.setText(translate('BiblesPlugin.UpgradeWizardForm', 'This wizard will help you to upgrade your existing Bibles from a prior version of OpenLP 2. ' 'Click the next button below to start the upgrade process.')) - self.backupPage.setTitle(translate('BiblesPlugin.UpgradeWizardForm', 'Select Backup Directory')) - self.backupPage.setSubTitle(translate('BiblesPlugin.UpgradeWizardForm', + self.backup_page.setTitle(translate('BiblesPlugin.UpgradeWizardForm', 'Select Backup Directory')) + self.backup_page.setSubTitle(translate('BiblesPlugin.UpgradeWizardForm', 'Please select a backup directory for your Bibles')) self.backupInfoLabel.setText(translate('BiblesPlugin.UpgradeWizardForm', '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: return True - elif self.currentPage() == self.backupPage: + elif self.currentPage() == self.backup_page: if not self.noBackupCheckBox.checkState() == QtCore.Qt.Checked: backup_path = self.backupDirectoryEdit.text() if not backup_path: @@ -316,7 +316,7 @@ class BibleUpgradeForm(OpenLPWizard): settings.beginGroup(self.plugin.settings_section) self.stop_import_flag = False self.success.clear() - self.newbibles.clear() + self.new_bibles.clear() self.clearScrollArea() self.files = self.manager.old_bible_databases self.addScrollArea() @@ -372,8 +372,8 @@ class BibleUpgradeForm(OpenLPWizard): name = filename[1] self.progress_label.setText(translate('BiblesPlugin.UpgradeWizardForm', '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.newbibles[number].register(self.plugin.upgrade_wizard) + self.new_bibles[number] = BibleDB(self.media_item, path=self.path, name=name, file=filename[0]) + self.new_bibles[number].register(self.plugin.upgrade_wizard) metadata = old_bible.get_metadata() web_bible = False meta_data = {} @@ -387,7 +387,7 @@ class BibleUpgradeForm(OpenLPWizard): # Copy the metadata meta_data[meta[u'key']] = meta[u'value'] 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': web_bible = True self.includeWebBible = True @@ -403,8 +403,8 @@ class BibleUpgradeForm(OpenLPWizard): if not books: log.error(u'Upgrading books from %s - download name: "%s" failed' % ( meta_data[u'download_source'], meta_data[u'download_name'])) - self.newbibles[number].session.close() - del self.newbibles[number] + self.new_bibles[number].session.close() + del self.new_bibles[number] critical_error_message_box( translate('BiblesPlugin.UpgradeWizardForm', 'Download Error'), translate('BiblesPlugin.UpgradeWizardForm', @@ -419,14 +419,14 @@ class BibleUpgradeForm(OpenLPWizard): meta_data[u'download_source'].lower()) if bible and 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) else: - language_id = self.newbibles[number].get_language(name) + language_id = self.new_bibles[number].get_language(name) if not language_id: log.warn(u'Upgrading from "%s" failed' % filename[0]) - self.newbibles[number].session.close() - del self.newbibles[number] + self.new_bibles[number].session.close() + del self.new_bibles[number] self.increment_progress_bar(translate('BiblesPlugin.UpgradeWizardForm', 'Upgrading Bible %s of %s: "%s"\nFailed') % (number + 1, max_bibles, name), self.progress_bar.maximum() - self.progress_bar.value()) @@ -439,17 +439,17 @@ class BibleUpgradeForm(OpenLPWizard): break self.increment_progress_bar(translate('BiblesPlugin.UpgradeWizardForm', '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) if not book_ref_id: log.warn(u'Upgrading books from %s - download name: "%s" aborted by user' % ( meta_data[u'download_source'], meta_data[u'download_name'])) - self.newbibles[number].session.close() - del self.newbibles[number] + self.new_bibles[number].session.close() + del self.new_bibles[number] self.success[number] = False break 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']) # Try to import already downloaded verses. oldbook = old_bible.get_book(book) @@ -462,19 +462,19 @@ class BibleUpgradeForm(OpenLPWizard): if self.stop_import_flag: self.success[number] = False 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'verse']), unicode(verse[u'text'])) self.application.process_events() - self.newbibles[number].session.commit() + self.new_bibles[number].session.commit() 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: - language_id = self.newbibles[number].get_language(name) + language_id = self.new_bibles[number].get_language(name) if not language_id: log.warn(u'Upgrading books from "%s" failed' % name) - self.newbibles[number].session.close() - del self.newbibles[number] + self.new_bibles[number].session.close() + del self.new_bibles[number] self.increment_progress_bar(translate('BiblesPlugin.UpgradeWizardForm', 'Upgrading Bible %s of %s: "%s"\nFailed') % (number + 1, max_bibles, name), self.progress_bar.maximum() - self.progress_bar.value()) @@ -489,41 +489,41 @@ class BibleUpgradeForm(OpenLPWizard): self.increment_progress_bar(translate('BiblesPlugin.UpgradeWizardForm', 'Upgrading Bible %s of %s: "%s"\nUpgrading %s ...') % (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: log.warn(u'Upgrading books from %s " failed - aborted by user' % name) - self.newbibles[number].session.close() - del self.newbibles[number] + self.new_bibles[number].session.close() + del self.new_bibles[number] self.success[number] = False break 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']) verses = old_bible.get_verses(book[u'id']) if not verses: 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 for verse in verses: if self.stop_import_flag: self.success[number] = False 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'verse']), unicode(verse[u'text'])) self.application.process_events() - self.newbibles[number].session.commit() + self.new_bibles[number].session.commit() if not self.success.get(number, True): self.increment_progress_bar(translate('BiblesPlugin.UpgradeWizardForm', 'Upgrading Bible %s of %s: "%s"\nFailed') % (number + 1, max_bibles, name), self.progress_bar.maximum() - self.progress_bar.value()) else: 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', 'Upgrading Bible %s of %s: "%s"\nComplete') % (number + 1, max_bibles, name)) - if number in self.newbibles: - self.newbibles[number].session.close() + if number in self.new_bibles: + self.new_bibles[number].session.close() # Close the last bible's connection if possible. if old_bible is not None: old_bible.close_connection() diff --git a/openlp/plugins/bibles/forms/booknamedialog.py b/openlp/plugins/bibles/forms/booknamedialog.py index df86b4380..285e9cdcc 100644 --- a/openlp/plugins/bibles/forms/booknamedialog.py +++ b/openlp/plugins/bibles/forms/booknamedialog.py @@ -33,66 +33,66 @@ from openlp.core.lib import translate from openlp.core.lib.ui import create_button_box class Ui_BookNameDialog(object): - def setupUi(self, bookNameDialog): - bookNameDialog.setObjectName(u'bookNameDialog') - bookNameDialog.resize(400, 271) - self.bookNameLayout = QtGui.QVBoxLayout(bookNameDialog) - self.bookNameLayout.setSpacing(8) - self.bookNameLayout.setMargin(8) - self.bookNameLayout.setObjectName(u'bookNameLayout') - self.infoLabel = QtGui.QLabel(bookNameDialog) - self.infoLabel.setWordWrap(True) - self.infoLabel.setObjectName(u'infoLabel') - self.bookNameLayout.addWidget(self.infoLabel) - self.correspondingLayout = QtGui.QGridLayout() - self.correspondingLayout.setColumnStretch(1, 1) - self.correspondingLayout.setSpacing(8) - self.correspondingLayout.setObjectName(u'correspondingLayout') - self.currentLabel = QtGui.QLabel(bookNameDialog) + def setupUi(self, book_name_dialog): + book_name_dialog.setObjectName(u'book_name_dialog') + book_name_dialog.resize(400, 271) + self.book_name_layout = QtGui.QVBoxLayout(book_name_dialog) + self.book_name_layout.setSpacing(8) + self.book_name_layout.setMargin(8) + self.book_name_layout.setObjectName(u'book_name_layout') + self.info_label = QtGui.QLabel(book_name_dialog) + self.info_label.setWordWrap(True) + self.info_label.setObjectName(u'info_label') + self.book_name_layout.addWidget(self.info_label) + self.corresponding_layout = QtGui.QGridLayout() + self.corresponding_layout.setColumnStretch(1, 1) + self.corresponding_layout.setSpacing(8) + self.corresponding_layout.setObjectName(u'corresponding_layout') + self.currentLabel = QtGui.QLabel(book_name_dialog) self.currentLabel.setObjectName(u'currentLabel') - self.correspondingLayout.addWidget(self.currentLabel, 0, 0, 1, 1) - self.currentBookLabel = QtGui.QLabel(bookNameDialog) - self.currentBookLabel.setObjectName(u'currentBookLabel') - self.correspondingLayout.addWidget(self.currentBookLabel, 0, 1, 1, 1) - self.correspondingLabel = QtGui.QLabel(bookNameDialog) + self.corresponding_layout.addWidget(self.currentLabel, 0, 0, 1, 1) + self.current_book_label = QtGui.QLabel(book_name_dialog) + self.current_book_label.setObjectName(u'current_book_label') + self.corresponding_layout.addWidget(self.current_book_label, 0, 1, 1, 1) + self.correspondingLabel = QtGui.QLabel(book_name_dialog) self.correspondingLabel.setObjectName(u'correspondingLabel') - self.correspondingLayout.addWidget(self.correspondingLabel, 1, 0, 1, 1) - self.correspondingComboBox = QtGui.QComboBox(bookNameDialog) - self.correspondingComboBox.setObjectName(u'correspondingComboBox') - self.correspondingLayout.addWidget(self.correspondingComboBox, 1, 1, 1, 1) - self.bookNameLayout.addLayout(self.correspondingLayout) - self.optionsGroupBox = QtGui.QGroupBox(bookNameDialog) - self.optionsGroupBox.setObjectName(u'optionsGroupBox') - self.optionsLayout = QtGui.QVBoxLayout(self.optionsGroupBox) - self.optionsLayout.setSpacing(8) - self.optionsLayout.setMargin(8) - self.optionsLayout.setObjectName(u'optionsLayout') - self.oldTestamentCheckBox = QtGui.QCheckBox(self.optionsGroupBox) - self.oldTestamentCheckBox.setObjectName(u'oldTestamentCheckBox') - self.oldTestamentCheckBox.setCheckState(QtCore.Qt.Checked) - self.optionsLayout.addWidget(self.oldTestamentCheckBox) - self.newTestamentCheckBox = QtGui.QCheckBox(self.optionsGroupBox) - self.newTestamentCheckBox.setObjectName(u'newTestamentCheckBox') - self.newTestamentCheckBox.setCheckState(QtCore.Qt.Checked) - self.optionsLayout.addWidget(self.newTestamentCheckBox) - self.apocryphaCheckBox = QtGui.QCheckBox(self.optionsGroupBox) - self.apocryphaCheckBox.setObjectName(u'apocryphaCheckBox') - self.apocryphaCheckBox.setCheckState(QtCore.Qt.Checked) - self.optionsLayout.addWidget(self.apocryphaCheckBox) - self.bookNameLayout.addWidget(self.optionsGroupBox) - self.button_box = create_button_box(bookNameDialog, u'button_box', [u'cancel', u'ok']) - self.bookNameLayout.addWidget(self.button_box) + self.corresponding_layout.addWidget(self.correspondingLabel, 1, 0, 1, 1) + self.corresponding_combo_box = QtGui.QComboBox(book_name_dialog) + self.corresponding_combo_box.setObjectName(u'corresponding_combo_box') + self.corresponding_layout.addWidget(self.corresponding_combo_box, 1, 1, 1, 1) + self.book_name_layout.addLayout(self.corresponding_layout) + self.options_group_box = QtGui.QGroupBox(book_name_dialog) + self.options_group_box.setObjectName(u'options_group_box') + self.options_layout = QtGui.QVBoxLayout(self.options_group_box) + self.options_layout.setSpacing(8) + self.options_layout.setMargin(8) + self.options_layout.setObjectName(u'options_layout') + self.old_testament_check_box = QtGui.QCheckBox(self.options_group_box) + self.old_testament_check_box.setObjectName(u'old_testament_check_box') + self.old_testament_check_box.setCheckState(QtCore.Qt.Checked) + self.options_layout.addWidget(self.old_testament_check_box) + self.new_testament_check_box = QtGui.QCheckBox(self.options_group_box) + self.new_testament_check_box.setObjectName(u'new_testament_check_box') + self.new_testament_check_box.setCheckState(QtCore.Qt.Checked) + self.options_layout.addWidget(self.new_testament_check_box) + self.apocrypha_check_box = QtGui.QCheckBox(self.options_group_box) + self.apocrypha_check_box.setObjectName(u'apocrypha_check_box') + self.apocrypha_check_box.setCheckState(QtCore.Qt.Checked) + self.options_layout.addWidget(self.apocrypha_check_box) + self.book_name_layout.addWidget(self.options_group_box) + self.button_box = create_button_box(book_name_dialog, u'button_box', [u'cancel', u'ok']) + self.book_name_layout.addWidget(self.button_box) - self.retranslateUi(bookNameDialog) + self.retranslateUi(book_name_dialog) - def retranslateUi(self, bookNameDialog): - bookNameDialog.setWindowTitle(translate('BiblesPlugin.BookNameDialog', 'Select Book Name')) - self.infoLabel.setText(translate('BiblesPlugin.BookNameDialog', + def retranslateUi(self, book_name_dialog): + book_name_dialog.setWindowTitle(translate('BiblesPlugin.BookNameDialog', 'Select Book Name')) + self.info_label.setText(translate('BiblesPlugin.BookNameDialog', 'The following book name cannot be matched up internally. ' 'Please select the corresponding name from the list.')) self.currentLabel.setText(translate('BiblesPlugin.BookNameDialog', 'Current name:')) self.correspondingLabel.setText(translate('BiblesPlugin.BookNameDialog', 'Corresponding name:')) - self.optionsGroupBox.setTitle(translate('BiblesPlugin.BookNameDialog', 'Show Books From')) - self.oldTestamentCheckBox.setText(translate('BiblesPlugin.BookNameDialog', 'Old Testament')) - self.newTestamentCheckBox.setText(translate('BiblesPlugin.BookNameDialog', 'New Testament')) - self.apocryphaCheckBox.setText(translate('BiblesPlugin.BookNameDialog', 'Apocrypha')) + self.options_group_box.setTitle(translate('BiblesPlugin.BookNameDialog', 'Show Books From')) + self.old_testament_check_box.setText(translate('BiblesPlugin.BookNameDialog', 'Old Testament')) + self.new_testament_check_box.setText(translate('BiblesPlugin.BookNameDialog', 'New Testament')) + self.apocrypha_check_box.setText(translate('BiblesPlugin.BookNameDialog', 'Apocrypha')) diff --git a/openlp/plugins/bibles/forms/booknameform.py b/openlp/plugins/bibles/forms/booknameform.py index c8abaa227..cc213cf96 100644 --- a/openlp/plugins/bibles/forms/booknameform.py +++ b/openlp/plugins/bibles/forms/booknameform.py @@ -66,61 +66,61 @@ class BookNameForm(QDialog, Ui_BookNameDialog): """ Set up the signals used in the booknameform. """ - self.oldTestamentCheckBox.stateChanged.connect(self.onCheckBoxIndexChanged) - self.newTestamentCheckBox.stateChanged.connect(self.onCheckBoxIndexChanged) - self.apocryphaCheckBox.stateChanged.connect(self.onCheckBoxIndexChanged) + self.old_testament_check_box.stateChanged.connect(self.onCheckBoxIndexChanged) + self.new_testament_check_box.stateChanged.connect(self.onCheckBoxIndexChanged) + self.apocrypha_check_box.stateChanged.connect(self.onCheckBoxIndexChanged) def onCheckBoxIndexChanged(self, index): """ 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 """ - self.correspondingComboBox.clear() + self.corresponding_combo_box.clear() items = BiblesResourcesDB.get_books() for item in items: - addBook = True + add_book = True for book in self.books: if book.book_reference_id == item[u'id']: - addBook = False + add_book = False break - if self.oldTestamentCheckBox.checkState() == QtCore.Qt.Unchecked and item[u'testament_id'] == 1: - addBook = False - elif self.newTestamentCheckBox.checkState() == QtCore.Qt.Unchecked and item[u'testament_id'] == 2: - addBook = False - elif self.apocryphaCheckBox.checkState() == QtCore.Qt.Unchecked and item[u'testament_id'] == 3: - addBook = False - if addBook: - self.correspondingComboBox.addItem(self.book_names[item[u'abbreviation']]) + if self.old_testament_check_box.checkState() == QtCore.Qt.Unchecked and item[u'testament_id'] == 1: + add_book = False + elif self.new_testament_check_box.checkState() == QtCore.Qt.Unchecked and item[u'testament_id'] == 2: + add_book = False + elif self.apocrypha_check_box.checkState() == QtCore.Qt.Unchecked and item[u'testament_id'] == 3: + add_book = False + if add_book: + 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 - log.debug(maxbooks) - if maxbooks <= 27: - self.oldTestamentCheckBox.setCheckState(QtCore.Qt.Unchecked) - self.apocryphaCheckBox.setCheckState(QtCore.Qt.Unchecked) - elif maxbooks <= 66: - self.apocryphaCheckBox.setCheckState(QtCore.Qt.Unchecked) - self.reloadComboBox() - self.currentBookLabel.setText(unicode(name)) - self.correspondingComboBox.setFocus() + log.debug(max_books) + if max_books <= 27: + self.old_testament_check_box.setCheckState(QtCore.Qt.Unchecked) + self.apocrypha_check_box.setCheckState(QtCore.Qt.Unchecked) + elif max_books <= 66: + self.apocrypha_check_box.setCheckState(QtCore.Qt.Unchecked) + self.reload_combo_box() + self.current_book_label.setText(unicode(name)) + self.corresponding_combo_box.setFocus() return QDialog.exec_(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.')) - self.correspondingComboBox.setFocus() + self.corresponding_combo_box.setFocus() return False else: - cor_book = self.correspondingComboBox.currentText() + cor_book = self.corresponding_combo_box.currentText() for character in u'\\.^$*+?{}[]()': cor_book = cor_book.replace(character, u'\\' + character) - books = filter(lambda key: - re.match(cor_book, unicode(self.book_names[key]), re.UNICODE), self.book_names.keys()) + books = filter( + 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)) if books: self.book_id = books[0][u'id'] diff --git a/openlp/plugins/bibles/forms/editbibledialog.py b/openlp/plugins/bibles/forms/editbibledialog.py index b45bb2751..79cef2575 100644 --- a/openlp/plugins/bibles/forms/editbibledialog.py +++ b/openlp/plugins/bibles/forms/editbibledialog.py @@ -36,118 +36,118 @@ from openlp.plugins.bibles.lib.db import BiblesResourcesDB class Ui_EditBibleDialog(object): - def setupUi(self, editBibleDialog): - editBibleDialog.setObjectName(u'editBibleDialog') - editBibleDialog.resize(520, 400) - editBibleDialog.setWindowIcon(build_icon(u':/icon/openlp-logo-16x16.png')) - editBibleDialog.setModal(True) - self.dialogLayout = QtGui.QVBoxLayout(editBibleDialog) - self.dialogLayout.setSpacing(8) - self.dialogLayout.setContentsMargins(8, 8, 8, 8) - self.dialogLayout.setObjectName(u'dialog_layout') - self.bibleTabWidget = QtGui.QTabWidget(editBibleDialog) - self.bibleTabWidget.setObjectName(u'BibleTabWidget') + def setupUi(self, edit_bible_dialog): + edit_bible_dialog.setObjectName(u'edit_bible_dialog') + edit_bible_dialog.resize(520, 400) + edit_bible_dialog.setWindowIcon(build_icon(u':/icon/openlp-logo-16x16.png')) + edit_bible_dialog.setModal(True) + self.dialog_layout = QtGui.QVBoxLayout(edit_bible_dialog) + self.dialog_layout.setSpacing(8) + self.dialog_layout.setContentsMargins(8, 8, 8, 8) + self.dialog_layout.setObjectName(u'dialog_layout') + self.bible_tab_widget = QtGui.QTabWidget(edit_bible_dialog) + self.bible_tab_widget.setObjectName(u'BibleTabWidget') # Meta tab - self.metaTab = QtGui.QWidget() - self.metaTab.setObjectName(u'metaTab') - self.metaTabLayout = QtGui.QVBoxLayout(self.metaTab) - self.metaTabLayout.setObjectName(u'metaTabLayout') - self.licenseDetailsGroupBox = QtGui.QGroupBox(self.metaTab) - self.licenseDetailsGroupBox.setObjectName(u'licenseDetailsGroupBox') - self.licenseDetailsLayout = QtGui.QFormLayout(self.licenseDetailsGroupBox) - self.licenseDetailsLayout.setObjectName(u'licenseDetailsLayout') - self.versionNameLabel = QtGui.QLabel(self.licenseDetailsGroupBox) - self.versionNameLabel.setObjectName(u'versionNameLabel') - self.versionNameEdit = QtGui.QLineEdit(self.licenseDetailsGroupBox) - self.versionNameEdit.setObjectName(u'versionNameEdit') - self.versionNameLabel.setBuddy(self.versionNameEdit) - self.licenseDetailsLayout.addRow(self.versionNameLabel, self.versionNameEdit) - self.copyrightLabel = QtGui.QLabel(self.licenseDetailsGroupBox) - self.copyrightLabel.setObjectName(u'copyrightLabel') - self.copyrightEdit = QtGui.QLineEdit(self.licenseDetailsGroupBox) - self.copyrightEdit.setObjectName(u'copyright_edit') - self.copyrightLabel.setBuddy(self.copyrightEdit) - self.licenseDetailsLayout.addRow(self.copyrightLabel, self.copyrightEdit) - self.permissionsLabel = QtGui.QLabel(self.licenseDetailsGroupBox) - self.permissionsLabel.setObjectName(u'permissionsLabel') - self.permissionsEdit = QtGui.QLineEdit(self.licenseDetailsGroupBox) - self.permissionsEdit.setObjectName(u'permissionsEdit') - self.permissionsLabel.setBuddy(self.permissionsEdit) - self.licenseDetailsLayout.addRow(self.permissionsLabel, self.permissionsEdit) - self.metaTabLayout.addWidget(self.licenseDetailsGroupBox) - self.languageSelectionGroupBox = QtGui.QGroupBox(self.metaTab) - self.languageSelectionGroupBox.setObjectName(u'languageSelectionGroupBox') - self.languageSelectionLayout = QtGui.QVBoxLayout(self.languageSelectionGroupBox) - self.languageSelectionLabel = QtGui.QLabel(self.languageSelectionGroupBox) - self.languageSelectionLabel.setObjectName(u'languageSelectionLabel') - self.languageSelectionComboBox = QtGui.QComboBox(self.languageSelectionGroupBox) - self.languageSelectionComboBox.setObjectName(u'languageSelectionComboBox') - self.languageSelectionComboBox.addItems([u'', u'', u'', u'']) - self.languageSelectionLayout.addWidget(self.languageSelectionLabel) - self.languageSelectionLayout.addWidget(self.languageSelectionComboBox) - self.metaTabLayout.addWidget(self.languageSelectionGroupBox) - self.metaTabLayout.addStretch() - self.bibleTabWidget.addTab(self.metaTab, u'') + self.meta_tab = QtGui.QWidget() + self.meta_tab.setObjectName(u'meta_tab') + self.meta_tab_layout = QtGui.QVBoxLayout(self.meta_tab) + self.meta_tab_layout.setObjectName(u'meta_tab_layout') + self.license_details_group_box = QtGui.QGroupBox(self.meta_tab) + self.license_details_group_box.setObjectName(u'license_details_group_box') + self.license_details_layout = QtGui.QFormLayout(self.license_details_group_box) + self.license_details_layout.setObjectName(u'license_details_layout') + self.version_name_label = QtGui.QLabel(self.license_details_group_box) + self.version_name_label.setObjectName(u'version_name_label') + self.version_name_edit = QtGui.QLineEdit(self.license_details_group_box) + self.version_name_edit.setObjectName(u'version_name_edit') + self.version_name_label.setBuddy(self.version_name_edit) + self.license_details_layout.addRow(self.version_name_label, self.version_name_edit) + self.copyright_label = QtGui.QLabel(self.license_details_group_box) + self.copyright_label.setObjectName(u'copyright_label') + self.copyright_edit = QtGui.QLineEdit(self.license_details_group_box) + self.copyright_edit.setObjectName(u'copyright_edit') + self.copyright_label.setBuddy(self.copyright_edit) + self.license_details_layout.addRow(self.copyright_label, self.copyright_edit) + self.permissions_label = QtGui.QLabel(self.license_details_group_box) + self.permissions_label.setObjectName(u'permissions_label') + self.permissions_edit = QtGui.QLineEdit(self.license_details_group_box) + self.permissions_edit.setObjectName(u'permissions_edit') + self.permissions_label.setBuddy(self.permissions_edit) + self.license_details_layout.addRow(self.permissions_label, self.permissions_edit) + self.meta_tab_layout.addWidget(self.license_details_group_box) + self.language_selection_group_box = QtGui.QGroupBox(self.meta_tab) + self.language_selection_group_box.setObjectName(u'language_selection_group_box') + self.language_selection_layout = QtGui.QVBoxLayout(self.language_selection_group_box) + self.language_selection_label = QtGui.QLabel(self.language_selection_group_box) + self.language_selection_label.setObjectName(u'language_selection_label') + self.language_selection_combo_box = QtGui.QComboBox(self.language_selection_group_box) + self.language_selection_combo_box.setObjectName(u'language_selection_combo_box') + self.language_selection_combo_box.addItems([u'', u'', u'', u'']) + self.language_selection_layout.addWidget(self.language_selection_label) + self.language_selection_layout.addWidget(self.language_selection_combo_box) + self.meta_tab_layout.addWidget(self.language_selection_group_box) + self.meta_tab_layout.addStretch() + self.bible_tab_widget.addTab(self.meta_tab, u'') # Book name tab - self.bookNameTab = QtGui.QWidget() - self.bookNameTab.setObjectName(u'bookNameTab') - self.bookNameTabLayout = QtGui.QVBoxLayout(self.bookNameTab) - self.bookNameTabLayout.setObjectName(u'bookNameTabLayout') - self.bookNameNotice = QtGui.QLabel(self.bookNameTab) - self.bookNameNotice.setObjectName(u'bookNameNotice') - self.bookNameNotice.setWordWrap(True) - self.bookNameTabLayout.addWidget(self.bookNameNotice) - self.scrollArea = QtGui.QScrollArea(self.bookNameTab) - self.scrollArea.setWidgetResizable(True) - self.scrollArea.setObjectName(u'scrollArea') - self.scrollArea.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) - self.bookNameWidget = QtGui.QWidget(self.scrollArea) - self.bookNameWidget.setObjectName(u'bookNameWidget') - self.bookNameWidgetLayout = QtGui.QFormLayout(self.bookNameWidget) - self.bookNameWidgetLayout.setObjectName(u'bookNameWidgetLayout') - self.bookNameLabel = {} - self.bookNameEdit= {} + self.book_name_tab = QtGui.QWidget() + self.book_name_tab.setObjectName(u'book_name_tab') + self.book_name_tab_layout = QtGui.QVBoxLayout(self.book_name_tab) + self.book_name_tab_layout.setObjectName(u'book_name_tab_layout') + self.book_name_notice = QtGui.QLabel(self.book_name_tab) + self.book_name_notice.setObjectName(u'book_name_notice') + self.book_name_notice.setWordWrap(True) + self.book_name_tab_layout.addWidget(self.book_name_notice) + self.scroll_area = QtGui.QScrollArea(self.book_name_tab) + self.scroll_area.setWidgetResizable(True) + self.scroll_area.setObjectName(u'scroll_area') + self.scroll_area.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) + self.book_name_widget = QtGui.QWidget(self.scroll_area) + self.book_name_widget.setObjectName(u'book_name_widget') + self.book_name_widget_layout = QtGui.QFormLayout(self.book_name_widget) + self.book_name_widget_layout.setObjectName(u'book_name_widget_layout') + self.book_name_label = {} + self.book_name_edit= {} for book in BiblesResourcesDB.get_books(): - self.bookNameLabel[book[u'abbreviation']] = QtGui.QLabel(self.bookNameWidget) - self.bookNameLabel[book[u'abbreviation']].setObjectName(u'bookNameLabel[%s]' % book[u'abbreviation']) - self.bookNameEdit[book[u'abbreviation']] = QtGui.QLineEdit(self.bookNameWidget) - self.bookNameEdit[book[u'abbreviation']].setObjectName(u'bookNameEdit[%s]' % book[u'abbreviation']) - self.bookNameWidgetLayout.addRow( - self.bookNameLabel[book[u'abbreviation']], - self.bookNameEdit[book[u'abbreviation']]) - self.scrollArea.setWidget(self.bookNameWidget) - self.bookNameTabLayout.addWidget(self.scrollArea) - self.bookNameTabLayout.addStretch() - self.bibleTabWidget.addTab(self.bookNameTab, u'') + self.book_name_label[book[u'abbreviation']] = QtGui.QLabel(self.book_name_widget) + self.book_name_label[book[u'abbreviation']].setObjectName(u'book_name_label[%s]' % book[u'abbreviation']) + self.book_name_edit[book[u'abbreviation']] = QtGui.QLineEdit(self.book_name_widget) + self.book_name_edit[book[u'abbreviation']].setObjectName(u'book_name_edit[%s]' % book[u'abbreviation']) + self.book_name_widget_layout.addRow( + self.book_name_label[book[u'abbreviation']], + self.book_name_edit[book[u'abbreviation']]) + self.scroll_area.setWidget(self.book_name_widget) + self.book_name_tab_layout.addWidget(self.scroll_area) + self.book_name_tab_layout.addStretch() + self.bible_tab_widget.addTab(self.book_name_tab, u'') # Last few bits - self.dialogLayout.addWidget(self.bibleTabWidget) - self.button_box = create_button_box(editBibleDialog, u'button_box', [u'cancel', u'save']) - self.dialogLayout.addWidget(self.button_box) - self.retranslateUi(editBibleDialog) - QtCore.QMetaObject.connectSlotsByName(editBibleDialog) + self.dialog_layout.addWidget(self.bible_tab_widget) + self.button_box = create_button_box(edit_bible_dialog, u'button_box', [u'cancel', u'save']) + self.dialog_layout.addWidget(self.button_box) + self.retranslateUi(edit_bible_dialog) + QtCore.QMetaObject.connectSlotsByName(edit_bible_dialog) - def retranslateUi(self, editBibleDialog): + def retranslateUi(self, edit_bible_dialog): self.book_names = BibleStrings().BookNames - editBibleDialog.setWindowTitle(translate('BiblesPlugin.EditBibleForm', 'Bible Editor')) + edit_bible_dialog.setWindowTitle(translate('BiblesPlugin.EditBibleForm', 'Bible Editor')) # 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')) - self.licenseDetailsGroupBox.setTitle(translate('BiblesPlugin.EditBibleForm', 'License Details')) - self.versionNameLabel.setText(translate('BiblesPlugin.EditBibleForm', 'Version name:')) - self.copyrightLabel.setText(translate('BiblesPlugin.EditBibleForm', 'Copyright:')) - self.permissionsLabel.setText(translate('BiblesPlugin.EditBibleForm', 'Permissions:')) - self.languageSelectionGroupBox.setTitle(translate('BiblesPlugin.EditBibleForm', 'Default Bible Language')) - self.languageSelectionLabel.setText(translate('BiblesPlugin.EditBibleForm', + self.license_details_group_box.setTitle(translate('BiblesPlugin.EditBibleForm', 'License Details')) + self.version_name_label.setText(translate('BiblesPlugin.EditBibleForm', 'Version name:')) + self.copyright_label.setText(translate('BiblesPlugin.EditBibleForm', 'Copyright:')) + self.permissions_label.setText(translate('BiblesPlugin.EditBibleForm', 'Permissions:')) + self.language_selection_group_box.setTitle(translate('BiblesPlugin.EditBibleForm', 'Default Bible Language')) + self.language_selection_label.setText(translate('BiblesPlugin.EditBibleForm', 'Book name language in search field, search results and on display:')) - self.languageSelectionComboBox.setItemText(0, translate('BiblesPlugin.EditBibleForm', 'Global Settings')) - self.languageSelectionComboBox.setItemText(LanguageSelection.Bible + 1, + self.language_selection_combo_box.setItemText(0, translate('BiblesPlugin.EditBibleForm', 'Global Settings')) + self.language_selection_combo_box.setItemText(LanguageSelection.Bible + 1, 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')) - self.languageSelectionComboBox.setItemText(LanguageSelection.English + 1, + self.language_selection_combo_box.setItemText(LanguageSelection.English + 1, translate('BiblesPlugin.EditBibleForm', 'English')) # 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')) 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']])) diff --git a/openlp/plugins/bibles/forms/editbibleform.py b/openlp/plugins/bibles/forms/editbibleform.py index cbb02109a..b05fb68fb 100644 --- a/openlp/plugins/bibles/forms/editbibleform.py +++ b/openlp/plugins/bibles/forms/editbibleform.py @@ -65,33 +65,33 @@ class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog): """ log.debug(u'Load Bible') self.bible = bible - self.versionNameEdit.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.permissionsEdit.setText(self.manager.get_meta_data(self.bible, u'permissions').value) + self.version_name_edit.setText(self.manager.get_meta_data(self.bible, u'name').value) + self.copyright_edit.setText(self.manager.get_meta_data(self.bible, u'copyright').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') 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.webbible = self.manager.get_meta_data(self.bible, u'download_source') 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.')) - self.scrollArea.hide() + self.scroll_area.hide() 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, ' 'if "Global settings" is selected, on the Bible page in Configure OpenLP.')) for book in BiblesResourcesDB.get_books(): 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: - 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: # It is necessary to remove the Widget otherwise there still # exists the vertical spacing in QFormLayout - self.bookNameWidgetLayout.removeWidget(self.bookNameLabel[book[u'abbreviation']]) - self.bookNameLabel[book[u'abbreviation']].hide() - self.bookNameWidgetLayout.removeWidget(self.bookNameEdit[book[u'abbreviation']]) - self.bookNameEdit[book[u'abbreviation']].hide() + self.book_name_widget_layout.removeWidget(self.book_name_label[book[u'abbreviation']]) + self.book_name_label[book[u'abbreviation']].hide() + self.book_name_widget_layout.removeWidget(self.book_name_edit[book[u'abbreviation']]) + self.book_name_edit[book[u'abbreviation']].hide() def reject(self): """ @@ -106,10 +106,10 @@ class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog): Exit Dialog and save data """ log.debug(u'BibleEditForm.accept') - version = self.versionNameEdit.text() - copyright = self.copyrightEdit.text() - permissions = self.permissionsEdit.text() - book_name_language = self.languageSelectionComboBox.currentIndex() - 1 + version = self.version_name_edit.text() + copyright = self.copyright_edit.text() + permissions = self.permissions_edit.text() + book_name_language = self.language_selection_combo_box.currentIndex() - 1 if book_name_language == -1: book_name_language = None if not self.validateMeta(version, copyright): @@ -118,7 +118,7 @@ class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog): custom_names = {} for abbr, book in self.books.iteritems(): 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 not self.validateBook(custom_names[abbr], abbr): return @@ -139,19 +139,19 @@ class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog): Validate the Meta before saving. """ if not name: - self.versionNameEdit.setFocus() + self.version_name_edit.setFocus() critical_error_message_box(UiStrings().EmptyField, translate('BiblesPlugin.BibleEditForm', 'You need to specify a version name for your Bible.')) return False elif not copyright: - self.copyrightEdit.setFocus() + self.copyright_edit.setFocus() critical_error_message_box(UiStrings().EmptyField, translate('BiblesPlugin.BibleEditForm', 'You need to set a copyright for your Bible. Bibles in the Public Domain need to be marked as such.')) return False elif self.manager.exists(name) and self.manager.get_meta_data(self.bible, u'name').value != \ name: - self.versionNameEdit.setFocus() + self.version_name_edit.setFocus() critical_error_message_box(translate('BiblesPlugin.BibleEditForm', 'Bible Exists'), translate('BiblesPlugin.BibleEditForm', 'This Bible already exists. Please import ' '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]+$') if not new_book_name: - self.bookNameEdit[abbreviation].setFocus() + self.book_name_edit[abbreviation].setFocus() critical_error_message_box(UiStrings().EmptyField, translate('BiblesPlugin.BibleEditForm', 'You need to specify a book name for "%s".') % self.book_names[abbreviation]) return False elif not book_regex.match(new_book_name): - self.bookNameEdit[abbreviation].setFocus() + self.book_name_edit[abbreviation].setFocus() critical_error_message_box(UiStrings().EmptyField, translate('BiblesPlugin.BibleEditForm', '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 abbr == abbreviation: continue - if self.bookNameEdit[abbr].text() == new_book_name: - self.bookNameEdit[abbreviation].setFocus() + if self.book_name_edit[abbr].text() == new_book_name: + self.book_name_edit[abbreviation].setFocus() critical_error_message_box( translate('BiblesPlugin.BibleEditForm', 'Duplicate Book Name'), translate('BiblesPlugin.BibleEditForm', 'The Book Name "%s" has been entered more than once.') diff --git a/openlp/plugins/bibles/forms/languagedialog.py b/openlp/plugins/bibles/forms/languagedialog.py index 9ad16bb30..870957c3c 100644 --- a/openlp/plugins/bibles/forms/languagedialog.py +++ b/openlp/plugins/bibles/forms/languagedialog.py @@ -33,44 +33,44 @@ from openlp.core.lib import translate from openlp.core.lib.ui import create_button_box class Ui_LanguageDialog(object): - def setupUi(self, languageDialog): - languageDialog.setObjectName(u'languageDialog') - languageDialog.resize(400, 165) - self.languageLayout = QtGui.QVBoxLayout(languageDialog) - self.languageLayout.setSpacing(8) - self.languageLayout.setMargin(8) - self.languageLayout.setObjectName(u'languageLayout') - self.bibleLabel = QtGui.QLabel(languageDialog) - self.bibleLabel.setObjectName(u'bibleLabel') - self.languageLayout.addWidget(self.bibleLabel) - self.infoLabel = QtGui.QLabel(languageDialog) - self.infoLabel.setWordWrap(True) - self.infoLabel.setObjectName(u'infoLabel') - self.languageLayout.addWidget(self.infoLabel) - self.languageHBoxLayout = QtGui.QHBoxLayout() - self.languageHBoxLayout.setSpacing(8) - self.languageHBoxLayout.setObjectName(u'languageHBoxLayout') - self.languageLabel = QtGui.QLabel(languageDialog) - self.languageLabel.setObjectName(u'languageLabel') - self.languageHBoxLayout.addWidget(self.languageLabel) - self.languageComboBox = QtGui.QComboBox(languageDialog) + def setupUi(self, language_dialog): + language_dialog.setObjectName(u'language_dialog') + language_dialog.resize(400, 165) + self.language_layout = QtGui.QVBoxLayout(language_dialog) + self.language_layout.setSpacing(8) + self.language_layout.setMargin(8) + self.language_layout.setObjectName(u'language_layout') + self.bible_label = QtGui.QLabel(language_dialog) + self.bible_label.setObjectName(u'bible_label') + self.language_layout.addWidget(self.bible_label) + self.info_label = QtGui.QLabel(language_dialog) + self.info_label.setWordWrap(True) + self.info_label.setObjectName(u'info_label') + self.language_layout.addWidget(self.info_label) + self.language_h_box_layout = QtGui.QHBoxLayout() + self.language_h_box_layout.setSpacing(8) + self.language_h_box_layout.setObjectName(u'language_h_box_layout') + self.language_label = QtGui.QLabel(language_dialog) + self.language_label.setObjectName(u'language_label') + self.language_h_box_layout.addWidget(self.language_label) + self.language_combo_box = QtGui.QComboBox(language_dialog) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.languageComboBox.sizePolicy().hasHeightForWidth()) - self.languageComboBox.setSizePolicy(sizePolicy) - self.languageComboBox.setObjectName(u'languageComboBox') - self.languageHBoxLayout.addWidget(self.languageComboBox) - self.languageLayout.addLayout(self.languageHBoxLayout) - self.button_box = create_button_box(languageDialog, u'button_box', [u'cancel', u'ok']) - self.languageLayout.addWidget(self.button_box) + sizePolicy.setHeightForWidth(self.language_combo_box.sizePolicy().hasHeightForWidth()) + self.language_combo_box.setSizePolicy(sizePolicy) + self.language_combo_box.setObjectName(u'language_combo_box') + self.language_h_box_layout.addWidget(self.language_combo_box) + self.language_layout.addLayout(self.language_h_box_layout) + self.button_box = create_button_box(language_dialog, u'button_box', [u'cancel', u'ok']) + self.language_layout.addWidget(self.button_box) - self.retranslateUi(languageDialog) + self.retranslateUi(language_dialog) - def retranslateUi(self, languageDialog): - languageDialog.setWindowTitle(translate('BiblesPlugin.LanguageDialog', 'Select Language')) - self.bibleLabel.setText(translate('BiblesPlugin.LanguageDialog', '')) - self.infoLabel.setText(translate('BiblesPlugin.LanguageDialog', + def retranslateUi(self, language_dialog): + language_dialog.setWindowTitle(translate('BiblesPlugin.LanguageDialog', 'Select Language')) + self.bible_label.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 ' 'from the list below.')) - self.languageLabel.setText(translate('BiblesPlugin.LanguageDialog', 'Language:')) + self.language_label.setText(translate('BiblesPlugin.LanguageDialog', 'Language:')) diff --git a/openlp/plugins/bibles/forms/languageform.py b/openlp/plugins/bibles/forms/languageform.py index cdac6dec9..2bba3d7a4 100644 --- a/openlp/plugins/bibles/forms/languageform.py +++ b/openlp/plugins/bibles/forms/languageform.py @@ -40,8 +40,10 @@ from openlp.plugins.bibles.forms.languagedialog import \ Ui_LanguageDialog from openlp.plugins.bibles.lib.db import BiblesResourcesDB + log = logging.getLogger(__name__) + class LanguageForm(QDialog, Ui_LanguageDialog): """ Class to manage a dialog which ask the user for a language. @@ -56,19 +58,17 @@ class LanguageForm(QDialog, Ui_LanguageDialog): self.setupUi(self) def exec_(self, bible_name): - self.languageComboBox.addItem(u'') + self.language_combo_box.addItem(u'') if bible_name: - self.bibleLabel.setText(unicode(bible_name)) + self.bible_label.setText(unicode(bible_name)) 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) def accept(self): - if not self.languageComboBox.currentText(): - critical_error_message_box( - message=translate('BiblesPlugin.LanguageForm', - 'You need to choose a language.')) - self.languageComboBox.setFocus() + if not self.language_combo_box.currentText(): + critical_error_message_box(message=translate('BiblesPlugin.LanguageForm', 'You need to choose a language.')) + self.language_combo_box.setFocus() return False else: return QDialog.accept(self) diff --git a/openlp/plugins/bibles/lib/__init__.py b/openlp/plugins/bibles/lib/__init__.py index 219b91f90..371632d41 100644 --- a/openlp/plugins/bibles/lib/__init__.py +++ b/openlp/plugins/bibles/lib/__init__.py @@ -38,9 +38,11 @@ from openlp.core.lib import Settings, translate log = logging.getLogger(__name__) + REFERENCE_MATCHES = {} REFERENCE_SEPARATORS = {} + class LayoutStyle(object): """ An enumeration for bible screen layout styles. @@ -62,8 +64,7 @@ class DisplayStyle(object): class LanguageSelection(object): """ - An enumeration for bible bookname language. - And standard strings for use throughout the bibles plugin. + An enumeration for bible bookname language. And standard strings for use throughout the bibles plugin. """ Bible = 0 Application = 1 @@ -178,8 +179,7 @@ class BibleStrings(object): def update_reference_separators(): """ - Updates separators and matches for parsing and formating scripture - references. + Updates separators and matches for parsing and formating scripture references. """ default_separators = translate('BiblesPlugin', ':|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): """ - This is the next generation über-awesome function that takes a person's - typed in string and converts it to a list of references to be queried from - the Bible database files. + This is the next generation über-awesome function that takes a person's typed in string and converts it to a list + of references to be queried from the Bible database files. ``reference`` 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. ``language_selection`` - An int. The language selection the user has choosen in settings - section. + An int. The language selection the user has choosen in settings section. ``book_ref_id`` A string. The book reference id. Returns ``None`` or a reference list. - The reference list is a list of tuples, with each tuple structured like - this:: + The reference list is a list of tuples, with each tuple structured like this:: (book, chapter, from_verse, to_verse) @@ -275,8 +272,7 @@ def parse_reference(reference, bible, language_selection, book_ref_id=False): **Reference string details:** - Each reference starts with the book name and a chapter number. These are - both mandatory. + Each reference starts with the book name and a chapter number. These are both mandatory. * ``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-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 - the last selected chapter. + After a verse reference all further single values are treat as verse in the last selected chapter. * ``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 - are build analog to the first ones. This way it is possible to define each - number of verse references. It is not possible to refer to verses in - additional books. + After a list separator it is possible to refer to additional verses. They are build analog to the first ones. This + way it is possible to define each number of verse references. It is not possible to refer to verses in additional + books. * ``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,4:1`` refers to John chapter 3 verses 16 to 18 and - chapter 4 verse 1 + * ``John 3:16-18,4:1`` refers to John chapter 3 verses 16 to 18 and chapter 4 verse 1 - If there is a range separator without further verse declaration the last - refered chapter is addressed until the end. + If there is a range separator without further verse declaration the last refered chapter is addressed until the end. - ``range_regex`` is a regular expression which matches for verse range - declarations: + ``range_regex`` is a regular expression which matches for verse range declarations: ``(?:(?P[0-9]+)%(sep_v)s)?`` - It starts with a optional chapter reference ``from_chapter`` followed by - a verse separator. + It starts with a optional chapter reference ``from_chapter`` followed by a verse separator. ``(?P[0-9]+)`` The verse reference ``from_verse`` is manditory ``(?P%(sep_r)s(?:`` ... ``|%(sep_e)s)?)?`` - A ``range_to`` declaration is optional. It starts with a range separator - and contains optional a chapter and verse declaration or a end - separator. + A ``range_to`` declaration is optional. It starts with a range separator and contains optional a chapter and + verse declaration or a end separator. ``(?:(?P[0-9]+)%(sep_v)s)?`` 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[0-9]+)`` The ``to_verse`` reference is equivalent to group 2. - The full reference is matched against get_reference_match(u'full'). This - regular expression looks like this: + The full reference is matched against get_reference_match(u'full'). This regular expression looks like this: ``^\s*(?!\s)(?P[\d]*[^\d]+)(?(?:%(range_regex)s(?:%(sep_l)s(?!\s*$)|(?=\s*$)))+)\s*$`` - The second group contains all ``ranges``. This can be multiple - declarations of range_regex separated by a list separator. + The second group contains all ``ranges``. This can be multiple declarations of range_regex separated by a list + separator. """ log.debug(u'parse_reference("%s")', reference) diff --git a/openlp/plugins/bibles/lib/csvbible.py b/openlp/plugins/bibles/lib/csvbible.py index f57da2ba0..7cf004cfc 100644 --- a/openlp/plugins/bibles/lib/csvbible.py +++ b/openlp/plugins/bibles/lib/csvbible.py @@ -27,8 +27,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### """ -The :mod:`cvsbible` modules provides a facility to import bibles from a set of -CSV files. +The :mod:`cvsbible` modules provides a facility to import bibles from a set of CSV files. 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 "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 -quotes ('"') as the quote symbol. +All CSV files are expected to use a comma (',') as the delimiter and double quotes ('"') as the quote symbol. """ import logging import chardet @@ -65,8 +63,10 @@ import csv from openlp.core.lib import translate from openlp.plugins.bibles.lib.db import BibleDB, BiblesResourcesDB + log = logging.getLogger(__name__) + class CSVBible(BibleDB): """ This class provides a specialisation for importing of CSV Bibles. @@ -75,9 +75,8 @@ class CSVBible(BibleDB): def __init__(self, parent, **kwargs): """ - Loads a Bible from a set of CSV files. - This class assumes the files contain all the information and - a clean bible is being loaded. + Loads a Bible from a set of CSV files. This class assumes the files contain all the information and a clean + bible is being loaded. """ log.info(self.__class__.__name__) BibleDB.__init__(self, parent, **kwargs) diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index 4193668e2..837dbec38 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -511,7 +511,7 @@ class BibleDB(QtCore.QObject, Manager): language = None language_form = LanguageForm(self.wizard) if language_form.exec_(bible_name): - language = unicode(language_form.languageComboBox.currentText()) + language = unicode(language_form.language_combo_box.currentText()) if not language: return False language = BiblesResourcesDB.get_language(language) diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index b01377a05..14c502265 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -27,8 +27,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### """ -The :mod:`http` module enables OpenLP to retrieve scripture from bible -websites. +The :mod:`http` module enables OpenLP to retrieve scripture from bible websites. """ import logging import re diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index b5352db9f..b67bb99b2 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -61,8 +61,8 @@ class BibleMediaItem(MediaManagerItem): def __init__(self, parent, plugin): self.icon_path = u'songs/song' - self.lockIcon = build_icon(u':/bibles/bibles_search_lock.png') - self.unlockIcon = build_icon(u':/bibles/bibles_search_unlock.png') + self.lock_icon = build_icon(u':/bibles/bibles_search_lock.png') + self.unlock_icon = build_icon(u':/bibles/bibles_search_unlock.png') MediaManagerItem.__init__(self, parent, plugin) # Place to store the search results for both bibles. self.settings = self.plugin.settings_tab @@ -73,7 +73,7 @@ class BibleMediaItem(MediaManagerItem): self.check_search_result() 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. """ @@ -84,7 +84,7 @@ class BibleMediaItem(MediaManagerItem): self.displayResults(bible, second_bible) return 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: self.displayResults(bible, second_bible) elif critical_error_message_box( @@ -95,7 +95,7 @@ class BibleMediaItem(MediaManagerItem): self.list_view.clear() self.displayResults(bible, second_bible) - def _decodeQtObject(self, bitem, key): + def _decode_qt_object(self, bitem, key): reference = bitem.data(QtCore.Qt.UserRole) obj = reference[unicode(key)] return unicode(obj).strip() @@ -159,7 +159,7 @@ class BibleMediaItem(MediaManagerItem): search_button_layout.setObjectName(prefix + u'search_button_layout') search_button_layout.addStretch() lockButton = QtGui.QToolButton(tab) - lockButton.setIcon(self.unlockIcon) + lockButton.setIcon(self.unlock_icon) lockButton.setCheckable(True) lockButton.setObjectName(prefix + u'LockButton') search_button_layout.addWidget(lockButton) @@ -509,9 +509,9 @@ class BibleMediaItem(MediaManagerItem): def onLockButtonToggled(self, checked): if checked: - self.sender().setIcon(self.lockIcon) + self.sender().setIcon(self.lock_icon) else: - self.sender().setIcon(self.unlockIcon) + self.sender().setIcon(self.unlock_icon) def onQuickStyleComboBoxChanged(self): self.settings.layout_style = self.quickStyleComboBox.currentIndex() @@ -633,7 +633,7 @@ class BibleMediaItem(MediaManagerItem): if not self.advancedLockButton.isChecked(): self.list_view.clear() if self.list_view.count() != 0: - self.__checkSecondBible(bible, second_bible) + self.__check_second_bible(bible, second_bible) elif self.search_results: self.displayResults(bible, second_bible) self.advancedSearchButton.setEnabled(True) @@ -689,7 +689,7 @@ class BibleMediaItem(MediaManagerItem): if not self.quickLockButton.isChecked(): self.list_view.clear() 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: self.displayResults(bible, second_bible) self.quickSearchButton.setEnabled(True) @@ -787,19 +787,19 @@ class BibleMediaItem(MediaManagerItem): raw_title = [] verses = VerseReferenceList() for bitem in items: - book = self._decodeQtObject(bitem, 'book') - chapter = int(self._decodeQtObject(bitem, 'chapter')) - verse = int(self._decodeQtObject(bitem, 'verse')) - bible = self._decodeQtObject(bitem, 'bible') - version = self._decodeQtObject(bitem, 'version') - copyright = self._decodeQtObject(bitem, 'copyright') - permissions = self._decodeQtObject(bitem, 'permissions') - text = self._decodeQtObject(bitem, 'text') - second_bible = self._decodeQtObject(bitem, 'second_bible') - second_version = self._decodeQtObject(bitem, 'second_version') - second_copyright = self._decodeQtObject(bitem, 'second_copyright') - second_permissions = self._decodeQtObject(bitem, 'second_permissions') - second_text = self._decodeQtObject(bitem, 'second_text') + book = self._decode_qt_object(bitem, 'book') + chapter = int(self._decode_qt_object(bitem, 'chapter')) + verse = int(self._decode_qt_object(bitem, 'verse')) + bible = self._decode_qt_object(bitem, 'bible') + version = self._decode_qt_object(bitem, 'version') + copyright = self._decode_qt_object(bitem, 'copyright') + permissions = self._decode_qt_object(bitem, 'permissions') + text = self._decode_qt_object(bitem, 'text') + second_bible = self._decode_qt_object(bitem, 'second_bible') + second_version = self._decode_qt_object(bitem, 'second_version') + second_copyright = self._decode_qt_object(bitem, 'second_copyright') + second_permissions = self._decode_qt_object(bitem, 'second_permissions') + second_text = self._decode_qt_object(bitem, 'second_text') verses.add(book, chapter, verse, version, copyright, permissions) verse_text = self.formatVerse(old_chapter, chapter, verse) if second_bible: @@ -867,13 +867,13 @@ class BibleMediaItem(MediaManagerItem): """ verse_separator = get_reference_separator(u'sep_v_display') range_separator = get_reference_separator(u'sep_r_display') - old_chapter = self._decodeQtObject(old_bitem, 'chapter') - old_verse = self._decodeQtObject(old_bitem, 'verse') - start_book = self._decodeQtObject(start_bitem, 'book') - start_chapter = self._decodeQtObject(start_bitem, 'chapter') - start_verse = self._decodeQtObject(start_bitem, 'verse') - start_bible = self._decodeQtObject(start_bitem, 'bible') - start_second_bible = self._decodeQtObject(start_bitem, 'second_bible') + old_chapter = self._decode_qt_object(old_bitem, 'chapter') + old_verse = self._decode_qt_object(old_bitem, 'verse') + start_book = self._decode_qt_object(start_bitem, 'book') + start_chapter = self._decode_qt_object(start_bitem, 'chapter') + start_verse = self._decode_qt_object(start_bitem, 'verse') + start_bible = self._decode_qt_object(start_bitem, 'bible') + start_second_bible = self._decode_qt_object(start_bitem, 'second_bible') if start_second_bible: bibles = u'%s, %s' % (start_bible, start_second_bible) else: @@ -901,16 +901,16 @@ class BibleMediaItem(MediaManagerItem): The item we were previously dealing with. """ # Get all the necessary meta data. - book = self._decodeQtObject(bitem, 'book') - chapter = int(self._decodeQtObject(bitem, 'chapter')) - verse = int(self._decodeQtObject(bitem, 'verse')) - bible = self._decodeQtObject(bitem, 'bible') - second_bible = self._decodeQtObject(bitem, 'second_bible') - old_book = self._decodeQtObject(old_bitem, 'book') - old_chapter = int(self._decodeQtObject(old_bitem, 'chapter')) - old_verse = int(self._decodeQtObject(old_bitem, 'verse')) - old_bible = self._decodeQtObject(old_bitem, 'bible') - old_second_bible = self._decodeQtObject(old_bitem, 'second_bible') + book = self._decode_qt_object(bitem, 'book') + chapter = int(self._decode_qt_object(bitem, 'chapter')) + verse = int(self._decode_qt_object(bitem, 'verse')) + bible = self._decode_qt_object(bitem, 'bible') + second_bible = self._decode_qt_object(bitem, 'second_bible') + old_book = self._decode_qt_object(old_bitem, 'book') + old_chapter = int(self._decode_qt_object(old_bitem, 'chapter')) + old_verse = int(self._decode_qt_object(old_bitem, 'verse')) + old_bible = self._decode_qt_object(old_bitem, '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: # The bible, second bible or book has changed. return True diff --git a/openlp/plugins/bibles/lib/opensong.py b/openlp/plugins/bibles/lib/opensong.py index 9b4b216d7..9a6c62aad 100644 --- a/openlp/plugins/bibles/lib/opensong.py +++ b/openlp/plugins/bibles/lib/opensong.py @@ -34,16 +34,18 @@ from openlp.core.lib import translate from openlp.core.lib.ui import critical_error_message_box from openlp.plugins.bibles.lib.db import BibleDB, BiblesResourcesDB + log = logging.getLogger(__name__) + class OpenSongBible(BibleDB): """ OpenSong Bible format importer class. """ def __init__(self, parent, **kwargs): """ - Constructor to create and set up an instance of the OpenSongBible - class. This class is used to import Bibles from OpenSong's XML format. + Constructor to create and set up an instance of the OpenSongBible class. This class is used to import Bibles + from OpenSong's XML format. """ log.debug(self.__class__.__name__) BibleDB.__init__(self, parent, **kwargs) @@ -75,9 +77,8 @@ class OpenSongBible(BibleDB): file = None success = True try: - # NOTE: We don't need to do any of the normal encoding detection - # here, because lxml does it's own encoding detection, and the two - # mechanisms together interfere with each other. + # NOTE: We don't need to do any of the normal encoding detection here, because lxml does it's own encoding + # detection, and the two mechanisms together interfere with each other. file = open(self.filename, u'r') opensong = objectify.parse(file) bible = opensong.getroot() @@ -116,16 +117,11 @@ class OpenSongBible(BibleDB): if len(verse_parts) > 1: number = int(verse_parts[0]) except TypeError: - log.warn(u'Illegal verse number: %s', - unicode(verse.attrib[u'n'])) + log.warn(u'Illegal verse number: %s', unicode(verse.attrib[u'n'])) verse_number = number else: verse_number += 1 - self.create_verse( - db_book.id, - chapter_number, - verse_number, - self.get_text(verse)) + self.create_verse(db_book.id, chapter_number, verse_number, self.get_text(verse)) self.wizard.increment_progress_bar(translate('BiblesPlugin.Opensong', 'Importing %s %s...', 'Importing ...')) % (db_book.name, chapter_number) self.session.commit() diff --git a/openlp/plugins/bibles/lib/osis.py b/openlp/plugins/bibles/lib/osis.py index 981d10949..b91cd8319 100644 --- a/openlp/plugins/bibles/lib/osis.py +++ b/openlp/plugins/bibles/lib/osis.py @@ -39,9 +39,11 @@ from openlp.plugins.bibles.lib.db import BibleDB, BiblesResourcesDB log = logging.getLogger(__name__) + def replacement(match): return match.group(2).upper() + class OSISBible(BibleDB): """ `OSIS `_ Bible format importer class. @@ -53,8 +55,7 @@ class OSISBible(BibleDB): BibleDB.__init__(self, parent, **kwargs) self.filename = kwargs[u'filename'] self.language_regex = re.compile(r'(.*?)') - self.verse_regex = re.compile( - r'(.*?)') + self.verse_regex = re.compile(r'(.*?)') self.note_regex = re.compile(r'(.*?)') self.title_regex = re.compile(r'(.*?)') self.milestone_regex = re.compile(r'') @@ -68,8 +69,7 @@ class OSISBible(BibleDB): self.q1_regex = re.compile(r'') self.q2_regex = re.compile(r'') self.trans_regex = re.compile(r'(.*?)') - self.divine_name_regex = re.compile( - r'(.*?)') + self.divine_name_regex = re.compile(r'(.*?)') self.spaces_regex = re.compile(r'([ ]{2,})') filepath = os.path.join( 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...', 'Importing ...') % (book_details[u'name'], chapter)) last_chapter = chapter - # All of this rigmarol below is because the mod2osis - # tool from the Sword library embeds XML in the OSIS - # but neglects to enclose the verse text (with XML) in - # <[CDATA[ ]]> tags. + # All of this rigmarol below is because the mod2osis tool from the Sword library embeds XML in the + # OSIS but neglects to enclose the verse text (with XML) in <[CDATA[ ]]> tags. verse_text = self.note_regex.sub(u'', verse_text) verse_text = self.title_regex.sub(u'', verse_text) verse_text = self.milestone_regex.sub(u'', verse_text) diff --git a/openlp/plugins/bibles/lib/upgrade.py b/openlp/plugins/bibles/lib/upgrade.py index b4a358c45..0c1a089b2 100644 --- a/openlp/plugins/bibles/lib/upgrade.py +++ b/openlp/plugins/bibles/lib/upgrade.py @@ -27,8 +27,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### """ -The :mod:`upgrade` module provides a way for the database and schema that is the -backend for the Bibles plugin +The :mod:`upgrade` module provides a way for the database and schema that is the backend for the Bibles plugin. """ import logging diff --git a/openlp/plugins/bibles/lib/versereferencelist.py b/openlp/plugins/bibles/lib/versereferencelist.py index 1cb76ffff..069b86d5e 100644 --- a/openlp/plugins/bibles/lib/versereferencelist.py +++ b/openlp/plugins/bibles/lib/versereferencelist.py @@ -29,8 +29,8 @@ class VerseReferenceList(object): """ - The VerseReferenceList class encapsulates a list of verse references, but - maintains the order in which they were added. + The VerseReferenceList class encapsulates a list of verse references, but maintains the order in which they were + added. """ def __init__(self):