Merge lp:~thelinuxguy/openlp/flake-fixes into lp:openlp

Proposed by Simon Hanna
Status: Needs review
Proposed branch: lp:~thelinuxguy/openlp/flake-fixes
Merge into: lp:openlp
Diff against target: 275 lines (+18/-27)
17 files modified
openlp/core/app.py (+1/-1)
openlp/core/lib/serviceitem.py (+1/-1)
openlp/core/projectors/editform.py (+0/-3)
openlp/core/ui/advancedtab.py (+1/-1)
openlp/core/ui/exceptiondialog.py (+1/-1)
openlp/core/ui/slidecontroller.py (+1/-1)
openlp/core/version.py (+0/-3)
openlp/core/widgets/edits.py (+1/-1)
openlp/core/widgets/wizard.py (+0/-1)
openlp/plugins/alerts/endpoint.py (+0/-1)
openlp/plugins/bibles/bibleplugin.py (+1/-1)
openlp/plugins/bibles/forms/bibleimportform.py (+2/-2)
openlp/plugins/bibles/lib/importers/csvbible.py (+0/-1)
openlp/plugins/presentations/lib/mediaitem.py (+1/-1)
openlp/plugins/songs/lib/importers/easyslides.py (+1/-1)
tests/functional/openlp_plugins/bibles/test_csvimport.py (+3/-3)
tests/openlp_core/projectors/test_projector_pjlink_commands_01.py (+4/-4)
To merge this branch: bzr merge lp:~thelinuxguy/openlp/flake-fixes
Reviewer Review Type Date Requested Status
Phill Needs Information
Review via email: mp+353535@code.launchpad.net

Description of the change

A couple of code fixes that I uncovered using linters

To post a comment you must log in.
Revision history for this message
Phill (phill-ridout) wrote :

I'm not sure about those patches that were changed (see in line) isn't patching supposed to take place in the module they're imported in to?

review: Needs Information
Revision history for this message
Simon Hanna (thelinuxguy) wrote :

I'm not sure if that makes a difference here, but when viewing it in the tests using the original definition shows what is actually being used. If you import it from somewhere else you could think that it's something different...

Unmerged revisions

2839. By Simon Hanna

Remove useless statements

2838. By Simon Hanna

Remove unused variable

2837. By Simon Hanna

Remove unused variable

2836. By Simon Hanna

Method expects Path and not str

2835. By Simon Hanna

Use proper Error in except clause

2834. By Simon Hanna

Add missing asserts

2833. By Simon Hanna

Fixup more hacks

2832. By Simon Hanna

Fix ugly hack in test

2831. By Simon Hanna

Remove unused imports

2830. By Simon Hanna

Remove unused import

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'openlp/core/app.py'
--- openlp/core/app.py 2018-04-07 16:16:42 +0000
+++ openlp/core/app.py 2018-08-21 22:59:09 +0000
@@ -357,7 +357,7 @@
357 portable_settings_path = data_path / 'OpenLP.ini'357 portable_settings_path = data_path / 'OpenLP.ini'
358 # Make this our settings file358 # Make this our settings file
359 log.info('INI file: {name}'.format(name=portable_settings_path))359 log.info('INI file: {name}'.format(name=portable_settings_path))
360 Settings.set_filename(str(portable_settings_path))360 Settings.set_filename(portable_settings_path)
361 portable_settings = Settings()361 portable_settings = Settings()
362 # Set our data path362 # Set our data path
363 log.info('Data path: {name}'.format(name=data_path))363 log.info('Data path: {name}'.format(name=data_path))
364364
=== modified file 'openlp/core/lib/serviceitem.py'
--- openlp/core/lib/serviceitem.py 2018-04-22 06:59:35 +0000
+++ openlp/core/lib/serviceitem.py 2018-08-21 22:59:09 +0000
@@ -39,7 +39,7 @@
39from openlp.core.common.mixins import RegistryProperties39from openlp.core.common.mixins import RegistryProperties
40from openlp.core.common.path import Path40from openlp.core.common.path import Path
41from openlp.core.common.settings import Settings41from openlp.core.common.settings import Settings
42from openlp.core.lib import ImageSource, build_icon, clean_tags, expand_tags, expand_chords42from openlp.core.lib import ImageSource, clean_tags, expand_tags, expand_chords
4343
44log = logging.getLogger(__name__)44log = logging.getLogger(__name__)
4545
4646
=== modified file 'openlp/core/projectors/editform.py'
--- openlp/core/projectors/editform.py 2018-04-21 19:57:51 +0000
+++ openlp/core/projectors/editform.py 2018-08-21 22:59:09 +0000
@@ -185,7 +185,6 @@
185 translate('OpenLP.ProjectorEdit',185 translate('OpenLP.ProjectorEdit',
186 'You must enter a name for this entry.<br />'186 'You must enter a name for this entry.<br />'
187 'Please enter a new name for this entry.'))187 'Please enter a new name for this entry.'))
188 valid = False
189 return188 return
190 name = self.name_text.text().strip()189 name = self.name_text.text().strip()
191 record = self.projectordb.get_projector_by_name(name)190 record = self.projectordb.get_projector_by_name(name)
@@ -197,7 +196,6 @@
197 'the database as ID "{record}". <br />'196 'the database as ID "{record}". <br />'
198 'Please enter a different name.'.format(name=name,197 'Please enter a different name.'.format(name=name,
199 record=record.id)))198 record=record.id)))
200 valid = False
201 return199 return
202 if self.new_projector:200 if self.new_projector:
203 # Only validate a new entry - otherwise it's been previously verified201 # Only validate a new entry - otherwise it's been previously verified
@@ -223,7 +221,6 @@
223 translate('OpenLP.ProjectorWizard',221 translate('OpenLP.ProjectorWizard',
224 'IP address "{ip}"<br>is not a valid IP address.'222 'IP address "{ip}"<br>is not a valid IP address.'
225 '<br /><br />Please enter a valid IP address.'.format(ip=adx)))223 '<br /><br />Please enter a valid IP address.'.format(ip=adx)))
226 valid = False
227 return224 return
228 port = int(self.port_text.text())225 port = int(self.port_text.text())
229 if port < 1000 or port > 32767:226 if port < 1000 or port > 32767:
230227
=== modified file 'openlp/core/ui/advancedtab.py'
--- openlp/core/ui/advancedtab.py 2018-08-04 20:58:13 +0000
+++ openlp/core/ui/advancedtab.py 2018-08-21 22:59:09 +0000
@@ -31,7 +31,7 @@
31from openlp.core.common.applocation import AppLocation31from openlp.core.common.applocation import AppLocation
32from openlp.core.common.i18n import UiStrings, format_time, translate32from openlp.core.common.i18n import UiStrings, format_time, translate
33from openlp.core.common.settings import Settings33from openlp.core.common.settings import Settings
34from openlp.core.lib import SettingsTab, build_icon34from openlp.core.lib import SettingsTab
35from openlp.core.ui.style import HAS_DARK_STYLE35from openlp.core.ui.style import HAS_DARK_STYLE
36from openlp.core.ui.icons import UiIcons36from openlp.core.ui.icons import UiIcons
37from openlp.core.widgets.edits import PathEdit37from openlp.core.widgets.edits import PathEdit
3838
=== modified file 'openlp/core/ui/exceptiondialog.py'
--- openlp/core/ui/exceptiondialog.py 2018-06-10 19:29:00 +0000
+++ openlp/core/ui/exceptiondialog.py 2018-08-21 22:59:09 +0000
@@ -23,7 +23,7 @@
23The GUI widgets of the exception dialog.23The GUI widgets of the exception dialog.
24"""24"""
2525
26from PyQt5 import QtGui, QtWidgets26from PyQt5 import QtWidgets
2727
28from openlp.core.common.i18n import translate28from openlp.core.common.i18n import translate
29from openlp.core.ui.icons import UiIcons29from openlp.core.ui.icons import UiIcons
3030
=== modified file 'openlp/core/ui/slidecontroller.py'
--- openlp/core/ui/slidecontroller.py 2018-08-04 20:58:13 +0000
+++ openlp/core/ui/slidecontroller.py 2018-08-21 22:59:09 +0000
@@ -36,7 +36,7 @@
36from openlp.core.common.registry import Registry, RegistryBase36from openlp.core.common.registry import Registry, RegistryBase
37from openlp.core.common.settings import Settings37from openlp.core.common.settings import Settings
38from openlp.core.display.screens import ScreenList38from openlp.core.display.screens import ScreenList
39from openlp.core.lib import ItemCapabilities, ServiceItem, ImageSource, ServiceItemAction, build_icon, build_html39from openlp.core.lib import ItemCapabilities, ServiceItem, ImageSource, ServiceItemAction, build_html
40from openlp.core.lib.ui import create_action40from openlp.core.lib.ui import create_action
41from openlp.core.ui import HideMode, MainDisplay, Display, DisplayControllerType41from openlp.core.ui import HideMode, MainDisplay, Display, DisplayControllerType
42from openlp.core.ui.icons import UiIcons42from openlp.core.ui.icons import UiIcons
4343
=== modified file 'openlp/core/version.py'
--- openlp/core/version.py 2018-06-28 20:40:54 +0000
+++ openlp/core/version.py 2018-08-21 22:59:09 +0000
@@ -24,11 +24,8 @@
24"""24"""
25import logging25import logging
26import platform26import platform
27import sys
28import time
29from datetime import date27from datetime import date
30from distutils.version import LooseVersion28from distutils.version import LooseVersion
31from subprocess import Popen, PIPE
3229
33import requests30import requests
34from PyQt5 import QtCore31from PyQt5 import QtCore
3532
=== modified file 'openlp/core/widgets/edits.py'
--- openlp/core/widgets/edits.py 2018-04-21 05:59:03 +0000
+++ openlp/core/widgets/edits.py 2018-08-21 22:59:09 +0000
@@ -31,7 +31,7 @@
31from openlp.core.common.i18n import UiStrings, translate31from openlp.core.common.i18n import UiStrings, translate
32from openlp.core.common.path import Path, path_to_str, str_to_path32from openlp.core.common.path import Path, path_to_str, str_to_path
33from openlp.core.common.settings import Settings33from openlp.core.common.settings import Settings
34from openlp.core.lib import FormattingTags, build_icon34from openlp.core.lib import FormattingTags
35from openlp.core.lib.ui import create_widget_action, create_action35from openlp.core.lib.ui import create_widget_action, create_action
36from openlp.core.ui.icons import UiIcons36from openlp.core.ui.icons import UiIcons
37from openlp.core.widgets.dialogs import FileDialog37from openlp.core.widgets.dialogs import FileDialog
3838
=== modified file 'openlp/core/widgets/wizard.py'
--- openlp/core/widgets/wizard.py 2018-06-03 16:07:20 +0000
+++ openlp/core/widgets/wizard.py 2018-08-21 22:59:09 +0000
@@ -32,7 +32,6 @@
32from openlp.core.common.mixins import RegistryProperties32from openlp.core.common.mixins import RegistryProperties
33from openlp.core.common.registry import Registry33from openlp.core.common.registry import Registry
34from openlp.core.common.settings import Settings34from openlp.core.common.settings import Settings
35from openlp.core.lib import build_icon
36from openlp.core.lib.ui import add_welcome_page35from openlp.core.lib.ui import add_welcome_page
37from openlp.core.widgets.dialogs import FileDialog36from openlp.core.widgets.dialogs import FileDialog
3837
3938
=== modified file 'openlp/plugins/alerts/endpoint.py'
--- openlp/plugins/alerts/endpoint.py 2017-12-29 09:15:48 +0000
+++ openlp/plugins/alerts/endpoint.py 2018-08-21 22:59:09 +0000
@@ -22,7 +22,6 @@
22import json22import json
23import logging23import logging
24import urllib24import urllib
25from urllib.parse import urlparse
2625
27from openlp.core.api.http import requires_auth26from openlp.core.api.http import requires_auth
28from openlp.core.api.http.endpoint import Endpoint27from openlp.core.api.http.endpoint import Endpoint
2928
=== modified file 'openlp/plugins/bibles/bibleplugin.py'
--- openlp/plugins/bibles/bibleplugin.py 2018-04-10 19:26:56 +0000
+++ openlp/plugins/bibles/bibleplugin.py 2018-08-21 22:59:09 +0000
@@ -26,7 +26,7 @@
26from openlp.core.common.actions import ActionList26from openlp.core.common.actions import ActionList
27from openlp.core.common.i18n import UiStrings, translate27from openlp.core.common.i18n import UiStrings, translate
28from openlp.core.ui.icons import UiIcons28from openlp.core.ui.icons import UiIcons
29from openlp.core.lib import Plugin, StringContent, build_icon29from openlp.core.lib import Plugin, StringContent
30from openlp.core.lib.ui import create_action30from openlp.core.lib.ui import create_action
31from openlp.plugins.bibles.endpoint import api_bibles_endpoint, bibles_endpoint31from openlp.plugins.bibles.endpoint import api_bibles_endpoint, bibles_endpoint
32from openlp.plugins.bibles.lib import BibleManager, BiblesTab, BibleMediaItem, LayoutStyle, DisplayStyle, \32from openlp.plugins.bibles.lib import BibleManager, BiblesTab, BibleMediaItem, LayoutStyle, DisplayStyle, \
3333
=== modified file 'openlp/plugins/bibles/forms/bibleimportform.py'
--- openlp/plugins/bibles/forms/bibleimportform.py 2017-12-29 09:15:48 +0000
+++ openlp/plugins/bibles/forms/bibleimportform.py 2018-08-21 22:59:09 +0000
@@ -31,7 +31,7 @@
31try:31try:
32 from pysword import modules32 from pysword import modules
33 PYSWORD_AVAILABLE = True33 PYSWORD_AVAILABLE = True
34except:34except ImportError:
35 PYSWORD_AVAILABLE = False35 PYSWORD_AVAILABLE = False
3636
37from openlp.core.common import trace_error_handler37from openlp.core.common import trace_error_handler
@@ -616,7 +616,7 @@
616 (WebDownload.Bibleserver, BSExtract(proxy_server))):616 (WebDownload.Bibleserver, BSExtract(proxy_server))):
617 try:617 try:
618 bibles = extractor.get_bibles_from_http()618 bibles = extractor.get_bibles_from_http()
619 except (urllib.error.URLError, ConnectionError) as err:619 except (urllib.error.URLError, ConnectionError):
620 critical_error_message_box(translate('BiblesPlugin.ImportWizardForm', 'Error during download'),620 critical_error_message_box(translate('BiblesPlugin.ImportWizardForm', 'Error during download'),
621 translate('BiblesPlugin.ImportWizardForm',621 translate('BiblesPlugin.ImportWizardForm',
622 'An error occurred while downloading the list of bibles from %s.'))622 'An error occurred while downloading the list of bibles from %s.'))
623623
=== modified file 'openlp/plugins/bibles/lib/importers/csvbible.py'
--- openlp/plugins/bibles/lib/importers/csvbible.py 2017-12-29 09:15:48 +0000
+++ openlp/plugins/bibles/lib/importers/csvbible.py 2018-08-21 22:59:09 +0000
@@ -54,7 +54,6 @@
5454
55from openlp.core.common import get_file_encoding55from openlp.core.common import get_file_encoding
56from openlp.core.common.i18n import translate56from openlp.core.common.i18n import translate
57from openlp.core.common.path import Path
58from openlp.core.lib.exceptions import ValidationError57from openlp.core.lib.exceptions import ValidationError
59from openlp.plugins.bibles.lib.bibleimport import BibleImport58from openlp.plugins.bibles.lib.bibleimport import BibleImport
6059
6160
=== modified file 'openlp/plugins/presentations/lib/mediaitem.py'
--- openlp/plugins/presentations/lib/mediaitem.py 2018-04-22 07:17:38 +0000
+++ openlp/plugins/presentations/lib/mediaitem.py 2018-08-21 22:59:09 +0000
@@ -21,7 +21,7 @@
21###############################################################################21###############################################################################
22import logging22import logging
2323
24from PyQt5 import QtCore, QtGui, QtWidgets24from PyQt5 import QtCore, QtWidgets
2525
26from openlp.core.common.i18n import UiStrings, translate, get_natural_key26from openlp.core.common.i18n import UiStrings, translate, get_natural_key
27from openlp.core.common.path import path_to_str, str_to_path27from openlp.core.common.path import path_to_str, str_to_path
2828
=== modified file 'openlp/plugins/songs/lib/importers/easyslides.py'
--- openlp/plugins/songs/lib/importers/easyslides.py 2018-07-02 20:38:47 +0000
+++ openlp/plugins/songs/lib/importers/easyslides.py 2018-08-21 22:59:09 +0000
@@ -107,7 +107,7 @@
107 def _add_authors(self, writer):107 def _add_authors(self, writer):
108 try:108 try:
109 self.parse_author(str(writer))109 self.parse_author(str(writer))
110 except UnicodeDecodeError as e:110 except UnicodeDecodeError:
111 log.exception('Unicode decode error while decoding Writer')111 log.exception('Unicode decode error while decoding Writer')
112 self._success = False112 self._success = False
113113
114114
=== modified file 'tests/functional/openlp_plugins/bibles/test_csvimport.py'
--- tests/functional/openlp_plugins/bibles/test_csvimport.py 2017-12-29 09:15:48 +0000
+++ tests/functional/openlp_plugins/bibles/test_csvimport.py 2018-08-21 22:59:09 +0000
@@ -134,7 +134,7 @@
134134
135 with patch('openlp.plugins.bibles.lib.importers.csvbible.get_file_encoding',135 with patch('openlp.plugins.bibles.lib.importers.csvbible.get_file_encoding',
136 return_value={'encoding': 'utf-8', 'confidence': 0.99}),\136 return_value={'encoding': 'utf-8', 'confidence': 0.99}),\
137 patch('openlp.plugins.bibles.lib.importers.csvbible.Path.open', create=True) as mocked_open,\137 patch('openlp.core.common.path.Path.open', create=True) as mocked_open,\
138 patch('openlp.plugins.bibles.lib.importers.csvbible.csv.reader',138 patch('openlp.plugins.bibles.lib.importers.csvbible.csv.reader',
139 return_value=iter(test_data)) as mocked_reader:139 return_value=iter(test_data)) as mocked_reader:
140140
@@ -154,7 +154,7 @@
154 # GIVEN: Mocked a mocked open object which raises an OSError154 # GIVEN: Mocked a mocked open object which raises an OSError
155 with patch('openlp.plugins.bibles.lib.importers.csvbible.get_file_encoding',155 with patch('openlp.plugins.bibles.lib.importers.csvbible.get_file_encoding',
156 return_value={'encoding': 'utf-8', 'confidence': 0.99}),\156 return_value={'encoding': 'utf-8', 'confidence': 0.99}),\
157 patch('openlp.plugins.bibles.lib.importers.csvbible.Path.open', side_effect=OSError, create=True):157 patch('openlp.core.common.path.Path.open', side_effect=OSError, create=True):
158158
159 # WHEN: Calling CSVBible.parse_csv_file159 # WHEN: Calling CSVBible.parse_csv_file
160 # THEN: A ValidationError should be raised160 # THEN: A ValidationError should be raised
@@ -169,7 +169,7 @@
169 # GIVEN: Mocked a csv.reader which raises an csv.Error169 # GIVEN: Mocked a csv.reader which raises an csv.Error
170 with patch('openlp.plugins.bibles.lib.importers.csvbible.get_file_encoding',170 with patch('openlp.plugins.bibles.lib.importers.csvbible.get_file_encoding',
171 return_value={'encoding': 'utf-8', 'confidence': 0.99}),\171 return_value={'encoding': 'utf-8', 'confidence': 0.99}),\
172 patch('openlp.plugins.bibles.lib.importers.csvbible.Path.open', create=True),\172 patch('openlp.core.common.path.Path.open', create=True),\
173 patch('openlp.plugins.bibles.lib.importers.csvbible.csv.reader', side_effect=csv.Error):173 patch('openlp.plugins.bibles.lib.importers.csvbible.csv.reader', side_effect=csv.Error):
174174
175 # WHEN: Calling CSVBible.parse_csv_file175 # WHEN: Calling CSVBible.parse_csv_file
176176
=== modified file 'tests/openlp_core/projectors/test_projector_pjlink_commands_01.py'
--- tests/openlp_core/projectors/test_projector_pjlink_commands_01.py 2018-01-13 05:41:42 +0000
+++ tests/openlp_core/projectors/test_projector_pjlink_commands_01.py 2018-08-21 22:59:09 +0000
@@ -612,8 +612,8 @@
612 # THEN: Power should be set to ON612 # THEN: Power should be set to ON
613 assert pjlink.power == S_STANDBY, 'Power should not have changed'613 assert pjlink.power == S_STANDBY, 'Power should not have changed'
614 assert mock_UpdateIcons.emit.called is False, 'projectorUpdateIcons() should not have been called'614 assert mock_UpdateIcons.emit.called is False, 'projectorUpdateIcons() should not have been called'
615 mock_change_status.called is False, 'change_status() should not have been called'615 assert mock_change_status.called is False, 'change_status() should not have been called'
616 mock_send_command.called is False, 'send_command() should not have been called'616 assert mock_send_command.called is False, 'send_command() should not have been called'
617 mock_log.warning.assert_has_calls(log_warn_calls)617 mock_log.warning.assert_has_calls(log_warn_calls)
618618
619 def test_projector_process_powr_off(self):619 def test_projector_process_powr_off(self):
@@ -634,8 +634,8 @@
634 # THEN: Power should be set to ON634 # THEN: Power should be set to ON
635 assert pjlink.power == S_STANDBY, 'Power should have changed to S_STANDBY'635 assert pjlink.power == S_STANDBY, 'Power should have changed to S_STANDBY'
636 assert mock_UpdateIcons.emit.called is True, 'projectorUpdateIcons should have been called'636 assert mock_UpdateIcons.emit.called is True, 'projectorUpdateIcons should have been called'
637 mock_change_status.called is True, 'change_status should have been called'637 assert mock_change_status.called is True, 'change_status should have been called'
638 mock_send_command.called is False, 'send_command should not have been called'638 assert mock_send_command.called is False, 'send_command should not have been called'
639639
640 def test_projector_process_rfil_save(self):640 def test_projector_process_rfil_save(self):
641 """641 """