From 9dfc446ebd4bf54fa1280f6244fb45816478d312 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 21 Mar 2014 18:23:35 +0000 Subject: [PATCH] More cleanups --- openlp/plugins/alerts/alertsplugin.py | 2 +- openlp/plugins/alerts/forms/alertform.py | 2 +- openlp/plugins/alerts/lib/alertsmanager.py | 2 +- openlp/plugins/bibles/bibleplugin.py | 4 +- .../plugins/bibles/forms/bibleimportform.py | 590 +++++++++--------- .../plugins/bibles/forms/bibleupgradeform.py | 156 ++--- openlp/plugins/bibles/forms/booknamedialog.py | 23 +- openlp/plugins/bibles/forms/booknameform.py | 13 +- .../plugins/bibles/forms/editbibledialog.py | 24 +- openlp/plugins/bibles/forms/editbibleform.py | 2 +- openlp/plugins/bibles/forms/languagedialog.py | 18 +- openlp/plugins/bibles/forms/languageform.py | 3 +- openlp/plugins/bibles/lib/__init__.py | 7 +- openlp/plugins/bibles/lib/biblestab.py | 3 +- openlp/plugins/bibles/lib/db.py | 27 +- openlp/plugins/bibles/lib/http.py | 6 +- openlp/plugins/bibles/lib/mediaitem.py | 6 +- openlp/plugins/images/forms/addgroupform.py | 3 +- openlp/plugins/images/lib/mediaitem.py | 6 +- openlp/plugins/media/lib/mediaitem.py | 8 +- .../songusage/forms/songusagedeleteform.py | 2 +- .../songusage/forms/songusagedetailform.py | 17 +- openlp/plugins/songusage/lib/db.py | 2 +- 23 files changed, 472 insertions(+), 454 deletions(-) diff --git a/openlp/plugins/alerts/alertsplugin.py b/openlp/plugins/alerts/alertsplugin.py index e9a24980e..cf3b7d0ce 100644 --- a/openlp/plugins/alerts/alertsplugin.py +++ b/openlp/plugins/alerts/alertsplugin.py @@ -246,4 +246,4 @@ class AlertsPlugin(Plugin): align = VerticalType.Names[self.settings_tab.location] frame.evaluateJavaScript('update_css("%s", "%s", "%s", "%s", "%s")' % (align, self.settings_tab.font_face, self.settings_tab.font_size, - self.settings_tab.font_color, self.settings_tab.background_color)) + self.settings_tab.font_color, self.settings_tab.background_color)) diff --git a/openlp/plugins/alerts/forms/alertform.py b/openlp/plugins/alerts/forms/alertform.py index f5e5ee31a..f988bec0f 100644 --- a/openlp/plugins/alerts/forms/alertform.py +++ b/openlp/plugins/alerts/forms/alertform.py @@ -46,7 +46,7 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog): self.manager = plugin.manager self.plugin = plugin self.item_id = None - super(AlertForm, self).__init__( Registry().get('main_window')) + super(AlertForm, self).__init__(Registry().get('main_window')) self.setupUi(self) self.display_button.clicked.connect(self.on_display_clicked) self.display_close_button.clicked.connect(self.on_display_close_clicked) diff --git a/openlp/plugins/alerts/lib/alertsmanager.py b/openlp/plugins/alerts/lib/alertsmanager.py index 675b5874e..061936446 100644 --- a/openlp/plugins/alerts/lib/alertsmanager.py +++ b/openlp/plugins/alerts/lib/alertsmanager.py @@ -97,4 +97,4 @@ class AlertsManager(OpenLPMixin, RegistryMixin, QtCore.QObject, RegistryProperti self.live_controller.display.alert('', alert_tab.location) self.killTimer(self.timer_id) self.timer_id = 0 - self.generate_alert() \ No newline at end of file + self.generate_alert() diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index fc7d76130..5a51be163 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -113,8 +113,8 @@ class BiblePlugin(Plugin): """ super(BiblePlugin, self).app_startup() if self.manager.old_bible_databases: - if QtGui.QMessageBox.information(self.main_window, - translate('OpenLP', 'Information'), + if QtGui.QMessageBox.information( + self.main_window, translate('OpenLP', 'Information'), translate('OpenLP', 'Bible format has changed.\nYou have to upgrade your existing Bibles.\n' 'Should OpenLP upgrade now?'), QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)) == \ diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index 8c7b62d10..ee5bee2d0 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -44,6 +44,7 @@ from openlp.plugins.bibles.lib.db import BiblesResourcesDB, clean_filename log = logging.getLogger(__name__) + class WebDownload(object): """ Provides an enumeration for the web bible types available to OpenLP. @@ -81,258 +82,257 @@ class BibleImportForm(OpenLPWizard): Set up the UI for the bible wizard. """ super(BibleImportForm, self).setupUi(image) - self.formatComboBox.currentIndexChanged.connect(self.onCurrentIndexChanged) + self.format_combo_box.currentIndexChanged.connect(self.on_current_index_changed) - def onCurrentIndexChanged(self, index): + def on_current_index_changed(self, index): """ Called when the format combo box's index changed. We have to check if the import is available and accordingly to disable or enable the next button. """ - self.selectStack.setCurrentIndex(index) + self.select_stack.setCurrentIndex(index) def custom_init(self): """ Perform any custom initialisation for bible importing. """ self.manager.set_process_dialog(self) - self.loadWebBibles() + self.load_Web_Bibles() self.restart() - self.selectStack.setCurrentIndex(0) + self.select_stack.setCurrentIndex(0) def custom_signals(self): """ Set up the signals used in the bible importer. """ - self.webSourceComboBox.currentIndexChanged.connect(self.onWebSourceComboBoxIndexChanged) - self.osisBrowseButton.clicked.connect(self.onOsisBrowseButtonClicked) - self.csvBooksButton.clicked.connect(self.onCsvBooksBrowseButtonClicked) - self.csvVersesButton.clicked.connect(self.onCsvVersesBrowseButtonClicked) - self.openSongBrowseButton.clicked.connect(self.onOpenSongBrowseButtonClicked) + self.web_source_combo_box.currentIndexChanged.connect(self.on_web_source_combo_box_index_changed) + self.osis_browse_button.clicked.connect(self.on_osis_browse_button_clicked) + self.csv_books_button.clicked.connect(self.on_csv_books_browse_button_clicked) + self.csv_verses_button.clicked.connect(self.on_csv_verses_browse_button_clicked) + self.open_song_browse_button.clicked.connect(self.on_open_song_browse_button_clicked) def add_custom_pages(self): """ Add the bible import specific wizard pages. """ # Select Page - self.selectPage = QtGui.QWizardPage() - self.selectPage.setObjectName('SelectPage') - self.selectPageLayout = QtGui.QVBoxLayout(self.selectPage) - self.selectPageLayout.setObjectName('SelectPageLayout') - self.formatLayout = QtGui.QFormLayout() - self.formatLayout.setObjectName('FormatLayout') - self.formatLabel = QtGui.QLabel(self.selectPage) - self.formatLabel.setObjectName('FormatLabel') - self.formatComboBox = QtGui.QComboBox(self.selectPage) - self.formatComboBox.addItems(['', '', '', '']) - self.formatComboBox.setObjectName('FormatComboBox') - self.formatLayout.addRow(self.formatLabel, self.formatComboBox) + self.select_page = QtGui.QWizardPage() + self.select_page.setObjectName('SelectPage') + self.select_page_layout = QtGui.QVBoxLayout(self.select_page) + self.select_page_layout.setObjectName('SelectPageLayout') + self.format_layout = QtGui.QFormLayout() + self.format_layout.setObjectName('FormatLayout') + self.format_label = QtGui.QLabel(self.select_page) + self.format_label.setObjectName('FormatLabel') + self.format_combo_box = QtGui.QComboBox(self.select_page) + self.format_combo_box.addItems(['', '', '', '']) + self.format_combo_box.setObjectName('FormatComboBox') + self.format_layout.addRow(self.format_label, self.format_combo_box) self.spacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Minimum) - self.formatLayout.setItem(1, QtGui.QFormLayout.LabelRole, self.spacer) - self.selectPageLayout.addLayout(self.formatLayout) - self.selectStack = QtGui.QStackedLayout() - self.selectStack.setObjectName('SelectStack') - self.osisWidget = QtGui.QWidget(self.selectPage) - self.osisWidget.setObjectName('OsisWidget') - self.osisLayout = QtGui.QFormLayout(self.osisWidget) - self.osisLayout.setMargin(0) - self.osisLayout.setObjectName('OsisLayout') - self.osisFileLabel = QtGui.QLabel(self.osisWidget) - self.osisFileLabel.setObjectName('OsisFileLabel') - self.osisFileLayout = QtGui.QHBoxLayout() - self.osisFileLayout.setObjectName('OsisFileLayout') - self.osisFileEdit = QtGui.QLineEdit(self.osisWidget) - self.osisFileEdit.setObjectName('OsisFileEdit') - self.osisFileLayout.addWidget(self.osisFileEdit) - self.osisBrowseButton = QtGui.QToolButton(self.osisWidget) - self.osisBrowseButton.setIcon(self.open_icon) - self.osisBrowseButton.setObjectName('OsisBrowseButton') - self.osisFileLayout.addWidget(self.osisBrowseButton) - self.osisLayout.addRow(self.osisFileLabel, self.osisFileLayout) - self.osisLayout.setItem(1, QtGui.QFormLayout.LabelRole, self.spacer) - self.selectStack.addWidget(self.osisWidget) - self.csvWidget = QtGui.QWidget(self.selectPage) - self.csvWidget.setObjectName('CsvWidget') - self.csvLayout = QtGui.QFormLayout(self.csvWidget) - self.csvLayout.setMargin(0) - self.csvLayout.setObjectName('CsvLayout') - self.csvBooksLabel = QtGui.QLabel(self.csvWidget) - self.csvBooksLabel.setObjectName('CsvBooksLabel') - self.csvBooksLayout = QtGui.QHBoxLayout() - self.csvBooksLayout.setObjectName('CsvBooksLayout') - self.csvBooksEdit = QtGui.QLineEdit(self.csvWidget) - self.csvBooksEdit.setObjectName('CsvBooksEdit') - self.csvBooksLayout.addWidget(self.csvBooksEdit) - self.csvBooksButton = QtGui.QToolButton(self.csvWidget) - self.csvBooksButton.setIcon(self.open_icon) - self.csvBooksButton.setObjectName('CsvBooksButton') - self.csvBooksLayout.addWidget(self.csvBooksButton) - self.csvLayout.addRow(self.csvBooksLabel, self.csvBooksLayout) - self.csvVersesLabel = QtGui.QLabel(self.csvWidget) - self.csvVersesLabel.setObjectName('CsvVersesLabel') - self.csvVersesLayout = QtGui.QHBoxLayout() - self.csvVersesLayout.setObjectName('CsvVersesLayout') - self.csvVersesEdit = QtGui.QLineEdit(self.csvWidget) - self.csvVersesEdit.setObjectName('CsvVersesEdit') - self.csvVersesLayout.addWidget(self.csvVersesEdit) - self.csvVersesButton = QtGui.QToolButton(self.csvWidget) - self.csvVersesButton.setIcon(self.open_icon) - self.csvVersesButton.setObjectName('CsvVersesButton') - self.csvVersesLayout.addWidget(self.csvVersesButton) - self.csvLayout.addRow(self.csvVersesLabel, self.csvVersesLayout) - self.csvLayout.setItem(3, QtGui.QFormLayout.LabelRole, self.spacer) - self.selectStack.addWidget(self.csvWidget) - self.openSongWidget = QtGui.QWidget(self.selectPage) - self.openSongWidget.setObjectName('OpenSongWidget') - self.openSongLayout = QtGui.QFormLayout(self.openSongWidget) - self.openSongLayout.setMargin(0) - self.openSongLayout.setObjectName('OpenSongLayout') - self.openSongFileLabel = QtGui.QLabel(self.openSongWidget) - self.openSongFileLabel.setObjectName('OpenSongFileLabel') - self.openSongFileLayout = QtGui.QHBoxLayout() - self.openSongFileLayout.setObjectName('OpenSongFileLayout') - self.openSongFileEdit = QtGui.QLineEdit(self.openSongWidget) - self.openSongFileEdit.setObjectName('OpenSongFileEdit') - self.openSongFileLayout.addWidget(self.openSongFileEdit) - self.openSongBrowseButton = QtGui.QToolButton(self.openSongWidget) - self.openSongBrowseButton.setIcon(self.open_icon) - self.openSongBrowseButton.setObjectName('OpenSongBrowseButton') - self.openSongFileLayout.addWidget(self.openSongBrowseButton) - self.openSongLayout.addRow(self.openSongFileLabel, self.openSongFileLayout) - self.openSongLayout.setItem(1, QtGui.QFormLayout.LabelRole, self.spacer) - self.selectStack.addWidget(self.openSongWidget) - self.webTabWidget = QtGui.QTabWidget(self.selectPage) - self.webTabWidget.setObjectName('WebTabWidget') - self.webBibleTab = QtGui.QWidget() - self.webBibleTab.setObjectName('WebBibleTab') - self.webBibleLayout = QtGui.QFormLayout(self.webBibleTab) - self.webBibleLayout.setObjectName('WebBibleLayout') - self.webSourceLabel = QtGui.QLabel(self.webBibleTab) - self.webSourceLabel.setObjectName('WebSourceLabel') - self.webBibleLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.webSourceLabel) - self.webSourceComboBox = QtGui.QComboBox(self.webBibleTab) - self.webSourceComboBox.setObjectName('WebSourceComboBox') - self.webSourceComboBox.addItems(['', '', '']) - self.webBibleLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.webSourceComboBox) - self.webTranslationLabel = QtGui.QLabel(self.webBibleTab) - self.webTranslationLabel.setObjectName('webTranslationLabel') - self.webBibleLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.webTranslationLabel) - self.webTranslationComboBox = QtGui.QComboBox(self.webBibleTab) - self.webTranslationComboBox.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToContents) - self.webTranslationComboBox.setObjectName('WebTranslationComboBox') - self.webBibleLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.webTranslationComboBox) - self.webTabWidget.addTab(self.webBibleTab, '') - self.webProxyTab = QtGui.QWidget() - self.webProxyTab.setObjectName('WebProxyTab') - self.webProxyLayout = QtGui.QFormLayout(self.webProxyTab) - self.webProxyLayout.setObjectName('WebProxyLayout') - self.webServerLabel = QtGui.QLabel(self.webProxyTab) - self.webServerLabel.setObjectName('WebServerLabel') - self.webProxyLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.webServerLabel) - self.webServerEdit = QtGui.QLineEdit(self.webProxyTab) - self.webServerEdit.setObjectName('WebServerEdit') - self.webProxyLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.webServerEdit) - self.webUserLabel = QtGui.QLabel(self.webProxyTab) - self.webUserLabel.setObjectName('WebUserLabel') - self.webProxyLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.webUserLabel) - self.webUserEdit = QtGui.QLineEdit(self.webProxyTab) - self.webUserEdit.setObjectName('WebUserEdit') - self.webProxyLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.webUserEdit) - self.webPasswordLabel = QtGui.QLabel(self.webProxyTab) - self.webPasswordLabel.setObjectName('WebPasswordLabel') - self.webProxyLayout.setWidget(2, QtGui.QFormLayout.LabelRole, self.webPasswordLabel) - self.webPasswordEdit = QtGui.QLineEdit(self.webProxyTab) - self.webPasswordEdit.setObjectName('WebPasswordEdit') - self.webProxyLayout.setWidget(2, QtGui.QFormLayout.FieldRole, self.webPasswordEdit) - self.webTabWidget.addTab(self.webProxyTab, '') - self.selectStack.addWidget(self.webTabWidget) - self.selectPageLayout.addLayout(self.selectStack) - self.addPage(self.selectPage) + self.format_layout.setItem(1, QtGui.QFormLayout.LabelRole, self.spacer) + self.select_page_layout.addLayout(self.format_layout) + self.select_stack = QtGui.QStackedLayout() + self.select_stack.setObjectName('SelectStack') + self.osis_widget = QtGui.QWidget(self.select_page) + self.osis_widget.setObjectName('OsisWidget') + self.osis_layout = QtGui.QFormLayout(self.osis_widget) + self.osis_layout.setMargin(0) + self.osis_layout.setObjectName('OsisLayout') + self.osis_file_label = QtGui.QLabel(self.osis_widget) + self.osis_file_label.setObjectName('OsisFileLabel') + self.osis_file_layout = QtGui.QHBoxLayout() + self.osis_file_layout.setObjectName('OsisFileLayout') + self.osis_file_edit = QtGui.QLineEdit(self.osis_widget) + self.osis_file_edit.setObjectName('OsisFileEdit') + self.osis_file_layout.addWidget(self.osis_file_edit) + self.osis_browse_button = QtGui.QToolButton(self.osis_widget) + self.osis_browse_button.setIcon(self.open_icon) + self.osis_browse_button.setObjectName('OsisBrowseButton') + self.osis_file_layout.addWidget(self.osis_browse_button) + self.osis_layout.addRow(self.osis_file_label, self.osis_file_layout) + self.osis_layout.setItem(1, QtGui.QFormLayout.LabelRole, self.spacer) + self.select_stack.addWidget(self.osis_widget) + self.csv_widget = QtGui.QWidget(self.select_page) + self.csv_widget.setObjectName('CsvWidget') + self.csv_layout = QtGui.QFormLayout(self.csv_widget) + self.csv_layout.setMargin(0) + self.csv_layout.setObjectName('CsvLayout') + self.csv_books_label = QtGui.QLabel(self.csv_widget) + self.csv_books_label.setObjectName('CsvBooksLabel') + self.csv_books_layout = QtGui.QHBoxLayout() + self.csv_books_layout.setObjectName('CsvBooksLayout') + self.csv_books_edit = QtGui.QLineEdit(self.csv_widget) + self.csv_books_edit.setObjectName('CsvBooksEdit') + self.csv_books_layout.addWidget(self.csv_books_edit) + self.csv_books_button = QtGui.QToolButton(self.csv_widget) + self.csv_books_button.setIcon(self.open_icon) + self.csv_books_button.setObjectName('CsvBooksButton') + self.csv_books_layout.addWidget(self.csv_books_button) + self.csv_layout.addRow(self.csv_books_label, self.csv_books_layout) + self.csv_verses_label = QtGui.QLabel(self.csv_widget) + self.csv_verses_label.setObjectName('CsvVersesLabel') + self.csv_verses_layout = QtGui.QHBoxLayout() + self.csv_verses_layout.setObjectName('CsvVersesLayout') + self.csv_verses_edit = QtGui.QLineEdit(self.csv_widget) + self.csv_verses_edit.setObjectName('CsvVersesEdit') + self.csv_verses_layout.addWidget(self.csv_verses_edit) + self.csv_verses_button = QtGui.QToolButton(self.csv_widget) + self.csv_verses_button.setIcon(self.open_icon) + self.csv_verses_button.setObjectName('CsvVersesButton') + self.csv_verses_layout.addWidget(self.csv_verses_button) + self.csv_layout.addRow(self.csv_verses_label, self.csv_verses_layout) + self.csv_layout.setItem(3, QtGui.QFormLayout.LabelRole, self.spacer) + self.select_stack.addWidget(self.csv_widget) + self.open_song_widget = QtGui.QWidget(self.select_page) + self.open_song_widget.setObjectName('OpenSongWidget') + self.open_song_layout = QtGui.QFormLayout(self.open_song_widget) + self.open_song_layout.setMargin(0) + self.open_song_layout.setObjectName('OpenSongLayout') + self.open_song_file_label = QtGui.QLabel(self.open_song_widget) + self.open_song_file_label.setObjectName('OpenSongFileLabel') + self.open_song_file_layout = QtGui.QHBoxLayout() + self.open_song_file_layout.setObjectName('OpenSongFileLayout') + self.open_song_file_edit = QtGui.QLineEdit(self.open_song_widget) + self.open_song_file_edit.setObjectName('OpenSongFileEdit') + self.open_song_file_layout.addWidget(self.open_song_file_edit) + self.open_song_browse_button = QtGui.QToolButton(self.open_song_widget) + self.open_song_browse_button.setIcon(self.open_icon) + self.open_song_browse_button.setObjectName('OpenSongBrowseButton') + self.open_song_file_layout.addWidget(self.open_song_browse_button) + self.open_song_layout.addRow(self.open_song_file_label, self.open_song_file_layout) + self.open_song_layout.setItem(1, QtGui.QFormLayout.LabelRole, self.spacer) + self.select_stack.addWidget(self.open_song_widget) + self.web_tab_widget = QtGui.QTabWidget(self.select_page) + self.web_tab_widget.setObjectName('WebTabWidget') + self.web_bible_tab = QtGui.QWidget() + self.web_bible_tab.setObjectName('WebBibleTab') + self.web_bible_layout = QtGui.QFormLayout(self.web_bible_tab) + self.web_bible_layout.setObjectName('WebBibleLayout') + self.web_source_label = QtGui.QLabel(self.web_bible_tab) + self.web_source_label.setObjectName('WebSourceLabel') + self.web_bible_layout.setWidget(0, QtGui.QFormLayout.LabelRole, self.web_source_label) + self.web_source_combo_box = QtGui.QComboBox(self.web_bible_tab) + self.web_source_combo_box.setObjectName('WebSourceComboBox') + self.web_source_combo_box.addItems(['', '', '']) + self.web_bible_layout.setWidget(0, QtGui.QFormLayout.FieldRole, self.web_source_combo_box) + self.web_translation_label = QtGui.QLabel(self.web_bible_tab) + self.web_translation_label.setObjectName('web_translation_label') + self.web_bible_layout.setWidget(1, QtGui.QFormLayout.LabelRole, self.web_translation_label) + self.web_translation_combo_box = QtGui.QComboBox(self.web_bible_tab) + self.web_translation_combo_box.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToContents) + self.web_translation_combo_box.setObjectName('WebTranslationComboBox') + self.web_bible_layout.setWidget(1, QtGui.QFormLayout.FieldRole, self.web_translation_combo_box) + self.web_tab_widget.addTab(self.web_bible_tab, '') + self.web_proxy_tab = QtGui.QWidget() + self.web_proxy_tab.setObjectName('WebProxyTab') + self.web_proxy_layout = QtGui.QFormLayout(self.web_proxy_tab) + self.web_proxy_layout.setObjectName('WebProxyLayout') + self.web_server_label = QtGui.QLabel(self.web_proxy_tab) + self.web_server_label.setObjectName('WebServerLabel') + self.web_proxy_layout.setWidget(0, QtGui.QFormLayout.LabelRole, self.web_server_label) + self.web_server_edit = QtGui.QLineEdit(self.web_proxy_tab) + self.web_server_edit.setObjectName('WebServerEdit') + self.web_proxy_layout.setWidget(0, QtGui.QFormLayout.FieldRole, self.web_server_edit) + self.web_user_label = QtGui.QLabel(self.web_proxy_tab) + self.web_user_label.setObjectName('WebUserLabel') + self.web_proxy_layout.setWidget(1, QtGui.QFormLayout.LabelRole, self.web_user_label) + self.web_user_edit = QtGui.QLineEdit(self.web_proxy_tab) + self.web_user_edit.setObjectName('WebUserEdit') + self.web_proxy_layout.setWidget(1, QtGui.QFormLayout.FieldRole, self.web_user_edit) + self.web_password_label = QtGui.QLabel(self.web_proxy_tab) + self.web_password_label.setObjectName('WebPasswordLabel') + self.web_proxy_layout.setWidget(2, QtGui.QFormLayout.LabelRole, self.web_password_label) + self.web_password_edit = QtGui.QLineEdit(self.web_proxy_tab) + self.web_password_edit.setObjectName('WebPasswordEdit') + self.web_proxy_layout.setWidget(2, QtGui.QFormLayout.FieldRole, self.web_password_edit) + self.web_tab_widget.addTab(self.web_proxy_tab, '') + self.select_stack.addWidget(self.web_tab_widget) + self.select_page_layout.addLayout(self.select_stack) + self.addPage(self.select_page) # License Page - self.licenseDetailsPage = QtGui.QWizardPage() - self.licenseDetailsPage.setObjectName('LicenseDetailsPage') - self.licenseDetailsLayout = QtGui.QFormLayout(self.licenseDetailsPage) - self.licenseDetailsLayout.setObjectName('LicenseDetailsLayout') - self.versionNameLabel = QtGui.QLabel(self.licenseDetailsPage) - self.versionNameLabel.setObjectName('VersionNameLabel') - self.licenseDetailsLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.versionNameLabel) - self.versionNameEdit = QtGui.QLineEdit(self.licenseDetailsPage) - self.versionNameEdit.setObjectName('VersionNameEdit') - self.licenseDetailsLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.versionNameEdit) - self.copyrightLabel = QtGui.QLabel(self.licenseDetailsPage) - self.copyrightLabel.setObjectName('CopyrightLabel') - self.licenseDetailsLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.copyrightLabel) - self.copyrightEdit = QtGui.QLineEdit(self.licenseDetailsPage) - self.copyrightEdit.setObjectName('CopyrightEdit') - self.licenseDetailsLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.copyrightEdit) - self.permissionsLabel = QtGui.QLabel(self.licenseDetailsPage) - self.permissionsLabel.setObjectName('PermissionsLabel') - self.licenseDetailsLayout.setWidget(2, QtGui.QFormLayout.LabelRole, - self.permissionsLabel) - self.permissionsEdit = QtGui.QLineEdit(self.licenseDetailsPage) - self.permissionsEdit.setObjectName('PermissionsEdit') - self.licenseDetailsLayout.setWidget(2, QtGui.QFormLayout.FieldRole, self.permissionsEdit) - self.addPage(self.licenseDetailsPage) + self.license_details_page = QtGui.QWizardPage() + self.license_details_page.setObjectName('LicenseDetailsPage') + self.license_details_layout = QtGui.QFormLayout(self.license_details_page) + self.license_details_layout.setObjectName('LicenseDetailsLayout') + self.version_name_label = QtGui.QLabel(self.license_details_page) + self.version_name_label.setObjectName('VersionNameLabel') + self.license_details_layout.setWidget(0, QtGui.QFormLayout.LabelRole, self.version_name_label) + self.version_name_edit = QtGui.QLineEdit(self.license_details_page) + self.version_name_edit.setObjectName('VersionNameEdit') + self.license_details_layout.setWidget(0, QtGui.QFormLayout.FieldRole, self.version_name_edit) + self.copyright_label = QtGui.QLabel(self.license_details_page) + self.copyright_label.setObjectName('CopyrightLabel') + self.license_details_layout.setWidget(1, QtGui.QFormLayout.LabelRole, self.copyright_label) + self.copyright_edit = QtGui.QLineEdit(self.license_details_page) + self.copyright_edit.setObjectName('CopyrightEdit') + self.license_details_layout.setWidget(1, QtGui.QFormLayout.FieldRole, self.copyright_edit) + self.permissions_label = QtGui.QLabel(self.license_details_page) + self.permissions_label.setObjectName('PermissionsLabel') + self.license_details_layout.setWidget(2, QtGui.QFormLayout.LabelRole, self.permissions_label) + self.permissions_edit = QtGui.QLineEdit(self.license_details_page) + self.permissions_edit.setObjectName('PermissionsEdit') + self.license_details_layout.setWidget(2, QtGui.QFormLayout.FieldRole, self.permissions_edit) + self.addPage(self.license_details_page) def retranslateUi(self): """ Allow for localisation of the bible import wizard. """ self.setWindowTitle(translate('BiblesPlugin.ImportWizardForm', 'Bible Import Wizard')) - self.title_label.setText(WizardStrings.HeaderStyle % - translate('OpenLP.Ui', 'Welcome to the Bible Import Wizard')) + self.title_label.setText(WizardStrings.HeaderStyle % translate('OpenLP.Ui', + 'Welcome to the Bible Import Wizard')) self.information_label.setText( translate('BiblesPlugin.ImportWizardForm', - 'This wizard will help you to import Bibles from a variety of ' - 'formats. Click the next button below to start the process by ' - 'selecting a format to import from.')) - self.selectPage.setTitle(WizardStrings.ImportSelect) - self.selectPage.setSubTitle(WizardStrings.ImportSelectLong) - self.formatLabel.setText(WizardStrings.FormatLabel) - self.formatComboBox.setItemText(BibleFormat.OSIS, WizardStrings.OSIS) - self.formatComboBox.setItemText(BibleFormat.CSV, WizardStrings.CSV) - self.formatComboBox.setItemText(BibleFormat.OpenSong, WizardStrings.OS) - self.formatComboBox.setItemText(BibleFormat.WebDownload, - translate('BiblesPlugin.ImportWizardForm', 'Web Download')) - self.osisFileLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Bible file:')) - self.csvBooksLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Books file:')) - self.csvVersesLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Verses file:')) - self.openSongFileLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Bible file:')) - self.webSourceLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Location:')) - self.webSourceComboBox.setItemText(WebDownload.Crosswalk, - translate('BiblesPlugin.ImportWizardForm', 'Crosswalk')) - self.webSourceComboBox.setItemText(WebDownload.BibleGateway, - translate('BiblesPlugin.ImportWizardForm', 'BibleGateway')) - self.webSourceComboBox.setItemText(WebDownload.Bibleserver, - translate('BiblesPlugin.ImportWizardForm', 'Bibleserver')) - self.webTranslationLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Bible:')) - self.webTabWidget.setTabText(self.webTabWidget.indexOf(self.webBibleTab), - translate('BiblesPlugin.ImportWizardForm', 'Download Options')) - self.webServerLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Server:')) - self.webUserLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Username:')) - self.webPasswordLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Password:')) - self.webTabWidget.setTabText(self.webTabWidget.indexOf(self.webProxyTab), - translate('BiblesPlugin.ImportWizardForm', - 'Proxy Server (Optional)')) - self.licenseDetailsPage.setTitle( + 'This wizard will help you to import Bibles from a variety of ' + 'formats. Click the next button below to start the process by ' + 'selecting a format to import from.')) + self.select_page.setTitle(WizardStrings.ImportSelect) + self.select_page.setSubTitle(WizardStrings.ImportSelectLong) + self.format_label.setText(WizardStrings.FormatLabel) + self.format_combo_box.setItemText(BibleFormat.OSIS, WizardStrings.OSIS) + self.format_combo_box.setItemText(BibleFormat.CSV, WizardStrings.CSV) + self.format_combo_box.setItemText(BibleFormat.OpenSong, WizardStrings.OS) + self.format_combo_box.setItemText(BibleFormat.WebDownload, translate('BiblesPlugin.ImportWizardForm', + 'Web Download')) + self.osis_file_label.setText(translate('BiblesPlugin.ImportWizardForm', 'Bible file:')) + self.csv_books_label.setText(translate('BiblesPlugin.ImportWizardForm', 'Books file:')) + self.csv_verses_label.setText(translate('BiblesPlugin.ImportWizardForm', 'Verses file:')) + self.open_song_file_label.setText(translate('BiblesPlugin.ImportWizardForm', 'Bible file:')) + self.web_source_label.setText(translate('BiblesPlugin.ImportWizardForm', 'Location:')) + self.web_source_combo_box.setItemText(WebDownload.Crosswalk, translate('BiblesPlugin.ImportWizardForm', + 'Crosswalk')) + self.web_source_combo_box.setItemText(WebDownload.BibleGateway, translate('BiblesPlugin.ImportWizardForm', + 'BibleGateway')) + self.web_source_combo_box.setItemText(WebDownload.Bibleserver, translate('BiblesPlugin.ImportWizardForm', + 'Bibleserver')) + self.web_translation_label.setText(translate('BiblesPlugin.ImportWizardForm', 'Bible:')) + self.web_tab_widget.setTabText(self.web_tab_widget.indexOf(self.web_bible_tab), + translate('BiblesPlugin.ImportWizardForm', 'Download Options')) + self.web_server_label.setText(translate('BiblesPlugin.ImportWizardForm', 'Server:')) + self.web_user_label.setText(translate('BiblesPlugin.ImportWizardForm', 'Username:')) + self.web_password_label.setText(translate('BiblesPlugin.ImportWizardForm', 'Password:')) + self.web_tab_widget.setTabText( + self.web_tab_widget.indexOf(self.web_proxy_tab), translate('BiblesPlugin.ImportWizardForm', + 'Proxy Server (Optional)')) + self.license_details_page.setTitle( translate('BiblesPlugin.ImportWizardForm', 'License Details')) - self.licenseDetailsPage.setSubTitle(translate('BiblesPlugin.ImportWizardForm', - 'Set up the Bible\'s license details.')) - self.versionNameLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Version name:')) - self.copyrightLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Copyright:')) - self.permissionsLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Permissions:')) + self.license_details_page.setSubTitle(translate('BiblesPlugin.ImportWizardForm', + 'Set up the Bible\'s license details.')) + self.version_name_label.setText(translate('BiblesPlugin.ImportWizardForm', 'Version name:')) + self.copyright_label.setText(translate('BiblesPlugin.ImportWizardForm', 'Copyright:')) + self.permissions_label.setText(translate('BiblesPlugin.ImportWizardForm', 'Permissions:')) self.progress_page.setTitle(WizardStrings.Importing) self.progress_page.setSubTitle(translate('BiblesPlugin.ImportWizardForm', - 'Please wait while your Bible is imported.')) + 'Please wait while your Bible is imported.')) self.progress_label.setText(WizardStrings.Ready) self.progress_bar.setFormat('%p%') # Align all QFormLayouts towards each other. - labelWidth = max(self.formatLabel.minimumSizeHint().width(), - self.osisFileLabel.minimumSizeHint().width(), - self.csvBooksLabel.minimumSizeHint().width(), - self.csvVersesLabel.minimumSizeHint().width(), - self.openSongFileLabel.minimumSizeHint().width()) - self.spacer.changeSize(labelWidth, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) + label_width = max(self.format_label.minimumSizeHint().width(), + self.osis_file_label.minimumSizeHint().width(), + self.csv_books_label.minimumSizeHint().width(), + self.csv_verses_label.minimumSizeHint().width(), + self.open_song_file_label.minimumSizeHint().width()) + self.spacer.changeSize(label_width, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) def validateCurrentPage(self): """ @@ -340,122 +340,130 @@ class BibleImportForm(OpenLPWizard): """ if self.currentPage() == self.welcome_page: return True - elif self.currentPage() == self.selectPage: + elif self.currentPage() == self.select_page: if self.field('source_format') == BibleFormat.OSIS: if not self.field('osis_location'): critical_error_message_box(UiStrings().NFSs, WizardStrings.YouSpecifyFile % WizardStrings.OSIS) - self.osisFileEdit.setFocus() + self.osis_file_edit.setFocus() return False elif self.field('source_format') == BibleFormat.CSV: if not self.field('csv_booksfile'): - critical_error_message_box(UiStrings().NFSs, translate('BiblesPlugin.ImportWizardForm', - 'You need to specify a file with books of the Bible to use in the import.')) - self.csvBooksEdit.setFocus() + critical_error_message_box( + UiStrings().NFSs, translate('BiblesPlugin.ImportWizardForm', + 'You need to specify a file with books of the Bible to use in the ' + 'import.')) + self.csv_books_edit.setFocus() return False elif not self.field('csv_versefile'): - critical_error_message_box(UiStrings().NFSs, - translate('BiblesPlugin.ImportWizardForm', - 'You need to specify a file of Bible verses to import.')) - self.csvVersesEdit.setFocus() + critical_error_message_box( + UiStrings().NFSs, + translate('BiblesPlugin.ImportWizardForm', 'You need to specify a file of Bible verses to ' + 'import.')) + self.csv_verses_edit.setFocus() return False elif self.field('source_format') == BibleFormat.OpenSong: if not self.field('opensong_file'): critical_error_message_box(UiStrings().NFSs, WizardStrings.YouSpecifyFile % WizardStrings.OS) - self.openSongFileEdit.setFocus() + self.open_song_file_edit.setFocus() return False elif self.field('source_format') == BibleFormat.WebDownload: - self.versionNameEdit.setText(self.webTranslationComboBox.currentText()) + self.version_name_edit.setText(self.web_translation_combo_box.currentText()) return True return True - elif self.currentPage() == self.licenseDetailsPage: + elif self.currentPage() == self.license_details_page: license_version = self.field('license_version') license_copyright = self.field('license_copyright') path = AppLocation.get_section_data_path('bibles') if not license_version: - critical_error_message_box(UiStrings().EmptyField, + critical_error_message_box( + UiStrings().EmptyField, translate('BiblesPlugin.ImportWizardForm', 'You need to specify a version name for your Bible.')) - self.versionNameEdit.setFocus() + self.version_name_edit.setFocus() return False elif not license_copyright: - critical_error_message_box(UiStrings().EmptyField, + critical_error_message_box( + UiStrings().EmptyField, translate('BiblesPlugin.ImportWizardForm', 'You need to set a copyright for your Bible. ' - 'Bibles in the Public Domain need to be marked as such.')) - self.copyrightEdit.setFocus() + 'Bibles in the Public Domain need to be marked as such.')) + self.copyright_edit.setFocus() return False elif self.manager.exists(license_version): - critical_error_message_box(translate('BiblesPlugin.ImportWizardForm', 'Bible Exists'), + critical_error_message_box( + translate('BiblesPlugin.ImportWizardForm', 'Bible Exists'), translate('BiblesPlugin.ImportWizardForm', - 'This Bible already exists. Please import a different Bible or first delete the existing one.')) - self.versionNameEdit.setFocus() + 'This Bible already exists. Please import a different Bible or first delete the ' + 'existing one.')) + self.version_name_edit.setFocus() return False - elif os.path.exists(os.path.join(path, clean_filename( - license_version))): + elif os.path.exists(os.path.join(path, clean_filename(license_version))): critical_error_message_box( translate('BiblesPlugin.ImportWizardForm', 'Bible Exists'), translate('BiblesPlugin.ImportWizardForm', 'This Bible already exists. Please import ' - 'a different Bible or first delete the existing one.')) - self.versionNameEdit.setFocus() + 'a different Bible or first delete the existing one.')) + self.version_name_edit.setFocus() return False return True if self.currentPage() == self.progress_page: return True - def onWebSourceComboBoxIndexChanged(self, index): + def on_web_source_combo_box_index_changed(self, index): """ - Setup the list of Bibles when you select a different source on the web - download page. + Setup the list of Bibles when you select a different source on the web download page. - ``index`` - The index of the combo box. + :param index: The index of the combo box. """ - self.webTranslationComboBox.clear() + self.web_translation_combo_box.clear() bibles = list(self.web_bible_list[index].keys()) bibles.sort(key=get_locale_key) - self.webTranslationComboBox.addItems(bibles) + self.web_translation_combo_box.addItems(bibles) - def onOsisBrowseButtonClicked(self): + def on_osis_browse_button_clicked(self): """ Show the file open dialog for the OSIS file. """ - self.get_file_name(WizardStrings.OpenTypeFile % WizardStrings.OSIS, self.osisFileEdit, 'last directory import') + self.get_file_name(WizardStrings.OpenTypeFile % WizardStrings.OSIS, self.osis_file_edit, + 'last directory import') - def onCsvBooksBrowseButtonClicked(self): + def on_csv_books_browse_button_clicked(self): """ Show the file open dialog for the books CSV file. """ - self.get_file_name(WizardStrings.OpenTypeFile % WizardStrings.CSV, self.csvBooksEdit, 'last directory import', - '%s (*.csv)' % translate('BiblesPlugin.ImportWizardForm', 'CSV File')) + self.get_file_name( + WizardStrings.OpenTypeFile % WizardStrings.CSV, self.csv_books_edit, 'last directory import', '%s (*.csv)' % + translate('BiblesPlugin.ImportWizardForm', 'CSV File')) - def onCsvVersesBrowseButtonClicked(self): + def on_csv_verses_browse_button_clicked(self): """ Show the file open dialog for the verses CSV file. """ - self.get_file_name(WizardStrings.OpenTypeFile % WizardStrings.CSV, self.csvVersesEdit, 'last directory import', - '%s (*.csv)' % translate('BiblesPlugin.ImportWizardForm', 'CSV File')) + self.get_file_name(WizardStrings.OpenTypeFile % WizardStrings.CSV, self.csv_verses_edit, + 'last directory import', '%s (*.csv)' % + translate('BiblesPlugin.ImportWizardForm', 'CSV File')) - def onOpenSongBrowseButtonClicked(self): + def on_open_song_browse_button_clicked(self): """ Show the file open dialog for the OpenSong file. """ - self.get_file_name(WizardStrings.OpenTypeFile % WizardStrings.OS, self.openSongFileEdit, 'last directory import') + self.get_file_name(WizardStrings.OpenTypeFile % WizardStrings.OS, self.open_song_file_edit, + 'last directory import') def register_fields(self): """ Register the bible import wizard fields. """ - self.selectPage.registerField('source_format', self.formatComboBox) - self.selectPage.registerField('osis_location', self.osisFileEdit) - self.selectPage.registerField('csv_booksfile', self.csvBooksEdit) - self.selectPage.registerField('csv_versefile', self.csvVersesEdit) - self.selectPage.registerField('opensong_file', self.openSongFileEdit) - self.selectPage.registerField('web_location', self.webSourceComboBox) - self.selectPage.registerField('web_biblename', self.webTranslationComboBox) - self.selectPage.registerField('proxy_server', self.webServerEdit) - self.selectPage.registerField('proxy_username', self.webUserEdit) - self.selectPage.registerField('proxy_password', self.webPasswordEdit) - self.licenseDetailsPage.registerField('license_version', self.versionNameEdit) - self.licenseDetailsPage.registerField('license_copyright', self.copyrightEdit) - self.licenseDetailsPage.registerField('license_permissions', self.permissionsEdit) + self.select_page.registerField('source_format', self.format_combo_box) + self.select_page.registerField('osis_location', self.osis_file_edit) + self.select_page.registerField('csv_booksfile', self.csv_books_edit) + self.select_page.registerField('csv_versefile', self.csv_verses_edit) + self.select_page.registerField('opensong_file', self.open_song_file_edit) + self.select_page.registerField('web_location', self.web_source_combo_box) + self.select_page.registerField('web_biblename', self.web_translation_combo_box) + self.select_page.registerField('proxy_server', self.web_server_edit) + self.select_page.registerField('proxy_username', self.web_user_edit) + self.select_page.registerField('proxy_password', self.web_password_edit) + self.license_details_page.registerField('license_version', self.version_name_edit) + self.license_details_page.registerField('license_copyright', self.copyright_edit) + self.license_details_page.registerField('license_permissions', self.permissions_edit) def setDefaults(self): """ @@ -472,33 +480,32 @@ class BibleImportForm(OpenLPWizard): self.setField('csv_versefile', '') self.setField('opensong_file', '') self.setField('web_location', WebDownload.Crosswalk) - self.setField('web_biblename', self.webTranslationComboBox.currentIndex()) + self.setField('web_biblename', self.web_translation_combo_box.currentIndex()) self.setField('proxy_server', settings.value('proxy address')) self.setField('proxy_username', settings.value('proxy username')) self.setField('proxy_password', settings.value('proxy password')) - self.setField('license_version', self.versionNameEdit.text()) - self.setField('license_copyright', self.copyrightEdit.text()) - self.setField('license_permissions', self.permissionsEdit.text()) - self.onWebSourceComboBoxIndexChanged(WebDownload.Crosswalk) + self.setField('license_version', self.version_name_edit.text()) + self.setField('license_copyright', self.copyright_edit.text()) + self.setField('license_permissions', self.permissions_edit.text()) + self.on_web_source_combo_box_index_changed(WebDownload.Crosswalk) settings.endGroup() - def loadWebBibles(self): + def load_Web_Bibles(self): """ Load the lists of Crosswalk, BibleGateway and Bibleserver bibles. """ # Load Crosswalk Bibles. - self.loadBibleResource(WebDownload.Crosswalk) + self.load_Bible_Resource(WebDownload.Crosswalk) # Load BibleGateway Bibles. - self.loadBibleResource(WebDownload.BibleGateway) + self.load_Bible_Resource(WebDownload.BibleGateway) # Load and Bibleserver Bibles. - self.loadBibleResource(WebDownload.Bibleserver) + self.load_Bible_Resource(WebDownload.Bibleserver) - def loadBibleResource(self, download_type): + def load_Bible_Resource(self, download_type): """ Loads a web bible from bible_resources.sqlite. - ``download_type`` - The WebDownload type e.g. bibleserver. + :param download_type: The WebDownload type e.g. bibleserver. """ self.web_bible_list[download_type] = {} bibles = BiblesResourcesDB.get_webbibles(WebDownload.Names[download_type]) @@ -530,28 +537,22 @@ class BibleImportForm(OpenLPWizard): importer = None if bible_type == BibleFormat.OSIS: # Import an OSIS bible. - importer = self.manager.import_bible(BibleFormat.OSIS, - name=license_version, - filename=self.field('osis_location') - ) + importer = self.manager.import_bible(BibleFormat.OSIS, name=license_version, + filename=self.field('osis_location')) elif bible_type == BibleFormat.CSV: # Import a CSV bible. - importer = self.manager.import_bible(BibleFormat.CSV, - name=license_version, - booksfile=self.field('csv_booksfile'), - versefile=self.field('csv_versefile') - ) + importer = self.manager.import_bible(BibleFormat.CSV, name=license_version, + booksfile=self.field('csv_booksfile'), + versefile=self.field('csv_versefile')) elif bible_type == BibleFormat.OpenSong: # Import an OpenSong bible. - importer = self.manager.import_bible(BibleFormat.OpenSong, - name=license_version, - filename=self.field('opensong_file') - ) + importer = self.manager.import_bible(BibleFormat.OpenSong, name=license_version, + filename=self.field('opensong_file')) elif bible_type == BibleFormat.WebDownload: # Import a bible from the web. self.progress_bar.setMaximum(1) download_location = self.field('web_location') - bible_version = self.webTranslationComboBox.currentText() + bible_version = self.web_translation_combo_box.currentText() bible = self.web_bible_list[download_location][bible_version] importer = self.manager.import_bible( BibleFormat.WebDownload, name=license_version, @@ -562,13 +563,12 @@ class BibleImportForm(OpenLPWizard): proxy_password=self.field('proxy_password') ) if importer.do_import(license_version): - self.manager.save_meta_data(license_version, license_version, - license_copyright, license_permissions) + self.manager.save_meta_data(license_version, license_version, license_copyright, license_permissions) self.manager.reload_bibles() if bible_type == BibleFormat.WebDownload: self.progress_label.setText( translate('BiblesPlugin.ImportWizardForm', 'Registered Bible. Please note, that verses will be ' - 'downloaded on\ndemand and thus an internet connection is required.')) + 'downloaded on\ndemand and thus an internet connection is required.')) else: self.progress_label.setText(WizardStrings.FinishedImport) else: diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index 2b574f778..9925b1ebc 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -96,34 +96,34 @@ class BibleUpgradeForm(OpenLPWizard): if not self.currentPage() == self.progress_page: self.done(QtGui.QDialog.Rejected) - def onCurrentIdChanged(self, pageId): + def onCurrentIdChanged(self, page_id): """ Perform necessary functions depending on which wizard page is active. """ - if self.page(pageId) == self.progress_page: + if self.page(page_id) == self.progress_page: self.pre_wizard() self.perform_wizard() self.post_wizard() - elif self.page(pageId) == self.selectPage and not self.files: + elif self.page(page_id) == self.selectPage and not self.files: self.next() - def onBackupBrowseButtonClicked(self): + def on_backup_browse_button_clicked(self): """ Show the file open dialog for the OSIS file. """ - filename = QtGui.QFileDialog.getExistingDirectory(self, - translate('BiblesPlugin.UpgradeWizardForm', 'Select a Backup Directory'), '') + filename = QtGui.QFileDialog.getExistingDirectory(self, translate('BiblesPlugin.UpgradeWizardForm', + 'Select a Backup Directory'), '') if filename: self.backupDirectoryEdit.setText(filename) - def onNoBackupCheckBoxToggled(self, checked): + def on_no_backup_check_box_toggled(self, checked): """ Enable or disable the backup directory widgets. """ self.backupDirectoryEdit.setEnabled(not checked) self.backupBrowseButton.setEnabled(not checked) - def backupOldBibles(self, backup_directory): + def backup_old_bibles(self, backup_directory): """ Backup old bible databases in a given folder. """ @@ -147,8 +147,8 @@ class BibleUpgradeForm(OpenLPWizard): """ Set up the signals used in the bible importer. """ - self.backupBrowseButton.clicked.connect(self.onBackupBrowseButtonClicked) - self.noBackupCheckBox.toggled.connect(self.onNoBackupCheckBoxToggled) + self.backupBrowseButton.clicked.connect(self.on_backup_browse_button_clicked) + self.noBackupCheckBox.toggled.connect(self.on_no_backup_check_box_toggled) def add_custom_pages(self): """ @@ -238,32 +238,34 @@ class BibleUpgradeForm(OpenLPWizard): Allow for localisation of the bible import wizard. """ self.setWindowTitle(translate('BiblesPlugin.UpgradeWizardForm', 'Bible Upgrade Wizard')) - self.title_label.setText(WizardStrings.HeaderStyle % - translate('OpenLP.Ui', 'Welcome to the Bible Upgrade Wizard')) - 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.title_label.setText(WizardStrings.HeaderStyle % translate('OpenLP.Ui', + 'Welcome to the Bible Upgrade Wizard')) + 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.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.' - ' This will create a backup of your current Bibles so that you can ' - 'simply copy the files back to your OpenLP data directory if you ' - 'need to revert to a previous release of OpenLP. Instructions on ' - 'how to restore the files can be found in our Frequently Asked Questions.')) - self.selectLabel.setText(translate('BiblesPlugin.UpgradeWizardForm', - 'Please select a backup location for your Bibles.')) + 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.' + ' This will create a backup of your current Bibles so that you can ' + 'simply copy the files back to your OpenLP data directory if you ' + 'need to revert to a previous release of OpenLP. Instructions on ' + 'how to restore the files can be found in our Frequently Asked Questions.')) + self.selectLabel.setText( + translate('BiblesPlugin.UpgradeWizardForm', 'Please select a backup location for your Bibles.')) self.backupDirectoryLabel.setText(translate('BiblesPlugin.UpgradeWizardForm', 'Backup Directory:')) self.noBackupCheckBox.setText( translate('BiblesPlugin.UpgradeWizardForm', 'There is no need to backup my Bibles')) self.selectPage.setTitle(translate('BiblesPlugin.UpgradeWizardForm', 'Select Bibles')) - self.selectPage.setSubTitle(translate('BiblesPlugin.UpgradeWizardForm', - 'Please select the Bibles to upgrade')) + self.selectPage.setSubTitle( + translate('BiblesPlugin.UpgradeWizardForm', 'Please select the Bibles to upgrade')) self.progress_page.setTitle(translate('BiblesPlugin.UpgradeWizardForm', 'Upgrading')) - self.progress_page.setSubTitle(translate('BiblesPlugin.UpgradeWizardForm', - 'Please wait while your Bibles are upgraded.')) + self.progress_page.setSubTitle( + translate('BiblesPlugin.UpgradeWizardForm', 'Please wait while your Bibles are upgraded.')) self.progress_label.setText(WizardStrings.Ready) self.progress_bar.setFormat('%p%') @@ -277,16 +279,18 @@ class BibleUpgradeForm(OpenLPWizard): if not self.noBackupCheckBox.checkState() == QtCore.Qt.Checked: backup_path = self.backupDirectoryEdit.text() if not backup_path: - critical_error_message_box(UiStrings().EmptyField, - translate('BiblesPlugin.UpgradeWizardForm', - 'You need to specify a backup directory for your Bibles.')) + critical_error_message_box( + UiStrings().EmptyField, + translate('BiblesPlugin.UpgradeWizardForm', 'You need to specify a backup directory for ' + 'your Bibles.')) self.backupDirectoryEdit.setFocus() return False else: - if not self.backupOldBibles(backup_path): - critical_error_message_box(UiStrings().Error, - translate('BiblesPlugin.UpgradeWizardForm', 'The backup was not successful.\nTo backup your ' - 'Bibles you need permission to write to the given directory.')) + if not self.backup_old_bibles(backup_path): + critical_error_message_box( + UiStrings().Error, + translate('BiblesPlugin.UpgradeWizardForm', 'The backup was not successful.\nTo backup ' + 'your Bibles you need permission to write to the given directory.')) return False return True elif self.currentPage() == self.selectPage: @@ -340,8 +344,8 @@ class BibleUpgradeForm(OpenLPWizard): self.includeWebBible = False proxy_server = None if not self.files: - self.progress_label.setText(translate('BiblesPlugin.UpgradeWizardForm', - 'There are no Bibles that need to be upgraded.')) + self.progress_label.setText( + translate('BiblesPlugin.UpgradeWizardForm', 'There are no Bibles that need to be upgraded.')) self.progress_bar.hide() return max_bibles = 0 @@ -363,11 +367,11 @@ class BibleUpgradeForm(OpenLPWizard): self.success[number] = False continue self.progress_bar.reset() - old_bible = OldBibleDB(self.media_item, path=self.temp_dir, - file=filename[0]) + old_bible = OldBibleDB(self.media_item, path=self.temp_dir, file=filename[0]) name = filename[1] - self.progress_label.setText(translate('BiblesPlugin.UpgradeWizardForm', - 'Upgrading Bible %s of %s: "%s"\nUpgrading ...') % (number + 1, max_bibles, name)) + self.progress_label.setText( + translate('BiblesPlugin.UpgradeWizardForm', + 'Upgrading Bible %s of %s: "%s"\nUpgrading ...') % (number + 1, max_bibles, name)) 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() @@ -404,7 +408,7 @@ class BibleUpgradeForm(OpenLPWizard): critical_error_message_box( translate('BiblesPlugin.UpgradeWizardForm', 'Download Error'), translate('BiblesPlugin.UpgradeWizardForm', - 'To upgrade your Web Bibles an Internet connection is required.')) + 'To upgrade your Web Bibles an Internet connection is required.')) 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()) @@ -415,16 +419,16 @@ class BibleUpgradeForm(OpenLPWizard): meta_data['download_source'].lower()) if bible and bible['language_id']: language_id = bible['language_id'] - self.new_bibles[number].save_meta('language_id', - language_id) + self.new_bibles[number].save_meta('language_id', language_id) else: language_id = self.new_bibles[number].get_language(name) if not language_id: log.warn('Upgrading from "%s" failed' % filename[0]) 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.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()) self.success[number] = False continue @@ -433,8 +437,10 @@ class BibleUpgradeForm(OpenLPWizard): if self.stop_import_flag: self.success[number] = False break - self.increment_progress_bar(translate('BiblesPlugin.UpgradeWizardForm', - 'Upgrading Bible %s of %s: "%s"\nUpgrading %s ...') % (number + 1, max_bibles, name, book)) + 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.new_bibles[number].\ get_book_ref_id_by_name(book, len(books), language_id) if not book_ref_id: @@ -445,8 +451,7 @@ class BibleUpgradeForm(OpenLPWizard): self.success[number] = False break book_details = BiblesResourcesDB.get_book_by_id(book_ref_id) - db_book = self.new_bibles[number].create_book(book, - book_ref_id, book_details['testament_id']) + db_book = self.new_bibles[number].create_book(book, book_ref_id, book_details['testament_id']) # Try to import already downloaded verses. oldbook = old_bible.get_book(book) if oldbook: @@ -458,9 +463,8 @@ class BibleUpgradeForm(OpenLPWizard): if self.stop_import_flag: self.success[number] = False break - self.new_bibles[number].create_verse(db_book.id, - int(verse['chapter']), - int(verse['verse']), str(verse['text'])) + self.new_bibles[number].create_verse(db_book.id, int(verse['chapter']), + int(verse['verse']), str(verse['text'])) self.application.process_events() self.new_bibles[number].session.commit() else: @@ -471,8 +475,9 @@ class BibleUpgradeForm(OpenLPWizard): log.warn('Upgrading books from "%s" failed' % name) 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.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()) self.success[number] = False continue @@ -482,8 +487,9 @@ class BibleUpgradeForm(OpenLPWizard): if self.stop_import_flag: self.success[number] = False break - self.increment_progress_bar(translate('BiblesPlugin.UpgradeWizardForm', - 'Upgrading Bible %s of %s: "%s"\nUpgrading %s ...') % + self.increment_progress_bar( + translate('BiblesPlugin.UpgradeWizardForm', + 'Upgrading Bible %s of %s: "%s"\nUpgrading %s ...') % (number + 1, max_bibles, name, book['name'])) book_ref_id = self.new_bibles[number].get_book_ref_id_by_name(book['name'], len(books), language_id) if not book_ref_id: @@ -493,8 +499,8 @@ class BibleUpgradeForm(OpenLPWizard): self.success[number] = False break book_details = BiblesResourcesDB.get_book_by_id(book_ref_id) - db_book = self.new_bibles[number].create_book(book['name'], - book_ref_id, book_details['testament_id']) + db_book = self.new_bibles[number].create_book(book['name'], book_ref_id, + book_details['testament_id']) verses = old_bible.get_verses(book['id']) if not verses: log.warn('No verses found to import for book "%s"', book['name']) @@ -504,20 +510,21 @@ class BibleUpgradeForm(OpenLPWizard): if self.stop_import_flag: self.success[number] = False break - self.new_bibles[number].create_verse(db_book.id, - int(verse['chapter']), - int(verse['verse']), str(verse['text'])) + self.new_bibles[number].create_verse(db_book.id, int(verse['chapter']), int(verse['verse']), + str(verse['text'])) self.application.process_events() 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.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.new_bibles[number].save_meta('name', name) - self.increment_progress_bar(translate('BiblesPlugin.UpgradeWizardForm', - 'Upgrading Bible %s of %s: "%s"\nComplete') % (number + 1, max_bibles, name)) + self.increment_progress_bar( + translate('BiblesPlugin.UpgradeWizardForm', + 'Upgrading Bible %s of %s: "%s"\nComplete') % (number + 1, max_bibles, name)) if number in self.new_bibles: self.new_bibles[number].session.close() # Close the last bible's connection if possible. @@ -545,12 +552,15 @@ class BibleUpgradeForm(OpenLPWizard): failed_import_text = '' if successful_import > 0: if self.includeWebBible: - self.progress_label.setText(translate('BiblesPlugin.UpgradeWizardForm', - 'Upgrading Bible(s): %s successful%s\nPlease note that verses from Web Bibles will be downloaded ' - 'on demand and so an Internet connection is required.') % (successful_import, failed_import_text)) + self.progress_label.setText( + translate('BiblesPlugin.UpgradeWizardForm', + 'Upgrading Bible(s): %s successful%s\nPlease note that verses from Web Bibles will be ' + 'downloaded on demand and so an Internet connection is required.') % + (successful_import, failed_import_text)) else: - self.progress_label.setText(translate('BiblesPlugin.UpgradeWizardForm', - 'Upgrading Bible(s): %s successful%s') % (successful_import, failed_import_text)) + self.progress_label.setText( + translate('BiblesPlugin.UpgradeWizardForm', 'Upgrading Bible(s): %s successful%s') % ( + successful_import, failed_import_text)) else: self.progress_label.setText(translate('BiblesPlugin.UpgradeWizardForm', 'Upgrade failed.')) # Remove temp directory. diff --git a/openlp/plugins/bibles/forms/booknamedialog.py b/openlp/plugins/bibles/forms/booknamedialog.py index 66eae6b09..5903391c3 100644 --- a/openlp/plugins/bibles/forms/booknamedialog.py +++ b/openlp/plugins/bibles/forms/booknamedialog.py @@ -32,6 +32,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.common import translate from openlp.core.lib.ui import create_button_box + class Ui_BookNameDialog(object): def setupUi(self, book_name_dialog): book_name_dialog.setObjectName('book_name_dialog') @@ -48,15 +49,15 @@ class Ui_BookNameDialog(object): self.corresponding_layout.setColumnStretch(1, 1) self.corresponding_layout.setSpacing(8) self.corresponding_layout.setObjectName('corresponding_layout') - self.currentLabel = QtGui.QLabel(book_name_dialog) - self.currentLabel.setObjectName('currentLabel') - self.corresponding_layout.addWidget(self.currentLabel, 0, 0, 1, 1) + self.current_label = QtGui.QLabel(book_name_dialog) + self.current_label.setObjectName('current_label') + self.corresponding_layout.addWidget(self.current_label, 0, 0, 1, 1) self.current_book_label = QtGui.QLabel(book_name_dialog) self.current_book_label.setObjectName('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('correspondingLabel') - self.corresponding_layout.addWidget(self.correspondingLabel, 1, 0, 1, 1) + self.corresponding_label = QtGui.QLabel(book_name_dialog) + self.corresponding_label.setObjectName('corresponding_label') + self.corresponding_layout.addWidget(self.corresponding_label, 1, 0, 1, 1) self.corresponding_combo_box = QtGui.QComboBox(book_name_dialog) self.corresponding_combo_box.setObjectName('corresponding_combo_box') self.corresponding_layout.addWidget(self.corresponding_combo_box, 1, 1, 1, 1) @@ -87,11 +88,11 @@ class Ui_BookNameDialog(object): 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.info_label.setText( + translate('BiblesPlugin.BookNameDialog', 'The following book name cannot be matched up internally. ' + 'Please select the corresponding name from the list.')) + self.current_label.setText(translate('BiblesPlugin.BookNameDialog', 'Current name:')) + self.corresponding_label.setText(translate('BiblesPlugin.BookNameDialog', 'Corresponding name:')) 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')) diff --git a/openlp/plugins/bibles/forms/booknameform.py b/openlp/plugins/bibles/forms/booknameform.py index 063a6618c..7d1242b7c 100644 --- a/openlp/plugins/bibles/forms/booknameform.py +++ b/openlp/plugins/bibles/forms/booknameform.py @@ -52,7 +52,7 @@ class BookNameForm(QDialog, Ui_BookNameDialog): """ log.info('BookNameForm loaded') - def __init__(self, parent = None): + def __init__(self, parent=None): """ Constructor """ @@ -66,11 +66,11 @@ class BookNameForm(QDialog, Ui_BookNameDialog): """ Set up the signals used in the booknameform. """ - 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) + self.old_testament_check_box.stateChanged.connect(self.on_check_box_index_changed) + self.new_testament_check_box.stateChanged.connect(self.on_check_box_index_changed) + self.apocrypha_check_box.stateChanged.connect(self.on_check_box_index_changed) - def onCheckBoxIndexChanged(self, index): + def on_check_box_index_changed(self, index): """ Reload Combobox if CheckBox state has changed """ @@ -119,7 +119,8 @@ class BookNameForm(QDialog, Ui_BookNameDialog): cor_book = self.corresponding_combo_box.currentText() for character in '\\.^$*+?{}[]()': cor_book = cor_book.replace(character, '\\' + character) - books = [key for key in list(self.book_names.keys()) if re.match(cor_book, str(self.book_names[key]), re.UNICODE)] + books = [key for key in list(self.book_names.keys()) if re.match(cor_book, str(self.book_names[key]), + re.UNICODE)] books = [_f for _f in map(BiblesResourcesDB.get_book, books) if _f] if books: self.book_id = books[0]['id'] diff --git a/openlp/plugins/bibles/forms/editbibledialog.py b/openlp/plugins/bibles/forms/editbibledialog.py index 48649daad..1fbaa2f1e 100644 --- a/openlp/plugins/bibles/forms/editbibledialog.py +++ b/openlp/plugins/bibles/forms/editbibledialog.py @@ -107,7 +107,7 @@ class Ui_EditBibleDialog(object): self.book_name_widget_layout = QtGui.QFormLayout(self.book_name_widget) self.book_name_widget_layout.setObjectName('book_name_widget_layout') self.book_name_label = {} - self.book_name_edit= {} + self.book_name_edit = {} for book in BiblesResourcesDB.get_books(): self.book_name_label[book['abbreviation']] = QtGui.QLabel(self.book_name_widget) self.book_name_label[book['abbreviation']].setObjectName('book_name_label[%s]' % book['abbreviation']) @@ -131,24 +131,28 @@ class Ui_EditBibleDialog(object): self.book_names = BibleStrings().BookNames edit_bible_dialog.setWindowTitle(translate('BiblesPlugin.EditBibleForm', 'Bible Editor')) # Meta tab - self.bible_tab_widget.setTabText( self.bible_tab_widget.indexOf(self.meta_tab), - translate('SongsPlugin.EditBibleForm', 'Meta Data')) + self.bible_tab_widget.setTabText( + self.bible_tab_widget.indexOf(self.meta_tab), translate('SongsPlugin.EditBibleForm', 'Meta Data')) 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.language_selection_label.setText( + translate('BiblesPlugin.EditBibleForm', 'Book name language in search field, search results and ' + 'on display:')) self.language_selection_combo_box.setItemText(0, translate('BiblesPlugin.EditBibleForm', 'Global Settings')) - self.language_selection_combo_box.setItemText(LanguageSelection.Bible + 1, + self.language_selection_combo_box.setItemText( + LanguageSelection.Bible + 1, translate('BiblesPlugin.EditBibleForm', 'Bible Language')) - self.language_selection_combo_box.setItemText(LanguageSelection.Application + 1, - translate('BiblesPlugin.EditBibleForm', 'Application Language')) - self.language_selection_combo_box.setItemText(LanguageSelection.English + 1, + self.language_selection_combo_box.setItemText( + LanguageSelection.Application + 1, translate('BiblesPlugin.EditBibleForm', 'Application Language')) + self.language_selection_combo_box.setItemText( + LanguageSelection.English + 1, translate('BiblesPlugin.EditBibleForm', 'English')) # Book name tab - self.bible_tab_widget.setTabText(self.bible_tab_widget.indexOf(self.book_name_tab), + 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.book_name_label[book['abbreviation']].setText('%s:' % str(self.book_names[book['abbreviation']])) diff --git a/openlp/plugins/bibles/forms/editbibleform.py b/openlp/plugins/bibles/forms/editbibleform.py index f2d97cc08..2d10fedfa 100644 --- a/openlp/plugins/bibles/forms/editbibleform.py +++ b/openlp/plugins/bibles/forms/editbibleform.py @@ -176,7 +176,7 @@ class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog, RegistryProperties): critical_error_message_box( UiStrings().EmptyField, translate('BiblesPlugin.BibleEditForm', 'You need to specify a book name for "%s".') % - self.book_names[abbreviation]) + self.book_names[abbreviation]) return False elif not book_regex.match(new_book_name): self.book_name_edit[abbreviation].setFocus() diff --git a/openlp/plugins/bibles/forms/languagedialog.py b/openlp/plugins/bibles/forms/languagedialog.py index a75df8ded..10382ea13 100644 --- a/openlp/plugins/bibles/forms/languagedialog.py +++ b/openlp/plugins/bibles/forms/languagedialog.py @@ -32,6 +32,7 @@ from PyQt4 import QtGui from openlp.core.common import translate from openlp.core.lib.ui import create_button_box + class Ui_LanguageDialog(object): def setupUi(self, language_dialog): language_dialog.setObjectName('language_dialog') @@ -54,11 +55,11 @@ class Ui_LanguageDialog(object): self.language_label.setObjectName('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.language_combo_box.sizePolicy().hasHeightForWidth()) - self.language_combo_box.setSizePolicy(sizePolicy) + size_policy = QtGui.QSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.Fixed) + size_policy.setHorizontalStretch(0) + size_policy.setVerticalStretch(0) + size_policy.setHeightForWidth(self.language_combo_box.sizePolicy().hasHeightForWidth()) + self.language_combo_box.setSizePolicy(size_policy) self.language_combo_box.setObjectName('language_combo_box') self.language_h_box_layout.addWidget(self.language_combo_box) self.language_layout.addLayout(self.language_h_box_layout) @@ -70,7 +71,8 @@ class Ui_LanguageDialog(object): 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.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.language_label.setText(translate('BiblesPlugin.LanguageDialog', 'Language:')) diff --git a/openlp/plugins/bibles/forms/languageform.py b/openlp/plugins/bibles/forms/languageform.py index 317132a57..f2c450494 100644 --- a/openlp/plugins/bibles/forms/languageform.py +++ b/openlp/plugins/bibles/forms/languageform.py @@ -36,8 +36,7 @@ from PyQt4.QtGui import QDialog from openlp.core.common import translate from openlp.core.lib.ui import critical_error_message_box -from openlp.plugins.bibles.forms.languagedialog import \ - Ui_LanguageDialog +from openlp.plugins.bibles.forms.languagedialog import Ui_LanguageDialog from openlp.plugins.bibles.lib.db import BiblesResourcesDB diff --git a/openlp/plugins/bibles/lib/__init__.py b/openlp/plugins/bibles/lib/__init__.py index 39bee992f..50a0e2a63 100644 --- a/openlp/plugins/bibles/lib/__init__.py +++ b/openlp/plugins/bibles/lib/__init__.py @@ -218,9 +218,10 @@ def update_reference_separators(): REFERENCE_MATCHES['range'] = re.compile('^\s*%s\s*$' % range_regex, re.UNICODE) REFERENCE_MATCHES['range_separator'] = re.compile(REFERENCE_SEPARATORS['sep_l'], re.UNICODE) # full reference match: ((,(?!$)|(?=$)))+ - REFERENCE_MATCHES['full'] = re.compile('^\s*(?!\s)(?P[\d]*[^\d]+)(?(?:%(range_regex)s(?:%(sep_l)s(?!\s*$)|(?=\s*$)))+)\s*$' \ - % dict(list(REFERENCE_SEPARATORS.items()) + [('range_regex', range_regex)]), re.UNICODE) + REFERENCE_MATCHES['full'] = \ + re.compile('^\s*(?!\s)(?P[\d]*[^\d]+)(?(?:%(range_regex)s(?:%(sep_l)s(?!\s*$)|(?=\s*$)))+)\s*$' + % dict(list(REFERENCE_SEPARATORS.items()) + [('range_regex', range_regex)]), re.UNICODE) def get_reference_separator(separator_type): diff --git a/openlp/plugins/bibles/lib/biblestab.py b/openlp/plugins/bibles/lib/biblestab.py index 8e5c50178..8f16bf830 100644 --- a/openlp/plugins/bibles/lib/biblestab.py +++ b/openlp/plugins/bibles/lib/biblestab.py @@ -422,7 +422,7 @@ class BiblesTab(SettingsTab): color.setAlpha(128) palette.setColor(QtGui.QPalette.Active, QtGui.QPalette.Text, color) return palette - + def check_is_verse_number_visible(self): """ Enables / Disables verse settings dependent on is_verse_number_visible @@ -430,4 +430,3 @@ class BiblesTab(SettingsTab): self.new_chapters_check_box.setEnabled(self.is_verse_number_visible) self.display_style_label.setEnabled(self.is_verse_number_visible) self.display_style_combo_box.setEnabled(self.is_verse_number_visible) - diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index a41545377..743bb01c6 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -80,23 +80,20 @@ def init_schema(url): meta_table = Table('metadata', metadata, Column('key', types.Unicode(255), primary_key=True, index=True), - Column('value', types.Unicode(255)), - ) + Column('value', types.Unicode(255)),) book_table = Table('book', metadata, Column('id', types.Integer, primary_key=True), Column('book_reference_id', types.Integer, index=True), Column('testament_reference_id', types.Integer), - Column('name', types.Unicode(50), index=True), - ) + Column('name', types.Unicode(50), index=True),) verse_table = Table('verse', metadata, Column('id', types.Integer, primary_key=True, index=True), Column('book_id', types.Integer, ForeignKey( 'book.id'), index=True), Column('chapter', types.Integer, index=True), Column('verse', types.Integer, index=True), - Column('text', types.UnicodeText, index=True), - ) + Column('text', types.UnicodeText, index=True),) try: class_mapper(BibleMeta) @@ -225,7 +222,8 @@ class BibleDB(QtCore.QObject, Manager, RegistryProperties): :param book_id: The id of the book being appended. :param chapter: The chapter number. - :param text_list: A dict of the verses to be inserted. The key is the verse number, and the value is the verse text. + :param text_list: A dict of the verses to be inserted. The key is the verse number, and the value is the + verse text. """ log.debug('BibleDBcreate_chapter("%s", "%s")', book_id, chapter) # Text list has book and chapter as first two elements of the array. @@ -437,7 +435,7 @@ class BibleDB(QtCore.QObject, Manager, RegistryProperties): """ log.debug('BibleDB.get_chapter_count("%s")', book.name) count = self.session.query(func.max(Verse.chapter)).join(Book).filter( - Book.book_reference_id==book.book_reference_id).scalar() + Book.book_reference_id == book.book_reference_id).scalar() if not count: return 0 return count @@ -718,8 +716,8 @@ class BiblesResourcesDB(QtCore.QObject, Manager): if not isinstance(source, str): source = str(source) source = BiblesResourcesDB.get_download_source(source) - bibles = BiblesResourcesDB.run_sql('SELECT id, name, abbreviation, ' - 'language_id, download_source_id FROM webbibles WHERE download_source_id = ?', (source['id'],)) + bibles = BiblesResourcesDB.run_sql('SELECT id, name, abbreviation, language_id, download_source_id ' + 'FROM webbibles WHERE download_source_id = ?', (source['id'],)) if bibles: return [{ 'id': bible[0], @@ -824,10 +822,9 @@ class BiblesResourcesDB(QtCore.QObject, Manager): log.debug('BiblesResourcesDB.get_testament_reference()') testaments = BiblesResourcesDB.run_sql('SELECT id, name FROM testament_reference ORDER BY id') return [ - { - 'id': testament[0], - 'name': str(testament[1]) - } + {'id': testament[0], + 'name': str(testament[1]) + } for testament in testaments ] @@ -934,7 +931,7 @@ class OldBibleDB(QtCore.QObject, Manager): QtCore.QObject.__init__(self) if 'path' not in kwargs: raise KeyError('Missing keyword argument "path".') - if 'file' not in kwargs: + if 'file' not in kwargs: raise KeyError('Missing keyword argument "file".') if 'path' in kwargs: self.path = kwargs['path'] diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index 3400c9a56..340d8ef92 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -32,7 +32,9 @@ The :mod:`http` module enables OpenLP to retrieve scripture from bible websites. import logging import re import socket -import urllib.request, urllib.parse, urllib.error +import urllib.request +import urllib.parse +import urllib.error from html.parser import HTMLParseError from bs4 import BeautifulSoup, NavigableString, Tag @@ -487,7 +489,7 @@ class HTTPBible(BibleDB, RegistryProperties): (self.download_source, self.download_name)) return False self.wizard.progress_bar.setMaximum(len(books) + 2) - self.wizard.increment_progress_bar(translate( 'BiblesPlugin.HTTPBible', 'Registering Language...')) + self.wizard.increment_progress_bar(translate('BiblesPlugin.HTTPBible', 'Registering Language...')) bible = BiblesResourcesDB.get_webbible(self.download_name, self.download_source.lower()) if bible['language_id']: language_id = bible['language_id'] diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 4b8b8bc83..10fef8e31 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -664,7 +664,7 @@ class BibleMediaItem(MediaManagerItem): db_book = bibles[second_bible].get_book_by_book_ref_id(verse.book.book_reference_id) if not db_book: log.debug('Passage "%s %d:%d" not found in Second Bible' % - (verse.book.name, verse.chapter, verse.verse)) + (verse.book.name, verse.chapter, verse.verse)) passage_not_found = True count += 1 continue @@ -910,8 +910,8 @@ class BibleMediaItem(MediaManagerItem): elif old_verse + 1 != verse and old_chapter == chapter: # We are still in the same chapter, but a verse has been skipped. return True - elif old_chapter + 1 == chapter and (verse != 1 or - old_verse != self.plugin.manager.get_verse_count(old_bible, old_book, old_chapter)): + elif old_chapter + 1 == chapter and (verse != 1 or old_verse != + self.plugin.manager.get_verse_count(old_bible, old_book, old_chapter)): # We are in the following chapter, but the last verse was not the # last verse of the chapter or the current verse is not the # first one of the chapter. diff --git a/openlp/plugins/images/forms/addgroupform.py b/openlp/plugins/images/forms/addgroupform.py index d5f26f308..414a8e4b9 100644 --- a/openlp/plugins/images/forms/addgroupform.py +++ b/openlp/plugins/images/forms/addgroupform.py @@ -50,7 +50,8 @@ class AddGroupForm(QtGui.QDialog, Ui_AddGroupDialog): Show the form. :param clear: Set to False if the text input box should not be cleared when showing the dialog (default: True). - :param show_top_level_group: Set to True when "-- Top level group --" should be showed as first item (default: False). + :param show_top_level_group: Set to True when "-- Top level group --" should be showed as first item + (default: False). :param selected_group: The ID of the group that should be selected by default when showing the dialog. """ if clear: diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index 5b88bfb36..b2eb5b816 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -327,7 +327,8 @@ class ImageMediaItem(MediaManagerItem): :param images: A List of Image Filenames objects that will be used to reload the mediamanager list. :param initial_load: When set to False, the busy cursor and progressbar will be shown while loading images. - :param open_group: ImageGroups object of the group that must be expanded after reloading the list in the interface. + :param open_group: ImageGroups object of the group that must be expanded after reloading the list in the + interface. """ if not initial_load: self.application.set_busy_cursor() @@ -462,7 +463,8 @@ class ImageMediaItem(MediaManagerItem): :param images_list: A List of strings containing image filenames :param group_id: The ID of the group to save the images in - :param reload_list: This boolean is set to True when the list in the interface should be reloaded after saving the new images + :param reload_list: This boolean is set to True when the list in the interface should be reloaded after saving + the new images """ for filename in images_list: if not isinstance(filename, str): diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index 01a28f9ca..56d3a49f4 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -34,7 +34,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.common import Registry, RegistryProperties, AppLocation, Settings, check_directory_exists, UiStrings,\ translate -from openlp.core.lib import ItemCapabilities, MediaManagerItem,MediaType, ServiceItem, ServiceItemContext, \ +from openlp.core.lib import ItemCapabilities, MediaManagerItem, MediaType, ServiceItem, ServiceItemContext, \ build_icon, check_item_selected from openlp.core.lib.ui import critical_error_message_box, create_horizontal_adjusting_combo_box from openlp.core.ui import DisplayController, Display, DisplayControllerType @@ -161,7 +161,7 @@ class MediaMediaItem(MediaManagerItem, RegistryProperties): Called to replace Live background with the media selected. """ if check_item_selected(self.list_view, - translate('MediaPlugin.MediaItem', + translate('MediaPlugin.MediaItem', 'You must select a media file to replace the background with.')): item = self.list_view.currentItem() filename = item.data(QtCore.Qt.UserRole) @@ -170,12 +170,12 @@ class MediaMediaItem(MediaManagerItem, RegistryProperties): service_item.title = 'webkit' service_item.processor = 'webkit' (path, name) = os.path.split(filename) - service_item.add_from_command(path, name,CLAPPERBOARD) + service_item.add_from_command(path, name, CLAPPERBOARD) if self.media_controller.video(DisplayControllerType.Live, service_item, video_behind_text=True): self.reset_action.setVisible(True) else: critical_error_message_box(UiStrings().LiveBGError, - translate('MediaPlugin.MediaItem', + translate('MediaPlugin.MediaItem', 'There was no display item to amend.')) else: critical_error_message_box(UiStrings().LiveBGError, diff --git a/openlp/plugins/songusage/forms/songusagedeleteform.py b/openlp/plugins/songusage/forms/songusagedeleteform.py index f7c05e0e6..64bd56768 100644 --- a/openlp/plugins/songusage/forms/songusagedeleteform.py +++ b/openlp/plugins/songusage/forms/songusagedeleteform.py @@ -70,4 +70,4 @@ class SongUsageDeleteForm(QtGui.QDialog, Ui_SongUsageDeleteDialog, RegistryPrope ) self.accept() else: - self.reject() \ No newline at end of file + self.reject() diff --git a/openlp/plugins/songusage/forms/songusagedetailform.py b/openlp/plugins/songusage/forms/songusagedetailform.py index eb5963228..e8111c058 100644 --- a/openlp/plugins/songusage/forms/songusagedetailform.py +++ b/openlp/plugins/songusage/forms/songusagedetailform.py @@ -87,15 +87,14 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog, RegistryPrope ) return check_directory_exists(path) - file_name = translate('SongUsagePlugin.SongUsageDetailForm', 'usage_detail_%s_%s.txt') % ( - self.from_date_calendar.selectedDate().toString('ddMMyyyy'), - self.to_date_calendar.selectedDate().toString('ddMMyyyy')) + file_name = translate('SongUsagePlugin.SongUsageDetailForm', 'usage_detail_%s_%s.txt') % \ + (self.from_date_calendar.selectedDate().toString('ddMMyyyy'), + self.to_date_calendar.selectedDate().toString('ddMMyyyy')) Settings().setValue(self.plugin.settings_section + '/from date', self.from_date_calendar.selectedDate()) Settings().setValue(self.plugin.settings_section + '/to date', self.to_date_calendar.selectedDate()) usage = self.plugin.manager.get_all_objects( - SongUsageItem, and_( - SongUsageItem.usagedate >= self.from_date_calendar.selectedDate().toPyDate(), - SongUsageItem.usagedate < self.to_date_calendar.selectedDate().toPyDate()), + SongUsageItem, and_(SongUsageItem.usagedate >= self.from_date_calendar.selectedDate().toPyDate(), + SongUsageItem.usagedate < self.to_date_calendar.selectedDate().toPyDate()), [SongUsageItem.usagedate, SongUsageItem.usagetime]) report_file_name = os.path.join(path, file_name) file_handle = None @@ -103,9 +102,9 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog, RegistryPrope file_handle = open(report_file_name, 'w') for instance in usage: record = '\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",' \ - '\"%s\",\"%s\"\n' % (instance.usagedate, - instance.usagetime, instance.title, instance.copyright, - instance.ccl_number, instance.authors, instance.plugin_name, instance.source) + '\"%s\",\"%s\"\n' % \ + (instance.usagedate, instance.usagetime, instance.title, instance.copyright, + instance.ccl_number, instance.authors, instance.plugin_name, instance.source) file_handle.write(record.encode('utf-8')) self.main_window.information_message( translate('SongUsagePlugin.SongUsageDetailForm', 'Report Creation'), diff --git a/openlp/plugins/songusage/lib/db.py b/openlp/plugins/songusage/lib/db.py index b7b9c6801..9d9fff460 100644 --- a/openlp/plugins/songusage/lib/db.py +++ b/openlp/plugins/songusage/lib/db.py @@ -62,7 +62,7 @@ def init_schema(url): Column('ccl_number', types.Unicode(65)), Column('plugin_name', types.Unicode(20)), Column('source', types.Unicode(10)) - ) + ) mapper(SongUsageItem, songusage_table)