From 6d0e006b09feac02e1e85c70fe68aff7a8741433 Mon Sep 17 00:00:00 2001 From: Simon Hanna Date: Sun, 3 Jan 2016 14:03:29 +0100 Subject: [PATCH 01/18] Change Combobox to Checkbox for plugin states --- openlp/core/ui/plugindialog.py | 10 ++++------ openlp/core/ui/pluginform.py | 19 ++++++++----------- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/openlp/core/ui/plugindialog.py b/openlp/core/ui/plugindialog.py index 5d36dd72c..273d20383 100644 --- a/openlp/core/ui/plugindialog.py +++ b/openlp/core/ui/plugindialog.py @@ -53,10 +53,9 @@ class Ui_PluginViewDialog(object): self.plugin_info_layout.setObjectName('plugin_info_layout') self.status_label = QtWidgets.QLabel(self.plugin_info_group_box) self.status_label.setObjectName('status_label') - self.status_combo_box = QtWidgets.QComboBox(self.plugin_info_group_box) - self.status_combo_box.addItems(('', '')) - self.status_combo_box.setObjectName('status_combo_box') - self.plugin_info_layout.addRow(self.status_label, self.status_combo_box) + self.status_checkbox = QtWidgets.QCheckBox(self.plugin_info_group_box) + self.status_checkbox.setObjectName('status_checkbox') + self.plugin_info_layout.addRow(self.status_label, self.status_checkbox) self.version_label = QtWidgets.QLabel(self.plugin_info_group_box) self.version_label.setObjectName('version_label') self.version_number_label = QtWidgets.QLabel(self.plugin_info_group_box) @@ -83,5 +82,4 @@ class Ui_PluginViewDialog(object): self.version_label.setText('%s:' % UiStrings().Version) self.about_label.setText('%s:' % UiStrings().About) self.status_label.setText(translate('OpenLP.PluginForm', 'Status:')) - self.status_combo_box.setItemText(0, translate('OpenLP.PluginForm', 'Active')) - self.status_combo_box.setItemText(1, translate('OpenLP.PluginForm', 'Inactive')) + self.status_checkbox.setText(translate('OpenLP.PluginForm', 'Active')) diff --git a/openlp/core/ui/pluginform.py b/openlp/core/ui/pluginform.py index 7d71e8ff4..040e9f3a1 100644 --- a/openlp/core/ui/pluginform.py +++ b/openlp/core/ui/pluginform.py @@ -49,7 +49,7 @@ class PluginForm(QtWidgets.QDialog, Ui_PluginViewDialog, RegistryProperties): self._clear_details() # Right, now let's put some signals and slots together! self.plugin_list_widget.itemSelectionChanged.connect(self.on_plugin_list_widget_selection_changed) - self.status_combo_box.currentIndexChanged.connect(self.on_status_combo_box_changed) + self.status_checkbox.stateChanged.connect(self.on_status_checkbox_changed) def load(self): """ @@ -86,10 +86,10 @@ class PluginForm(QtWidgets.QDialog, Ui_PluginViewDialog, RegistryProperties): """ Clear the plugin details widgets """ - self.status_combo_box.setCurrentIndex(-1) + self.status_checkbox.setChecked(False) self.version_number_label.setText('') self.about_text_browser.setHtml('') - self.status_combo_box.setEnabled(False) + self.status_checkbox.setEnabled(False) def _set_details(self): """ @@ -99,11 +99,8 @@ class PluginForm(QtWidgets.QDialog, Ui_PluginViewDialog, RegistryProperties): self.version_number_label.setText(self.active_plugin.version) self.about_text_browser.setHtml(self.active_plugin.about()) self.programatic_change = True - status = PluginStatus.Active - if self.active_plugin.status == PluginStatus.Active: - status = PluginStatus.Inactive - self.status_combo_box.setCurrentIndex(status) - self.status_combo_box.setEnabled(True) + self.status_checkbox.setChecked(self.active_plugin.status == PluginStatus.Active) + self.status_checkbox.setEnabled(True) self.programatic_change = False def on_plugin_list_widget_selection_changed(self): @@ -125,13 +122,13 @@ class PluginForm(QtWidgets.QDialog, Ui_PluginViewDialog, RegistryProperties): else: self._clear_details() - def on_status_combo_box_changed(self, status): + def on_status_checkbox_changed(self, status): """ If the status of a plugin is altered, apply the change """ - if self.programatic_change or status == PluginStatus.Disabled: + if self.programatic_change: return - if status == PluginStatus.Inactive: + if status: self.application.set_busy_cursor() self.active_plugin.toggle_status(PluginStatus.Active) self.application.set_normal_cursor() From ed0b739d97c153820a83323ecfc80b9259abebd9 Mon Sep 17 00:00:00 2001 From: Simon Hanna Date: Sun, 3 Jan 2016 15:00:23 +0100 Subject: [PATCH 02/18] Add .coveragerc --- .bzrignore | 1 + .coveragerc | 5 +++++ 2 files changed, 6 insertions(+) create mode 100644 .coveragerc diff --git a/.bzrignore b/.bzrignore index 272c37e88..68fa826de 100644 --- a/.bzrignore +++ b/.bzrignore @@ -43,3 +43,4 @@ __pycache__ .coverage cover *.kdev4 +coverage diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 000000000..f8f529f44 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,5 @@ +[run] +source = openlp + +[html] +directory = coverage From 480a2d8512bf17d2088e500bac951a535681b2fb Mon Sep 17 00:00:00 2001 From: Simon Hanna Date: Sun, 3 Jan 2016 15:50:41 +0100 Subject: [PATCH 03/18] Make about() method of SongUsagePlugin static and add a test for it --- openlp/plugins/songusage/songusageplugin.py | 5 +-- .../openlp_plugins/songusage/__init__.py | 24 ++++++++++++++ .../songusage/test_songusage.py | 31 +++++++++++++++++++ 3 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 tests/functional/openlp_plugins/songusage/__init__.py create mode 100644 tests/functional/openlp_plugins/songusage/test_songusage.py diff --git a/openlp/plugins/songusage/songusageplugin.py b/openlp/plugins/songusage/songusageplugin.py index 0bf8ed9a5..b433d96e0 100644 --- a/openlp/plugins/songusage/songusageplugin.py +++ b/openlp/plugins/songusage/songusageplugin.py @@ -226,8 +226,9 @@ class SongUsagePlugin(Plugin): """ self.song_usage_detail_form.initialise() self.song_usage_detail_form.exec() - - def about(self): + + @staticmethod + def about(): """ The plugin about text diff --git a/tests/functional/openlp_plugins/songusage/__init__.py b/tests/functional/openlp_plugins/songusage/__init__.py new file mode 100644 index 000000000..917bf47cd --- /dev/null +++ b/tests/functional/openlp_plugins/songusage/__init__.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2016 OpenLP Developers # +# --------------------------------------------------------------------------- # +# This program is free software; you can redistribute it and/or modify it # +# under the terms of the GNU General Public License as published by the Free # +# Software Foundation; version 2 of the License. # +# # +# This program is distributed in the hope that it will be useful, but WITHOUT # +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # +# more details. # +# # +# You should have received a copy of the GNU General Public License along # +# with this program; if not, write to the Free Software Foundation, Inc., 59 # +# Temple Place, Suite 330, Boston, MA 02111-1307 USA # +############################################################################### +""" +Tests for the Songusage plugin +""" diff --git a/tests/functional/openlp_plugins/songusage/test_songusage.py b/tests/functional/openlp_plugins/songusage/test_songusage.py new file mode 100644 index 000000000..7b940bc20 --- /dev/null +++ b/tests/functional/openlp_plugins/songusage/test_songusage.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2016 OpenLP Developers # +# --------------------------------------------------------------------------- # +# This program is free software; you can redistribute it and/or modify it # +# under the terms of the GNU General Public License as published by the Free # +# Software Foundation; version 2 of the License. # +# # +# This program is distributed in the hope that it will be useful, but WITHOUT # +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # +# more details. # +# # +# You should have received a copy of the GNU General Public License along # +# with this program; if not, write to the Free Software Foundation, Inc., 59 # +# Temple Place, Suite 330, Boston, MA 02111-1307 USA # +############################################################################### +""" +This module contains tests for the Songusage plugin. +""" +from unittest import TestCase +from openlp.plugins.songusage.songusageplugin import SongUsagePlugin + +class TestSongUsage(TestCase): + + def test_about_text(self): + self.assertNotEquals(len(SongUsagePlugin.about()), 0) From 9ced5436bae39514014661b3545d4f8469fec0a8 Mon Sep 17 00:00:00 2001 From: Simon Hanna Date: Mon, 22 Feb 2016 15:34:00 +0100 Subject: [PATCH 04/18] Fix exception caused when plugins are disabled --- openlp/core/ui/pluginform.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/pluginform.py b/openlp/core/ui/pluginform.py index d7bd1d1d6..d67e7ea1e 100644 --- a/openlp/core/ui/pluginform.py +++ b/openlp/core/ui/pluginform.py @@ -126,7 +126,7 @@ class PluginForm(QtWidgets.QDialog, Ui_PluginViewDialog, RegistryProperties): """ If the status of a plugin is altered, apply the change """ - if self.programatic_change: + if self.programatic_change or self.active_plugin is None: return if status: self.application.set_busy_cursor() From 9356d990acf5f061cc7ae198e8c6eb80e6e34ad0 Mon Sep 17 00:00:00 2001 From: Simon Hanna Date: Mon, 22 Feb 2016 15:51:11 +0100 Subject: [PATCH 05/18] Show plugin information even if the plugin is disabled --- openlp/core/ui/pluginform.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/openlp/core/ui/pluginform.py b/openlp/core/ui/pluginform.py index d67e7ea1e..f43757b44 100644 --- a/openlp/core/ui/pluginform.py +++ b/openlp/core/ui/pluginform.py @@ -99,8 +99,12 @@ class PluginForm(QtWidgets.QDialog, Ui_PluginViewDialog, RegistryProperties): self.version_number_label.setText(self.active_plugin.version) self.about_text_browser.setHtml(self.active_plugin.about()) self.programatic_change = True - self.status_checkbox.setChecked(self.active_plugin.status == PluginStatus.Active) - self.status_checkbox.setEnabled(True) + if self.active_plugin.status != PluginStatus.Disabled: + self.status_checkbox.setChecked(self.active_plugin.status == PluginStatus.Active) + self.status_checkbox.setEnabled(True) + else: + self.status_checkbox.setChecked(False) + self.status_checkbox.setEnabled(False) self.programatic_change = False def on_plugin_list_widget_selection_changed(self): @@ -113,10 +117,9 @@ class PluginForm(QtWidgets.QDialog, Ui_PluginViewDialog, RegistryProperties): plugin_name_singular = self.plugin_list_widget.currentItem().text().split('(')[0][:-1] self.active_plugin = None for plugin in self.plugin_manager.plugins: - if plugin.status != PluginStatus.Disabled: - if plugin.name_strings['singular'] == plugin_name_singular: - self.active_plugin = plugin - break + if plugin.name_strings['singular'] == plugin_name_singular: + self.active_plugin = plugin + break if self.active_plugin: self._set_details() else: From 1d51939308070471702d7e745dae028b009bf77e Mon Sep 17 00:00:00 2001 From: Simon Hanna Date: Mon, 22 Feb 2016 15:51:58 +0100 Subject: [PATCH 06/18] Do not show version numbers for plugins --- openlp/core/ui/plugindialog.py | 6 ------ openlp/core/ui/pluginform.py | 2 -- 2 files changed, 8 deletions(-) diff --git a/openlp/core/ui/plugindialog.py b/openlp/core/ui/plugindialog.py index 273d20383..583728fcd 100644 --- a/openlp/core/ui/plugindialog.py +++ b/openlp/core/ui/plugindialog.py @@ -56,11 +56,6 @@ class Ui_PluginViewDialog(object): self.status_checkbox = QtWidgets.QCheckBox(self.plugin_info_group_box) self.status_checkbox.setObjectName('status_checkbox') self.plugin_info_layout.addRow(self.status_label, self.status_checkbox) - self.version_label = QtWidgets.QLabel(self.plugin_info_group_box) - self.version_label.setObjectName('version_label') - self.version_number_label = QtWidgets.QLabel(self.plugin_info_group_box) - self.version_number_label.setObjectName('version_number_label') - self.plugin_info_layout.addRow(self.version_label, self.version_number_label) self.about_label = QtWidgets.QLabel(self.plugin_info_group_box) self.about_label.setObjectName('about_label') self.about_text_browser = QtWidgets.QTextBrowser(self.plugin_info_group_box) @@ -79,7 +74,6 @@ class Ui_PluginViewDialog(object): """ plugin_view_dialog.setWindowTitle(translate('OpenLP.PluginForm', 'Manage Plugins')) self.plugin_info_group_box.setTitle(translate('OpenLP.PluginForm', 'Plugin Details')) - self.version_label.setText('%s:' % UiStrings().Version) self.about_label.setText('%s:' % UiStrings().About) self.status_label.setText(translate('OpenLP.PluginForm', 'Status:')) self.status_checkbox.setText(translate('OpenLP.PluginForm', 'Active')) diff --git a/openlp/core/ui/pluginform.py b/openlp/core/ui/pluginform.py index f43757b44..cb6dd70aa 100644 --- a/openlp/core/ui/pluginform.py +++ b/openlp/core/ui/pluginform.py @@ -87,7 +87,6 @@ class PluginForm(QtWidgets.QDialog, Ui_PluginViewDialog, RegistryProperties): Clear the plugin details widgets """ self.status_checkbox.setChecked(False) - self.version_number_label.setText('') self.about_text_browser.setHtml('') self.status_checkbox.setEnabled(False) @@ -96,7 +95,6 @@ class PluginForm(QtWidgets.QDialog, Ui_PluginViewDialog, RegistryProperties): Set the details of the currently selected plugin """ log.debug('PluginStatus: %s', str(self.active_plugin.status)) - self.version_number_label.setText(self.active_plugin.version) self.about_text_browser.setHtml(self.active_plugin.about()) self.programatic_change = True if self.active_plugin.status != PluginStatus.Disabled: From 2433efdfd064443d6adbd3327012a982c2f8e43c Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Tue, 29 Mar 2016 16:45:59 +0100 Subject: [PATCH 07/18] Update themes in service manager when themes are set in settings --- openlp/core/ui/servicemanager.py | 1 + openlp/core/ui/themestab.py | 1 + .../openlp_core_ui/test_themetab.py | 84 +++++++++++++++++++ 3 files changed, 86 insertions(+) create mode 100644 tests/functional/openlp_core_ui/test_themetab.py diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index fdae5c069..067fd86c7 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -1326,6 +1326,7 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtWidgets.QWidget, Ui_ServiceMa visible = self.renderer.theme_level == ThemeLevel.Global self.theme_label.setVisible(visible) self.theme_combo_box.setVisible(visible) + self.regenerate_service_items() def regenerate_service_items(self, changed=False): """ diff --git a/openlp/core/ui/themestab.py b/openlp/core/ui/themestab.py index a953ae013..07474ca74 100644 --- a/openlp/core/ui/themestab.py +++ b/openlp/core/ui/themestab.py @@ -160,6 +160,7 @@ class ThemesTab(SettingsTab): settings.endGroup() self.renderer.set_theme_level(self.theme_level) if self.tab_visited: + print("processed") self.settings_form.register_post_process('theme_update_global') self.tab_visited = False diff --git a/tests/functional/openlp_core_ui/test_themetab.py b/tests/functional/openlp_core_ui/test_themetab.py new file mode 100644 index 000000000..8896ae8f0 --- /dev/null +++ b/tests/functional/openlp_core_ui/test_themetab.py @@ -0,0 +1,84 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2016 OpenLP Developers # +# --------------------------------------------------------------------------- # +# This program is free software; you can redistribute it and/or modify it # +# under the terms of the GNU General Public License as published by the Free # +# Software Foundation; version 2 of the License. # +# # +# This program is distributed in the hope that it will be useful, but WITHOUT # +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # +# more details. # +# # +# You should have received a copy of the GNU General Public License along # +# with this program; if not, write to the Free Software Foundation, Inc., 59 # +# Temple Place, Suite 330, Boston, MA 02111-1307 USA # +############################################################################### +""" +Package to test the openlp.core.ui.ThemeTab package. +""" +from unittest import TestCase + +from openlp.core.common import Registry +from openlp.core.ui.themestab import ThemesTab +from openlp.core.ui.settingsform import SettingsForm + +from tests.helpers.testmixin import TestMixin +from tests.functional import MagicMock + + +class TestThemeTab(TestCase, TestMixin): + + def setUp(self): + """ + Set up a few things for the tests + """ + Registry.create() + + def test_creation(self): + """ + Test that Themes Tab is created. + """ + # GIVEN: A new Advanced Tab + settings_form = SettingsForm(None) + + # WHEN: I create an advanced tab + themes_tab = ThemesTab(settings_form) + + # THEN: + self.assertEqual("Themes", themes_tab.tab_title, 'The tab title should be Theme') + + def test_save_triggers_processes_true(self): + """ + Test that the global theme event is triggered when the tab is visited. + """ + # GIVEN: A new Advanced Tab + settings_form = SettingsForm(None) + themes_tab = ThemesTab(settings_form) + Registry().register('renderer', MagicMock()) + themes_tab.tab_visited = True + # WHEN: I change search as type check box + themes_tab.save() + + # THEN: we should have two post save processed to run + self.assertEqual(1, len(settings_form.processes), 'One post save processes should be created') + + def test_save_triggers_processes_false(self): + """ + Test that the global theme event is not triggered when the tab is not visited. + """ + # GIVEN: A new Advanced Tab + settings_form = SettingsForm(None) + themes_tab = ThemesTab(settings_form) + Registry().register('renderer', MagicMock()) + themes_tab.tab_visited = False + # WHEN: I change search as type check box + themes_tab.save() + + # THEN: we should have two post save processed to run + self.assertEqual(0, len(settings_form.processes), 'No post save processes should be created') \ No newline at end of file From be8bdcf1f34afda94c182f5025894d9a86841360 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Tue, 29 Mar 2016 17:00:55 +0100 Subject: [PATCH 08/18] remove print --- openlp/core/ui/themestab.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openlp/core/ui/themestab.py b/openlp/core/ui/themestab.py index 07474ca74..a953ae013 100644 --- a/openlp/core/ui/themestab.py +++ b/openlp/core/ui/themestab.py @@ -160,7 +160,6 @@ class ThemesTab(SettingsTab): settings.endGroup() self.renderer.set_theme_level(self.theme_level) if self.tab_visited: - print("processed") self.settings_form.register_post_process('theme_update_global') self.tab_visited = False From 77fca59e5711c651e2ff540e8a2b2f864ed081ef Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Tue, 29 Mar 2016 17:07:40 +0100 Subject: [PATCH 09/18] add new line --- tests/functional/openlp_core_ui/test_themetab.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/functional/openlp_core_ui/test_themetab.py b/tests/functional/openlp_core_ui/test_themetab.py index 8896ae8f0..c3bb6282d 100644 --- a/tests/functional/openlp_core_ui/test_themetab.py +++ b/tests/functional/openlp_core_ui/test_themetab.py @@ -81,4 +81,4 @@ class TestThemeTab(TestCase, TestMixin): themes_tab.save() # THEN: we should have two post save processed to run - self.assertEqual(0, len(settings_form.processes), 'No post save processes should be created') \ No newline at end of file + self.assertEqual(0, len(settings_form.processes), 'No post save processes should be created') From d11cb1d6222efc232606068e016b9913f9839063 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Tue, 29 Mar 2016 17:55:33 +0100 Subject: [PATCH 10/18] Only set tab_visited when the tab is visited and not on loading --- openlp/core/lib/settingstab.py | 2 +- openlp/core/ui/settingsform.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/openlp/core/lib/settingstab.py b/openlp/core/lib/settingstab.py index fb7da0e14..a236dbdf9 100644 --- a/openlp/core/lib/settingstab.py +++ b/openlp/core/lib/settingstab.py @@ -135,4 +135,4 @@ class SettingsTab(QtWidgets.QWidget, RegistryProperties): """ Tab has just been made visible to the user """ - self.tab_visited = True + pass diff --git a/openlp/core/ui/settingsform.py b/openlp/core/ui/settingsform.py index f8c3cbbc2..82d72694c 100644 --- a/openlp/core/ui/settingsform.py +++ b/openlp/core/ui/settingsform.py @@ -60,7 +60,8 @@ class SettingsForm(QtWidgets.QDialog, Ui_SettingsDialog, RegistryProperties): """ Execute the form """ - # load all the settings + # load all the + self.setting_list_widget.blockSignals(True) self.setting_list_widget.clear() while self.stacked_layout.count(): # take at 0 and the rest shuffle up. @@ -74,6 +75,7 @@ class SettingsForm(QtWidgets.QDialog, Ui_SettingsDialog, RegistryProperties): if plugin.settings_tab: self.insert_tab(plugin.settings_tab, plugin.is_active()) self.setting_list_widget.setCurrentRow(0) + self.setting_list_widget.blockSignals(False) return QtWidgets.QDialog.exec(self) def insert_tab(self, tab_widget, is_visible=True): @@ -177,6 +179,7 @@ class SettingsForm(QtWidgets.QDialog, Ui_SettingsDialog, RegistryProperties): # Check that the title of the tab (i.e. plugin name) is the same as the data in the list item if tab_widget.tab_title == list_item.data(QtCore.Qt.UserRole): # Make the matching tab visible + tab_widget.tab_visited = True self.stacked_layout.setCurrentIndex(tab_index) self.stacked_layout.currentWidget().tab_visible() From 7c4671b67665634ed3b5b47356d7706ba3182d65 Mon Sep 17 00:00:00 2001 From: Ken Roberts Date: Sun, 15 May 2016 10:33:42 -0700 Subject: [PATCH 11/18] Convert strings to python3 in core.common.lib --- openlp/core/lib/db.py | 25 ++--- openlp/core/lib/filedialog.py | 3 +- openlp/core/lib/htmlbuilder.py | 94 +++++++++++-------- openlp/core/lib/imagemanager.py | 6 +- openlp/core/lib/mediamanageritem.py | 32 ++++--- openlp/core/lib/plugin.py | 10 +- openlp/core/lib/pluginmanager.py | 25 ++--- openlp/core/lib/renderer.py | 12 ++- openlp/core/lib/screen.py | 16 ++-- openlp/core/lib/searchedit.py | 5 +- openlp/core/lib/serviceitem.py | 21 +++-- openlp/core/lib/theme.py | 3 +- openlp/core/lib/ui.py | 6 +- openlp/core/lib/webpagereader.py | 20 ++-- .../openlp_core_lib/test_projector_pjlink1.py | 76 ++++++++++++++- 15 files changed, 230 insertions(+), 124 deletions(-) diff --git a/openlp/core/lib/db.py b/openlp/core/lib/db.py index 7ae3cdc6f..812758a4b 100644 --- a/openlp/core/lib/db.py +++ b/openlp/core/lib/db.py @@ -82,10 +82,10 @@ def handle_db_error(plugin_name, db_file_name): :return: None """ db_path = get_db_path(plugin_name, db_file_name) - log.exception('Error loading database: %s', db_path) + log.exception('Error loading database: {db}'.format(db=db_path)) critical_error_message_box(translate('OpenLP.Manager', 'Database Error'), - translate('OpenLP.Manager', 'OpenLP cannot load your database.\n\nDatabase: %s') - % db_path) + translate('OpenLP.Manager', + 'OpenLP cannot load your database.\n\nDatabase: {db}').format(db=db_path)) def init_url(plugin_name, db_file_name=None): @@ -157,10 +157,10 @@ def upgrade_db(url, upgrade): return version, upgrade.__version__ version += 1 try: - while hasattr(upgrade, 'upgrade_%d' % version): - log.debug('Running upgrade_%d', version) + while hasattr(upgrade, 'upgrade_{version:d}'.format(version=version)): + log.debug('Running upgrade_{version:d}'.format(version=version)) try: - upgrade_func = getattr(upgrade, 'upgrade_%d' % version) + upgrade_func = getattr(upgrade, 'upgrade_{version:d}'.format(version=version)) upgrade_func(session, metadata) session.commit() # Update the version number AFTER a commit so that we are sure the previous transaction happened @@ -168,8 +168,8 @@ def upgrade_db(url, upgrade): session.commit() version += 1 except (SQLAlchemyError, DBAPIError): - log.exception('Could not run database upgrade script "upgrade_%s", upgrade process has been halted.', - version) + log.exception('Could not run database upgrade script ' + '"upgrade_{version:d}", upgrade process has been halted.'.format(version=version)) break except (SQLAlchemyError, DBAPIError): version_meta = Metadata.populate(key='version', value=int(upgrade.__version__)) @@ -242,9 +242,10 @@ class Manager(object): critical_error_message_box( translate('OpenLP.Manager', 'Database Error'), translate('OpenLP.Manager', 'The database being loaded was created in a more recent version of ' - 'OpenLP. The database is version %d, while OpenLP expects version %d. The database will ' - 'not be loaded.\n\nDatabase: %s') % (db_ver, up_ver, self.db_url) - ) + 'OpenLP. The database is version {db_ver}, while OpenLP expects version {db_up}. ' + 'The database will not be loaded.\n\nDatabase: {db_name}').format(db_ver=db_ver, + db_up=up_ver, + db_name=self.db_url)) return if not session: try: @@ -460,7 +461,7 @@ class Manager(object): raise except InvalidRequestError: self.session.rollback() - log.exception('Failed to delete %s records', object_class.__name__) + log.exception('Failed to delete {name} records'.format(name=object_class.__name__)) return False except: self.session.rollback() diff --git a/openlp/core/lib/filedialog.py b/openlp/core/lib/filedialog.py index 823567a37..249f7959d 100644 --- a/openlp/core/lib/filedialog.py +++ b/openlp/core/lib/filedialog.py @@ -50,7 +50,8 @@ class FileDialog(QtWidgets.QFileDialog): log.info('File not found. Attempting to unquote.') file = parse.unquote(file) if not os.path.exists(file): - log.error('File %s not found.' % file) + log.error('File {text} not found.'.format(text=file)) + # TODO: Test with UiStrings() before converting to python3 strings QtWidgets.QMessageBox.information(parent, UiStrings().FileNotFound, UiStrings().FileNotFoundMessage % file) continue diff --git a/openlp/core/lib/htmlbuilder.py b/openlp/core/lib/htmlbuilder.py index 812680027..265aabe2c 100644 --- a/openlp/core/lib/htmlbuilder.py +++ b/openlp/core/lib/htmlbuilder.py @@ -396,6 +396,7 @@ from openlp.core.lib.theme import BackgroundType, BackgroundGradientType, Vertic log = logging.getLogger(__name__) +# TODO: Verify where this is used before converting to python3 HTMLSRC = """ @@ -564,13 +565,13 @@ def build_html(item, screen, is_live, background, image=None, plugins=None): theme_data = item.theme_data # Image generated and poked in if background: - bgimage_src = 'src="data:image/png;base64,%s"' % background + bgimage_src = 'src="data:image/png;base64,{image}"'.format(image=background) elif item.bg_image_bytes: - bgimage_src = 'src="data:image/png;base64,%s"' % item.bg_image_bytes + bgimage_src = 'src="data:image/png;base64,{image}"'.format(image=item.bg_image_bytes) else: bgimage_src = 'style="display:none;"' if image: - image_src = 'src="data:image/png;base64,%s"' % image + image_src = 'src="data:image/png;base64,{image}"'.format(image=image) else: image_src = 'style="display:none;"' css_additions = '' @@ -601,7 +602,7 @@ def webkit_version(): """ try: webkit_ver = float(QtWebKit.qWebKitVersion()) - log.debug('Webkit version = %s' % webkit_ver) + log.debug('Webkit version = {version}'.format(version=webkit_ver)) except AttributeError: webkit_ver = 0 return webkit_ver @@ -621,23 +622,25 @@ def build_background_css(item, width): if theme.background_type == BackgroundType.to_string(BackgroundType.Transparent): background = '' elif theme.background_type == BackgroundType.to_string(BackgroundType.Solid): - background = 'background-color: %s' % theme.background_color + background = 'background-color: {theme}'.format(theme=theme.background_color) else: if theme.background_direction == BackgroundGradientType.to_string(BackgroundGradientType.Horizontal): - background = 'background: -webkit-gradient(linear, left top, left bottom, from(%s), to(%s)) fixed' \ - % (theme.background_start_color, theme.background_end_color) + background = 'background: -webkit-gradient(linear, left top, left bottom, from({start}), to({end})) ' \ + 'fixed'.format(start=theme.background_start_color, end=theme.background_end_color) elif theme.background_direction == BackgroundGradientType.to_string(BackgroundGradientType.LeftTop): - background = 'background: -webkit-gradient(linear, left top, right bottom, from(%s), to(%s)) fixed' \ - % (theme.background_start_color, theme.background_end_color) + background = 'background: -webkit-gradient(linear, left top, right bottom, from({start}), to({end})) ' \ + 'fixed'.format(start=theme.background_start_color, end=theme.background_end_color) elif theme.background_direction == BackgroundGradientType.to_string(BackgroundGradientType.LeftBottom): - background = 'background: -webkit-gradient(linear, left bottom, right top, from(%s), to(%s)) fixed' \ - % (theme.background_start_color, theme.background_end_color) + background = 'background: -webkit-gradient(linear, left bottom, right top, from({start}), to({end})) ' \ + 'fixed'.format(start=theme.background_start_color, end=theme.background_end_color) elif theme.background_direction == BackgroundGradientType.to_string(BackgroundGradientType.Vertical): - background = 'background: -webkit-gradient(linear, left top, right top, from(%s), to(%s)) fixed' % \ - (theme.background_start_color, theme.background_end_color) + background = 'background: -webkit-gradient(linear, left top, right top, from({start}), to({end})) ' \ + 'fixed'.format(start=theme.background_start_color, end=theme.background_end_color) else: - background = 'background: -webkit-gradient(radial, %s 50%%, 100, %s 50%%, %s, from(%s), to(%s)) fixed'\ - % (width, width, width, theme.background_start_color, theme.background_end_color) + background = 'background: -webkit-gradient(radial, {width1} 50%%, 100, {width2} 50%%, {width3}, ' \ + 'from({start}), to({end})) fixed'.format(width1=width, width2=width, width3=width, + start=theme.background_start_color, + end=theme.background_end_color) return background @@ -652,16 +655,16 @@ def build_lyrics_css(item): z-index: 5; position: absolute; display: table; - %s + {stable} } .lyricscell { display: table-cell; word-wrap: break-word; -webkit-transition: opacity 0.4s ease; - %s + {lyrics} } .lyricsmain { - %s + {main} } """ theme_data = item.theme_data @@ -669,13 +672,15 @@ def build_lyrics_css(item): lyrics = '' lyricsmain = '' if theme_data and item.main: - lyricstable = 'left: %spx; top: %spx;' % (item.main.x(), item.main.y()) + lyricstable = 'left: {left}px; top: {top}px;'.format(left=item.main.x(), top=item.main.y()) lyrics = build_lyrics_format_css(theme_data, item.main.width(), item.main.height()) lyricsmain += build_lyrics_outline_css(theme_data) if theme_data.font_main_shadow: - lyricsmain += ' text-shadow: %s %spx %spx;' % \ - (theme_data.font_main_shadow_color, theme_data.font_main_shadow_size, theme_data.font_main_shadow_size) - lyrics_css = style % (lyricstable, lyrics, lyricsmain) + lyricsmain += ' text-shadow: {theme} {shadow1}px ' \ + '{shadow2}px;'.format(theme=theme_data.font_main_shadow_color, + shadow1=theme_data.font_main_shadow_size, + shadow2=theme_data.font_main_shadow_size) + lyrics_css = style.format(stable=lyricstable, lyrics=lyrics, main=lyricsmain) return lyrics_css @@ -689,7 +694,9 @@ def build_lyrics_outline_css(theme_data): size = float(theme_data.font_main_outline_size) / 16 fill_color = theme_data.font_main_color outline_color = theme_data.font_main_outline_color - return ' -webkit-text-stroke: %sem %s; -webkit-text-fill-color: %s; ' % (size, outline_color, fill_color) + return ' -webkit-text-stroke: {size}em {color}; -webkit-text-fill-color: {fill}; '.format(size=size, + color=outline_color, + fill=fill_color) return '' @@ -715,13 +722,21 @@ def build_lyrics_format_css(theme_data, width, height): padding_bottom = '0.5em' else: padding_bottom = '0' - lyrics = '%s word-wrap: break-word; ' \ - 'text-align: %s; vertical-align: %s; font-family: %s; ' \ - 'font-size: %spt; color: %s; line-height: %d%%; margin: 0;' \ - 'padding: 0; padding-bottom: %s; padding-left: %spx; width: %spx; height: %spx; ' % \ - (justify, align, valign, theme_data.font_main_name, theme_data.font_main_size, - theme_data.font_main_color, 100 + int(theme_data.font_main_line_adjustment), padding_bottom, - left_margin, width, height) + lyrics = '{justify} word-wrap: break-word; ' \ + 'text-align: {align}; vertical-align: {valign}; font-family: {font); ' \ + 'font-size: {size}pt; color: {color}; line-height: {line:d}%%; margin: 0;' \ + 'padding: 0; padding-bottom: {bottom}; padding-left: {left}px; width: {width}px; ' \ + 'height: {height}px; '.format(justify=justify, + align=align, + valign=valign, + font=theme_data.font_main_name, + size=theme_data.font_main_size, + color=theme_data.font_main_color, + line=100 + int(theme_data.font_main_line_adjustment), + bottom=padding_bottom, + left=left_margin, + width=width, + height=height) if theme_data.font_main_italics: lyrics += 'font-style:italic; ' if theme_data.font_main_bold: @@ -737,20 +752,21 @@ def build_footer_css(item, height): :param height: """ style = """ - left: %spx; - bottom: %spx; - width: %spx; - font-family: %s; - font-size: %spt; - color: %s; + left: {left}px; + bottom: {bottom}px; + width: {width}px; + font-family: {family}; + font-size: {size}pt; + color: {color}; text-align: left; - white-space: %s; + white-space: {space}; """ theme = item.theme_data if not theme or not item.footer: return '' bottom = height - int(item.footer.y()) - int(item.footer.height()) whitespace = 'normal' if Settings().value('themes/wrap footer') else 'nowrap' - lyrics_html = style % (item.footer.x(), bottom, item.footer.width(), - theme.font_footer_name, theme.font_footer_size, theme.font_footer_color, whitespace) + lyrics_html = style.format(left=item.footer.x(), bottom=bottom, width=item.footer.width(), + family=theme.font_footer_name, size=theme.font_footer_size, + color=theme.font_footer_color, space=whitespace) return lyrics_html diff --git a/openlp/core/lib/imagemanager.py b/openlp/core/lib/imagemanager.py index 0d0903a3b..1c25fca25 100644 --- a/openlp/core/lib/imagemanager.py +++ b/openlp/core/lib/imagemanager.py @@ -236,7 +236,7 @@ class ImageManager(QtCore.QObject): """ Return the ``QImage`` from the cache. If not present wait for the background thread to process it. """ - log.debug('getImage %s' % path) + log.debug('getImage {path}'.format(path=path)) image = self._cache[(path, source, width, height)] if image.image is None: self._conversion_queue.modify_priority(image, Priority.High) @@ -256,7 +256,7 @@ class ImageManager(QtCore.QObject): """ Returns the byte string for an image. If not present wait for the background thread to process it. """ - log.debug('get_image_bytes %s' % path) + log.debug('get_image_bytes {path}'.format(path=path)) image = self._cache[(path, source, width, height)] if image.image_bytes is None: self._conversion_queue.modify_priority(image, Priority.Urgent) @@ -271,7 +271,7 @@ class ImageManager(QtCore.QObject): """ Add image to cache if it is not already there. """ - log.debug('add_image %s' % path) + log.debug('add_image {path}'.format(path=path)) if not (path, source, width, height) in self._cache: image = Image(path, source, background, width, height) self._cache[(path, source, width, height)] = image diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 5af90c1b7..6e8327365 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -186,7 +186,7 @@ class MediaManagerItem(QtWidgets.QWidget, RegistryProperties): for action in toolbar_actions: if action[0] == StringContent.Preview: self.toolbar.addSeparator() - self.toolbar.add_toolbar_action('%s%sAction' % (self.plugin.name, action[0]), + self.toolbar.add_toolbar_action('{name}{action}Action'.format(name=self.plugin.name, action=action[0]), text=self.plugin.get_string(action[1])['title'], icon=action[2], tooltip=self.plugin.get_string(action[1])['tooltip'], triggers=action[3]) @@ -200,7 +200,7 @@ class MediaManagerItem(QtWidgets.QWidget, RegistryProperties): self.list_view.setSpacing(1) self.list_view.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection) self.list_view.setAlternatingRowColors(True) - self.list_view.setObjectName('%sListView' % self.plugin.name) + self.list_view.setObjectName('{name}ListView'.format(name=self.plugin.name)) # Add to page_layout self.page_layout.addWidget(self.list_view) # define and add the context menu @@ -212,19 +212,22 @@ class MediaManagerItem(QtWidgets.QWidget, RegistryProperties): triggers=self.on_edit_click) create_widget_action(self.list_view, separator=True) create_widget_action(self.list_view, - 'listView%s%sItem' % (self.plugin.name.title(), StringContent.Preview.title()), + 'listView{plugin}{preview}Item'.format(plugin=self.plugin.name.title(), + preview=StringContent.Preview.title()), text=self.plugin.get_string(StringContent.Preview)['title'], icon=':/general/general_preview.png', can_shortcuts=True, triggers=self.on_preview_click) create_widget_action(self.list_view, - 'listView%s%sItem' % (self.plugin.name.title(), StringContent.Live.title()), + 'listView{plugin}{live}Item'.format(plugin=self.plugin.name.title(), + live=StringContent.Live.title()), text=self.plugin.get_string(StringContent.Live)['title'], icon=':/general/general_live.png', can_shortcuts=True, triggers=self.on_live_click) create_widget_action(self.list_view, - 'listView%s%sItem' % (self.plugin.name.title(), StringContent.Service.title()), + 'listView{plugin}{service}Item'.format(plugin=self.plugin.name.title(), + service=StringContent.Service.title()), can_shortcuts=True, text=self.plugin.get_string(StringContent.Service)['title'], icon=':/general/general_add.png', @@ -232,7 +235,8 @@ class MediaManagerItem(QtWidgets.QWidget, RegistryProperties): if self.has_delete_icon: create_widget_action(self.list_view, separator=True) create_widget_action(self.list_view, - 'listView%s%sItem' % (self.plugin.name.title(), StringContent.Delete.title()), + 'listView{plugin}{delete}Item'.format(plugin=self.plugin.name.title(), + delete=StringContent.Delete.title()), text=self.plugin.get_string(StringContent.Delete)['title'], icon=':/general/general_delete.png', can_shortcuts=True, triggers=self.on_delete_click) @@ -313,7 +317,7 @@ class MediaManagerItem(QtWidgets.QWidget, RegistryProperties): files = FileDialog.getOpenFileNames(self, self.on_new_prompt, Settings().value(self.settings_section + '/last directory'), self.on_new_file_masks) - log.info('New files(s) %s' % files) + log.info('New files(s) {files}'.format(files=files)) if files: self.application.set_busy_cursor() self.validate_and_load(files) @@ -333,7 +337,8 @@ class MediaManagerItem(QtWidgets.QWidget, RegistryProperties): if not error_shown: critical_error_message_box(translate('OpenLP.MediaManagerItem', 'Invalid File Type'), translate('OpenLP.MediaManagerItem', - 'Invalid File %s.\nSuffix not supported') % file_name) + 'Invalid File {name}.\n' + 'Suffix not supported').format(name=file_name)) error_shown = True else: new_files.append(file_name) @@ -375,7 +380,9 @@ class MediaManagerItem(QtWidgets.QWidget, RegistryProperties): self.load_list(full_list, target_group) last_dir = os.path.split(files[0])[0] Settings().setValue(self.settings_section + '/last directory', last_dir) - Settings().setValue('%s/%s files' % (self.settings_section, self.settings_section), self.get_file_list()) + Settings().setValue('{section1}/{section2} files'.format(section1=self.settings_section, + section2=self.settings_section), + self.get_file_list()) if duplicates_found: critical_error_message_box(UiStrings().Duplicate, translate('OpenLP.MediaManagerItem', @@ -550,7 +557,7 @@ class MediaManagerItem(QtWidgets.QWidget, RegistryProperties): # Is it possible to process multiple list items to generate # multiple service items? if self.single_service_item: - log.debug('%s Add requested', self.plugin.name) + log.debug('{plugin} Add requested'.format(plugin=self.plugin.name)) self.add_to_service(replace=self.remote_triggered) else: items = self.list_view.selectedIndexes() @@ -591,7 +598,7 @@ class MediaManagerItem(QtWidgets.QWidget, RegistryProperties): translate('OpenLP.MediaManagerItem', 'You must select one or more items.')) else: - log.debug('%s Add requested', self.plugin.name) + log.debug('{plugin} Add requested'.format(plugin=self.plugin.name)) service_item = self.service_manager.get_service_item() if not service_item: QtWidgets.QMessageBox.information(self, UiStrings().NISs, @@ -604,7 +611,8 @@ class MediaManagerItem(QtWidgets.QWidget, RegistryProperties): # Turn off the remote edit update message indicator QtWidgets.QMessageBox.information(self, translate('OpenLP.MediaManagerItem', 'Invalid Service Item'), translate('OpenLP.MediaManagerItem', - 'You must select a %s service item.') % self.title) + 'You must select a {title} ' + 'service item.').format(title=self.title)) def build_service_item(self, item=None, xml_version=False, remote=False, context=ServiceItemContext.Live): """ diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index b9c8ca5f0..493cc2f45 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -130,7 +130,7 @@ class Plugin(QtCore.QObject, RegistryProperties): :param settings_tab_class: The class name of the plugin's settings tab. :param version: Defaults to *None*, which means that the same version number is used as OpenLP's version number. """ - log.debug('Plugin %s initialised' % name) + log.debug('Plugin {plugin} initialised'.format(plugin=name)) super(Plugin, self).__init__() self.name = name self.text_strings = {} @@ -154,11 +154,11 @@ class Plugin(QtCore.QObject, RegistryProperties): # Append a setting for files in the mediamanager (note not all plugins # which have a mediamanager need this). if media_item_class is not None: - default_settings['%s/%s files' % (name, name)] = [] + default_settings['{name1}/{name2} files'.format(name1=name, name2=name)] = [] # Add settings to the dict of all settings. Settings.extend_default_settings(default_settings) - Registry().register_function('%s_add_service_item' % self.name, self.process_add_service_event) - Registry().register_function('%s_config_updated' % self.name, self.config_update) + Registry().register_function('{name}_add_service_item'.format(name=self.name), self.process_add_service_event) + Registry().register_function('{name}_config_updated'.format(name=self.name), self.config_update) def check_pre_conditions(self): """ @@ -256,7 +256,7 @@ class Plugin(QtCore.QObject, RegistryProperties): """ Generic Drag and drop handler triggered from service_manager. """ - log.debug('process_add_service_event event called for plugin %s' % self.name) + log.debug('process_add_service_event event called for plugin {name}'.format(name=self.name)) if replace: self.media_item.on_add_edit_click() else: diff --git a/openlp/core/lib/pluginmanager.py b/openlp/core/lib/pluginmanager.py index 598c7c5d1..455d0deed 100644 --- a/openlp/core/lib/pluginmanager.py +++ b/openlp/core/lib/pluginmanager.py @@ -43,7 +43,7 @@ class PluginManager(RegistryMixin, OpenLPMixin, RegistryProperties): super(PluginManager, self).__init__(parent) self.log_info('Plugin manager Initialising') self.base_path = os.path.abspath(AppLocation.get_directory(AppLocation.PluginsDir)) - self.log_debug('Base path %s ' % self.base_path) + self.log_debug('Base path {path}'.forma(path=self.base_path)) self.plugins = [] self.log_info('Plugin manager Initialised') @@ -73,7 +73,7 @@ class PluginManager(RegistryMixin, OpenLPMixin, RegistryProperties): """ start_depth = len(os.path.abspath(self.base_path).split(os.sep)) present_plugin_dir = os.path.join(self.base_path, 'presentations') - self.log_debug('finding plugins in %s at depth %d' % (self.base_path, start_depth)) + self.log_debug('finding plugins in {path} at depth {depth:d}'.format(path=self.base_path, depth=start_depth)) for root, dirs, files in os.walk(self.base_path): for name in files: if name.endswith('.py') and not name.startswith('__'): @@ -84,7 +84,9 @@ class PluginManager(RegistryMixin, OpenLPMixin, RegistryProperties): break module_name = name[:-3] # import the modules - self.log_debug('Importing %s from %s. Depth %d' % (module_name, root, this_depth)) + self.log_debug('Importing {name} from {root}. Depth {depth:d}'.format(name=module_name, + root=root, + depth=this_depth)) try: # Use the "imp" library to try to get around a problem with the PyUNO library which # monkey-patches the __import__ function to do some magic. This causes issues with our tests. @@ -93,21 +95,21 @@ class PluginManager(RegistryMixin, OpenLPMixin, RegistryProperties): # Then load the module (do the actual import) using the details from find_module() imp.load_module(module_name, fp, path_name, description) except ImportError as e: - self.log_exception('Failed to import module %s on path %s: %s' - % (module_name, path, e.args[0])) + self.log_exception('Failed to import module {name} on path {path}: ' + '{args}'.format(name=module_name, path=path, args=e.args[0])) plugin_classes = Plugin.__subclasses__() plugin_objects = [] for p in plugin_classes: try: plugin = p() - self.log_debug('Loaded plugin %s' % str(p)) + self.log_debug('Loaded plugin {plugin}'.format(plugin=str(p))) plugin_objects.append(plugin) except TypeError: - self.log_exception('Failed to load plugin %s' % str(p)) + self.log_exception('Failed to load plugin {plugin}'.format(plugin=str(p))) plugins_list = sorted(plugin_objects, key=lambda plugin: plugin.weight) for plugin in plugins_list: if plugin.check_pre_conditions(): - self.log_debug('Plugin %s active' % str(plugin.name)) + self.log_debug('Plugin {plugin} active'.format(plugin=str(plugin.name))) plugin.set_status() else: plugin.status = PluginStatus.Disabled @@ -175,10 +177,11 @@ class PluginManager(RegistryMixin, OpenLPMixin, RegistryProperties): Loop through all the plugins and give them an opportunity to initialise themselves. """ for plugin in self.plugins: - self.log_info('initialising plugins %s in a %s state' % (plugin.name, plugin.is_active())) + self.log_info('initialising plugins {plugin} in a {state} state'.format(plugin=plugin.name, + state=plugin.is_active())) if plugin.is_active(): plugin.initialise() - self.log_info('Initialisation Complete for %s ' % plugin.name) + self.log_info('Initialisation Complete for {plugin}'.format(plugin=plugin.name)) def finalise_plugins(self): """ @@ -187,7 +190,7 @@ class PluginManager(RegistryMixin, OpenLPMixin, RegistryProperties): for plugin in self.plugins: if plugin.is_active(): plugin.finalise() - self.log_info('Finalisation Complete for %s ' % plugin.name) + self.log_info('Finalisation Complete for {plugin}'.format(plugin=plugin.name)) def get_plugin_by_name(self, name): """ diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index f76d28853..0d233a9c4 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -107,7 +107,7 @@ class Renderer(OpenLPMixin, RegistryMixin, RegistryProperties): :param theme_name: The theme name """ - self.log_debug("_set_theme with theme %s" % theme_name) + self.log_debug("_set_theme with theme {theme}".format(theme=theme_name)) if theme_name not in self._theme_dimensions: theme_data = self.theme_manager.get_theme_data(theme_name) main_rect = self.get_main_rectangle(theme_data) @@ -183,7 +183,7 @@ class Renderer(OpenLPMixin, RegistryMixin, RegistryProperties): :param item_theme_name: The item theme's name. """ - self.log_debug("set_item_theme with theme %s" % item_theme_name) + self.log_debug("set_item_theme with theme {theme}".format(theme=item_theme_name)) self._set_theme(item_theme_name) self.item_theme_name = item_theme_name @@ -317,7 +317,7 @@ class Renderer(OpenLPMixin, RegistryMixin, RegistryProperties): self.width = screen_size.width() self.height = screen_size.height() self.screen_ratio = self.height / self.width - self.log_debug('_calculate default %s, %f' % (screen_size, self.screen_ratio)) + self.log_debug('_calculate default {size}, {ratio:f}'.format(size=screen_size, ratio=self.screen_ratio)) # 90% is start of footer self.footer_start = int(self.height * 0.90) @@ -354,7 +354,7 @@ class Renderer(OpenLPMixin, RegistryMixin, RegistryProperties): :param rect_main: The main text block. :param rect_footer: The footer text block. """ - self.log_debug('_set_text_rectangle %s , %s' % (rect_main, rect_footer)) + self.log_debug('_set_text_rectangle {main} , {footer}'.format(main=rect_main, footer=rect_footer)) self._rect = rect_main self._rect_footer = rect_footer self.page_width = self._rect.width() @@ -370,6 +370,7 @@ class Renderer(OpenLPMixin, RegistryMixin, RegistryProperties): self.web.resize(self.page_width, self.page_height) self.web_frame = self.web.page().mainFrame() # Adjust width and height to account for shadow. outline done in css. + # TODO: Verify before converting to python3 strings html = """