Merge lp:~phill-ridout/openlp/fixes-II into lp:openlp

Proposed by Phill
Status: Superseded
Proposed branch: lp:~phill-ridout/openlp/fixes-II
Merge into: lp:openlp
Diff against target: 707 lines (+88/-85)
26 files modified
openlp/core/app.py (+8/-10)
openlp/core/common/__init__.py (+5/-5)
openlp/core/display/window.py (+1/-1)
openlp/core/lib/mediamanageritem.py (+5/-6)
openlp/core/lib/theme.py (+1/-1)
openlp/core/server.py (+2/-1)
openlp/core/ui/firsttimewizard.py (+1/-1)
openlp/core/ui/mainwindow.py (+11/-10)
openlp/core/ui/servicemanager.py (+21/-13)
openlp/core/ui/slidecontroller.py (+1/-1)
openlp/core/widgets/dialogs.py (+1/-1)
openlp/core/widgets/layouts.py (+1/-1)
openlp/core/widgets/views.py (+3/-3)
openlp/plugins/bibles/lib/importers/csvbible.py (+1/-1)
openlp/plugins/images/lib/mediaitem.py (+1/-2)
openlp/plugins/presentations/lib/mediaitem.py (+8/-10)
openlp/plugins/songs/lib/importers/presentationmanager.py (+1/-1)
openlp/plugins/songs/lib/importers/songbeamer.py (+1/-1)
openlp/plugins/songs/lib/importers/worshipassistant.py (+1/-1)
tests/functional/openlp_core/common/test_common.py (+2/-2)
tests/functional/openlp_core/common/test_init.py (+3/-3)
tests/functional/openlp_core/test_app.py (+2/-2)
tests/functional/openlp_core/test_server.py (+3/-2)
tests/functional/openlp_core/ui/test_mainwindow.py (+1/-2)
tests/functional/openlp_core/ui/test_thememanager.py (+2/-2)
tests/functional/openlp_plugins/bibles/test_csvimport.py (+1/-2)
To merge this branch: bzr merge lp:~phill-ridout/openlp/fixes-II
Reviewer Review Type Date Requested Status
OpenLP Core Pending
Review via email: mp+366950@code.launchpad.net

This proposal supersedes a proposal from 2019-05-04.

This proposal has been superseded by a proposal from 2019-05-04.

Commit message

Just to trigger the tests :-)

To post a comment you must log in.
Revision history for this message
Raoul Snyman (raoul-snyman) wrote : Posted in a previous version of this proposal

Linux tests failed, please see https://ci.openlp.io/job/MP-02-Linux_Tests/142/ for more details

Revision history for this message
Raoul Snyman (raoul-snyman) wrote : Posted in a previous version of this proposal

Linux tests passed!

Revision history for this message
Raoul Snyman (raoul-snyman) wrote : Posted in a previous version of this proposal

Linting failed, please see https://ci.openlp.io/job/MP-03-Linting/88/ for more details

Unmerged revisions

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 2019-05-01 19:22:01 +0000
+++ openlp/core/app.py 2019-05-04 18:26:49 +0000
@@ -287,12 +287,12 @@
287 return QtWidgets.QApplication.event(self, event)287 return QtWidgets.QApplication.event(self, event)
288288
289289
290def parse_options(args=None):290def parse_options():
291 """291 """
292 Parse the command line arguments292 Parse the command line arguments
293293
294 :param args: list of command line arguments294 :return: An :object:`argparse.Namespace` insatnce containing the parsed args.
295 :return: a tuple of parsed options of type optparse.Value and a list of remaining argsZ295 :rtype: argparse.Namespace
296 """296 """
297 # Set up command line options.297 # Set up command line options.
298 parser = argparse.ArgumentParser(prog='openlp')298 parser = argparse.ArgumentParser(prog='openlp')
@@ -307,9 +307,9 @@
307 dir_name=os.path.join('<AppDir>', '..', '..')))307 dir_name=os.path.join('<AppDir>', '..', '..')))
308 parser.add_argument('-w', '--no-web-server', dest='no_web_server', action='store_true',308 parser.add_argument('-w', '--no-web-server', dest='no_web_server', action='store_true',
309 help='Turn off the Web and Socket Server ')309 help='Turn off the Web and Socket Server ')
310 parser.add_argument('rargs', nargs='?', default=[])310 parser.add_argument('rargs', nargs='*', default=[])
311 # Parse command line options and deal with them. Use args supplied pragmatically if possible.311 # Parse command line options and deal with them.
312 return parser.parse_args(args) if args else parser.parse_args()312 return parser.parse_args()
313313
314314
315def set_up_logging(log_path):315def set_up_logging(log_path):
@@ -328,13 +328,11 @@
328 print('Logging to: {name}'.format(name=file_path))328 print('Logging to: {name}'.format(name=file_path))
329329
330330
331def main(args=None):331def main():
332 """332 """
333 The main function which parses command line options and then runs333 The main function which parses command line options and then runs
334
335 :param args: Some args
336 """334 """
337 args = parse_options(args)335 args = parse_options()
338 qt_args = ['--disable-web-security']336 qt_args = ['--disable-web-security']
339 # qt_args = []337 # qt_args = []
340 if args and args.loglevel.lower() in ['d', 'debug']:338 if args and args.loglevel.lower() in ['d', 'debug']:
341339
=== modified file 'openlp/core/common/__init__.py'
--- openlp/core/common/__init__.py 2019-04-13 13:00:22 +0000
+++ openlp/core/common/__init__.py 2019-05-04 18:26:49 +0000
@@ -134,8 +134,8 @@
134 importlib.import_module(module_name)134 importlib.import_module(module_name)
135 except (ImportError, OSError):135 except (ImportError, OSError):
136 # On some platforms importing vlc.py might cause OSError exceptions. (e.g. Mac OS X)136 # On some platforms importing vlc.py might cause OSError exceptions. (e.g. Mac OS X)
137 log.warning('Failed to import {module_name} on path {extension_path}'137 log.exception('Failed to import {module_name} on path {extension_path}'
138 .format(module_name=module_name, extension_path=extension_path))138 .format(module_name=module_name, extension_path=extension_path))
139139
140140
141def path_to_module(path):141def path_to_module(path):
@@ -463,8 +463,8 @@
463 Utility function to incrementally detect the file encoding.463 Utility function to incrementally detect the file encoding.
464464
465 :param openlp.core.common.path.Path file_path: Filename for the file to determine the encoding for.465 :param openlp.core.common.path.Path file_path: Filename for the file to determine the encoding for.
466 :return: A dict with the keys 'encoding' and 'confidence'466 :return: The name of the encoding detected
467 :rtype: dict[str, float]467 :rtype: str
468 """468 """
469 detector = UniversalDetector()469 detector = UniversalDetector()
470 try:470 try:
@@ -477,7 +477,7 @@
477 except OSError:477 except OSError:
478 log.exception('Error detecting file encoding')478 log.exception('Error detecting file encoding')
479 finally:479 finally:
480 return detector.close()480 return detector.close()['encoding']
481481
482482
483def normalize_str(irregular_string):483def normalize_str(irregular_string):
484484
=== modified file 'openlp/core/display/window.py'
--- openlp/core/display/window.py 2019-04-13 13:00:22 +0000
+++ openlp/core/display/window.py 2019-05-04 18:26:49 +0000
@@ -180,7 +180,7 @@
180 """180 """
181 Set the URL of the webview181 Set the URL of the webview
182182
183 :param str url: The URL to set183 :param QtCore.QUrl | str url: The URL to set
184 """184 """
185 if not isinstance(url, QtCore.QUrl):185 if not isinstance(url, QtCore.QUrl):
186 url = QtCore.QUrl(url)186 url = QtCore.QUrl(url)
187187
=== modified file 'openlp/core/lib/mediamanageritem.py'
--- openlp/core/lib/mediamanageritem.py 2019-04-28 19:21:23 +0000
+++ openlp/core/lib/mediamanageritem.py 2019-05-04 18:26:49 +0000
@@ -29,7 +29,6 @@
2929
30from openlp.core.common.i18n import UiStrings, translate30from openlp.core.common.i18n import UiStrings, translate
31from openlp.core.common.mixins import RegistryProperties31from openlp.core.common.mixins import RegistryProperties
32from openlp.core.common.path import path_to_str, str_to_path
33from openlp.core.common.registry import Registry32from openlp.core.common.registry import Registry
34from openlp.core.common.settings import Settings33from openlp.core.common.settings import Settings
35from openlp.core.lib import ServiceItemContext34from openlp.core.lib import ServiceItemContext
@@ -333,7 +332,7 @@
333 self.validate_and_load(file_paths)332 self.validate_and_load(file_paths)
334 self.application.set_normal_cursor()333 self.application.set_normal_cursor()
335334
336 def load_file(self, data):335 def handle_mime_data(self, data):
337 """336 """
338 Turn file from Drag and Drop into an array so the Validate code can run it.337 Turn file from Drag and Drop into an array so the Validate code can run it.
339338
@@ -379,11 +378,11 @@
379 duplicates_found = False378 duplicates_found = False
380 files_added = False379 files_added = False
381 for file_path in file_paths:380 for file_path in file_paths:
382 if path_to_str(file_path) in full_list:381 if file_path in full_list:
383 duplicates_found = True382 duplicates_found = True
384 else:383 else:
385 files_added = True384 files_added = True
386 full_list.append(path_to_str(file_path))385 full_list.append(file_path)
387 if full_list and files_added:386 if full_list and files_added:
388 if target_group is None:387 if target_group is None:
389 self.list_view.clear()388 self.list_view.clear()
@@ -416,8 +415,8 @@
416 file_paths = []415 file_paths = []
417 for index in range(self.list_view.count()):416 for index in range(self.list_view.count()):
418 list_item = self.list_view.item(index)417 list_item = self.list_view.item(index)
419 filename = list_item.data(QtCore.Qt.UserRole)418 file_path = list_item.data(QtCore.Qt.UserRole)
420 file_paths.append(str_to_path(filename))419 file_paths.append(file_path)
421 return file_paths420 return file_paths
422421
423 def load_list(self, load_list, target_group):422 def load_list(self, load_list, target_group):
424423
=== modified file 'openlp/core/lib/theme.py'
--- openlp/core/lib/theme.py 2019-04-13 13:00:22 +0000
+++ openlp/core/lib/theme.py 2019-05-04 18:26:49 +0000
@@ -333,7 +333,7 @@
333 else:333 else:
334 # make string value unicode334 # make string value unicode
335 if not isinstance(value, str):335 if not isinstance(value, str):
336 value = str(str(value), 'utf-8')336 value = str(value, 'utf-8')
337 # None means an empty string so lets have one.337 # None means an empty string so lets have one.
338 if value == 'None':338 if value == 'None':
339 value = ''339 value = ''
340340
=== modified file 'openlp/core/server.py'
--- openlp/core/server.py 2019-04-13 13:00:22 +0000
+++ openlp/core/server.py 2019-05-04 18:26:49 +0000
@@ -22,6 +22,7 @@
22from PyQt5 import QtCore, QtNetwork22from PyQt5 import QtCore, QtNetwork
2323
24from openlp.core.common.mixins import LogMixin24from openlp.core.common.mixins import LogMixin
25from openlp.core.common.path import Path
25from openlp.core.common.registry import Registry26from openlp.core.common.registry import Registry
2627
2728
@@ -97,7 +98,7 @@
97 msg = self.in_stream.readLine()98 msg = self.in_stream.readLine()
98 if msg:99 if msg:
99 self.log_debug("socket msg = " + msg)100 self.log_debug("socket msg = " + msg)
100 Registry().get('service_manager').on_load_service_clicked(msg)101 Registry().get('service_manager').load_service(Path(msg))
101102
102 def close_server(self):103 def close_server(self):
103 """104 """
104105
=== modified file 'openlp/core/ui/firsttimewizard.py'
--- openlp/core/ui/firsttimewizard.py 2019-04-13 13:00:22 +0000
+++ openlp/core/ui/firsttimewizard.py 2019-05-04 18:26:49 +0000
@@ -78,7 +78,7 @@
78 """78 """
79 nominal_width = 141 # Icon width of 133 + 4 each side79 nominal_width = 141 # Icon width of 133 + 4 each side
80 max_items_per_row = self.viewport().width() // nominal_width or 1 # or 1 to avoid divide by 0 errors80 max_items_per_row = self.viewport().width() // nominal_width or 1 # or 1 to avoid divide by 0 errors
81 col_size = (self.viewport().width() - 1) / max_items_per_row81 col_size = (self.viewport().width() - 1) // max_items_per_row
82 self.setGridSize(QtCore.QSize(col_size, 140))82 self.setGridSize(QtCore.QSize(col_size, 140))
8383
8484
8585
=== modified file 'openlp/core/ui/mainwindow.py'
--- openlp/core/ui/mainwindow.py 2019-04-13 13:00:22 +0000
+++ openlp/core/ui/mainwindow.py 2019-05-04 18:26:49 +0000
@@ -22,7 +22,7 @@
22"""22"""
23This is the main window, where all the action happens.23This is the main window, where all the action happens.
24"""24"""
25import sys25import os
26from datetime import datetime26from datetime import datetime
27from distutils import dir_util27from distutils import dir_util
28from distutils.errors import DistutilsFileError28from distutils.errors import DistutilsFileError
@@ -475,7 +475,6 @@
475 super(MainWindow, self).__init__()475 super(MainWindow, self).__init__()
476 Registry().register('main_window', self)476 Registry().register('main_window', self)
477 self.clipboard = self.application.clipboard()477 self.clipboard = self.application.clipboard()
478 self.arguments = ''.join(self.application.args)
479 # Set up settings sections for the main application (not for use by plugins).478 # Set up settings sections for the main application (not for use by plugins).
480 self.ui_settings_section = 'user interface'479 self.ui_settings_section = 'user interface'
481 self.general_settings_section = 'core'480 self.general_settings_section = 'core'
@@ -632,8 +631,8 @@
632 # if self.live_controller.display.isVisible():631 # if self.live_controller.display.isVisible():
633 # self.live_controller.display.setFocus()632 # self.live_controller.display.setFocus()
634 self.activateWindow()633 self.activateWindow()
635 if self.arguments:634 if self.application.args:
636 self.open_cmd_line_files(self.arguments)635 self.open_cmd_line_files(self.application.args)
637 elif Settings().value(self.general_settings_section + '/auto open'):636 elif Settings().value(self.general_settings_section + '/auto open'):
638 self.service_manager_contents.load_last_file()637 self.service_manager_contents.load_last_file()
639 # This will store currently used layout preset so it remains enabled on next startup.638 # This will store currently used layout preset so it remains enabled on next startup.
@@ -1339,7 +1338,7 @@
1339 self.application.set_normal_cursor()1338 self.application.set_normal_cursor()
1340 self.log_exception('Data copy failed {err}'.format(err=str(why)))1339 self.log_exception('Data copy failed {err}'.format(err=str(why)))
1341 err_text = translate('OpenLP.MainWindow',1340 err_text = translate('OpenLP.MainWindow',
1342 'OpenLP Data directory copy failed\n\n{err}').format(err=str(why)),1341 'OpenLP Data directory copy failed\n\n{err}').format(err=str(why))
1343 QtWidgets.QMessageBox.critical(self, translate('OpenLP.MainWindow', 'New Data Directory Error'),1342 QtWidgets.QMessageBox.critical(self, translate('OpenLP.MainWindow', 'New Data Directory Error'),
1344 err_text,1343 err_text,
1345 QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Ok))1344 QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Ok))
@@ -1354,11 +1353,13 @@
1354 settings.remove('advanced/data path')1353 settings.remove('advanced/data path')
1355 self.application.set_normal_cursor()1354 self.application.set_normal_cursor()
13561355
1357 def open_cmd_line_files(self, filename):1356 def open_cmd_line_files(self, args):
1358 """1357 """
1359 Open files passed in through command line arguments1358 Open files passed in through command line arguments
1359
1360 :param list[str] args: List of remaining positionall arguments
1360 """1361 """
1361 if not isinstance(filename, str):1362 for arg in args:
1362 filename = str(filename, sys.getfilesystemencoding())1363 file_name = os.path.expanduser(arg)
1363 if filename.endswith(('.osz', '.oszl')):1364 if os.path.isfile(file_name):
1364 self.service_manager_contents.load_file(Path(filename))1365 self.service_manager_contents.load_file(Path(file_name))
13651366
=== modified file 'openlp/core/ui/servicemanager.py'
--- openlp/core/ui/servicemanager.py 2019-04-13 13:00:22 +0000
+++ openlp/core/ui/servicemanager.py 2019-05-04 18:26:49 +0000
@@ -38,7 +38,7 @@
38from openlp.core.common.i18n import UiStrings, format_time, translate38from openlp.core.common.i18n import UiStrings, format_time, translate
39from openlp.core.common.json import OpenLPJsonDecoder, OpenLPJsonEncoder39from openlp.core.common.json import OpenLPJsonDecoder, OpenLPJsonEncoder
40from openlp.core.common.mixins import LogMixin, RegistryProperties40from openlp.core.common.mixins import LogMixin, RegistryProperties
41from openlp.core.common.path import Path, str_to_path41from openlp.core.common.path import Path
42from openlp.core.common.registry import Registry, RegistryBase42from openlp.core.common.registry import Registry, RegistryBase
43from openlp.core.common.settings import Settings43from openlp.core.common.settings import Settings
44from openlp.core.lib import build_icon44from openlp.core.lib import build_icon
@@ -430,11 +430,20 @@
430 return False430 return False
431 self.new_file()431 self.new_file()
432432
433 def on_load_service_clicked(self, load_file=None):433 def on_load_service_clicked(self, checked):
434 """
435 Handle the `fileOpenItem` action
436
437 :param bool checked: Not used.
438 :rtype: None
439 """
440 self.load_service()
441
442 def load_service(self, file_path=None):
434 """443 """
435 Loads the service file and saves the existing one it there is one unchanged.444 Loads the service file and saves the existing one it there is one unchanged.
436445
437 :param load_file: The service file to the loaded. Will be None is from menu so selection will be required.446 :param openlp.core.common.path.Path | None file_path: The service file to the loaded.
438 """447 """
439 if self.is_modified():448 if self.is_modified():
440 result = self.save_modified_service()449 result = self.save_modified_service()
@@ -442,7 +451,7 @@
442 return False451 return False
443 elif result == QtWidgets.QMessageBox.Save:452 elif result == QtWidgets.QMessageBox.Save:
444 self.decide_save_method()453 self.decide_save_method()
445 if not load_file:454 if not file_path:
446 file_path, filter_used = FileDialog.getOpenFileName(455 file_path, filter_used = FileDialog.getOpenFileName(
447 self.main_window,456 self.main_window,
448 translate('OpenLP.ServiceManager', 'Open File'),457 translate('OpenLP.ServiceManager', 'Open File'),
@@ -450,8 +459,6 @@
450 translate('OpenLP.ServiceManager', 'OpenLP Service Files (*.osz *.oszl)'))459 translate('OpenLP.ServiceManager', 'OpenLP Service Files (*.osz *.oszl)'))
451 if not file_path:460 if not file_path:
452 return False461 return False
453 else:
454 file_path = str_to_path(load_file)
455 Settings().setValue(self.main_window.service_manager_settings_section + '/last directory', file_path.parent)462 Settings().setValue(self.main_window.service_manager_settings_section + '/last directory', file_path.parent)
456 self.load_file(file_path)463 self.load_file(file_path)
457464
@@ -670,8 +677,9 @@
670677
671 def load_file(self, file_path):678 def load_file(self, file_path):
672 """679 """
673 Load an existing service file680 Load an existing service file.
674 :param file_path:681
682 :param openlp.core.common.path.Path file_path: The service file to load.
675 """683 """
676 if not file_path.exists():684 if not file_path.exists():
677 return False685 return False
@@ -1520,12 +1528,12 @@
1520 event.setDropAction(QtCore.Qt.CopyAction)1528 event.setDropAction(QtCore.Qt.CopyAction)
1521 event.accept()1529 event.accept()
1522 for url in link.urls():1530 for url in link.urls():
1523 file_name = url.toLocalFile()1531 file_path = Path(url.toLocalFile())
1524 if file_name.endswith('.osz'):1532 if file_path.suffix == '.osz':
1525 self.on_load_service_clicked(file_name)1533 self.load_service(file_path)
1526 elif file_name.endswith('.oszl'):1534 elif file_path.suffix == '.oszl':
1527 # todo correct1535 # todo correct
1528 self.on_load_service_clicked(file_name)1536 self.load_service(file_path)
1529 elif link.hasText():1537 elif link.hasText():
1530 plugin = link.text()1538 plugin = link.text()
1531 item = self.service_manager_list.itemAt(event.pos())1539 item = self.service_manager_list.itemAt(event.pos())
15321540
=== modified file 'openlp/core/ui/slidecontroller.py'
--- openlp/core/ui/slidecontroller.py 2019-04-13 13:00:22 +0000
+++ openlp/core/ui/slidecontroller.py 2019-05-04 18:26:49 +0000
@@ -112,7 +112,7 @@
112112
113class InfoLabel(QtWidgets.QLabel):113class InfoLabel(QtWidgets.QLabel):
114 """114 """
115 InfoLabel is a subclassed QLabel. Created to provide the ablilty to add a ellipsis if the text is cut off. Original115 InfoLabel is a subclassed QLabel. Created to provide the ability to add a ellipsis if the text is cut off. Original
116 source: https://stackoverflow.com/questions/11446478/pyside-pyqt-truncate-text-in-qlabel-based-on-minimumsize116 source: https://stackoverflow.com/questions/11446478/pyside-pyqt-truncate-text-in-qlabel-based-on-minimumsize
117 """117 """
118118
119119
=== modified file 'openlp/core/widgets/dialogs.py'
--- openlp/core/widgets/dialogs.py 2019-04-13 13:00:22 +0000
+++ openlp/core/widgets/dialogs.py 2019-05-04 18:26:49 +0000
@@ -35,7 +35,7 @@
35 :type caption: str35 :type caption: str
36 :type directory: openlp.core.common.path.Path36 :type directory: openlp.core.common.path.Path
37 :type options: QtWidgets.QFileDialog.Options37 :type options: QtWidgets.QFileDialog.Options
38 :rtype: tuple[openlp.core.common.path.Path, str]38 :rtype: openlp.core.common.path.Path
39 """39 """
40 args, kwargs = replace_params(args, kwargs, ((2, 'directory', path_to_str),))40 args, kwargs = replace_params(args, kwargs, ((2, 'directory', path_to_str),))
4141
4242
=== modified file 'openlp/core/widgets/layouts.py'
--- openlp/core/widgets/layouts.py 2019-04-13 13:00:22 +0000
+++ openlp/core/widgets/layouts.py 2019-05-04 18:26:49 +0000
@@ -37,7 +37,7 @@
37 """37 """
38 Create a layout.38 Create a layout.
3939
40 :param PyQt5.QtWidgets.QWidget parent: The parent widget, can be None.40 :param QtWidgets.QWidget | None parent: The parent widget
41 :param float aspect_ratio: The aspect ratio as a float (e.g. 16.0/9.0)41 :param float aspect_ratio: The aspect ratio as a float (e.g. 16.0/9.0)
42 """42 """
43 super().__init__(parent)43 super().__init__(parent)
4444
=== modified file 'openlp/core/widgets/views.py'
--- openlp/core/widgets/views.py 2019-04-13 13:00:22 +0000
+++ openlp/core/widgets/views.py 2019-05-04 18:26:49 +0000
@@ -39,7 +39,7 @@
39 """39 """
40 Process the data from a drag and drop operation.40 Process the data from a drag and drop operation.
4141
42 :param PyQt5.QtCore.QMimeData mime_data: The mime data from the drag and drop opperation.42 :param QtCore.QMimeData mime_data: The mime data from the drag and drop opperation.
43 :return: A list of file paths that were dropped43 :return: A list of file paths that were dropped
44 :rtype: list[openlp.core.common.path.Path]44 :rtype: list[openlp.core.common.path.Path]
45 """45 """
@@ -297,7 +297,7 @@
297 """297 """
298 self.setAcceptDrops(True)298 self.setAcceptDrops(True)
299 self.setDragDropMode(QtWidgets.QAbstractItemView.DragDrop)299 self.setDragDropMode(QtWidgets.QAbstractItemView.DragDrop)
300 Registry().register_function(('%s_dnd' % self.mime_data_text), self.parent().load_file)300 Registry().register_function(('%s_dnd' % self.mime_data_text), self.parent().handle_mime_data)
301301
302 def clear(self, search_while_typing=False):302 def clear(self, search_while_typing=False):
303 """303 """
@@ -412,7 +412,7 @@
412 """412 """
413 self.setAcceptDrops(True)413 self.setAcceptDrops(True)
414 self.setDragDropMode(QtWidgets.QAbstractItemView.DragDrop)414 self.setDragDropMode(QtWidgets.QAbstractItemView.DragDrop)
415 Registry().register_function(('%s_dnd' % self.mime_data_text), self.parent().load_file)415 Registry().register_function(('%s_dnd' % self.mime_data_text), self.parent().handle_mime_data)
416 Registry().register_function(('%s_dnd_internal' % self.mime_data_text), self.parent().dnd_move_internal)416 Registry().register_function(('%s_dnd_internal' % self.mime_data_text), self.parent().dnd_move_internal)
417417
418 def mouseMoveEvent(self, event):418 def mouseMoveEvent(self, event):
419419
=== modified file 'openlp/plugins/bibles/lib/importers/csvbible.py'
--- openlp/plugins/bibles/lib/importers/csvbible.py 2019-04-13 13:00:22 +0000
+++ openlp/plugins/bibles/lib/importers/csvbible.py 2019-05-04 18:26:49 +0000
@@ -102,7 +102,7 @@
102 :rtype: list[namedtuple]102 :rtype: list[namedtuple]
103 """103 """
104 try:104 try:
105 encoding = get_file_encoding(file_path)['encoding']105 encoding = get_file_encoding(file_path)
106 with file_path.open('r', encoding=encoding, newline='') as csv_file:106 with file_path.open('r', encoding=encoding, newline='') as csv_file:
107 csv_reader = csv.reader(csv_file, delimiter=',', quotechar='"')107 csv_reader = csv.reader(csv_file, delimiter=',', quotechar='"')
108 return [results_tuple(*line) for line in csv_reader]108 return [results_tuple(*line) for line in csv_reader]
109109
=== modified file 'openlp/plugins/images/lib/mediaitem.py'
--- openlp/plugins/images/lib/mediaitem.py 2019-04-13 13:00:22 +0000
+++ openlp/plugins/images/lib/mediaitem.py 2019-05-04 18:26:49 +0000
@@ -401,10 +401,9 @@
401 Process a list for files either from the File Dialog or from Drag and Drop.401 Process a list for files either from the File Dialog or from Drag and Drop.
402 This method is overloaded from MediaManagerItem.402 This method is overloaded from MediaManagerItem.
403403
404 :param files: A List of strings containing the filenames of the files to be loaded404 :param list[openlp.core.common.path.Path] file_paths: A List of paths to be loaded
405 :param target_group: The QTreeWidgetItem of the group that will be the parent of the added files405 :param target_group: The QTreeWidgetItem of the group that will be the parent of the added files
406 """406 """
407 file_paths = [Path(file) for file in file_paths]
408 self.application.set_normal_cursor()407 self.application.set_normal_cursor()
409 self.load_list(file_paths, target_group)408 self.load_list(file_paths, target_group)
410 last_dir = file_paths[0].parent409 last_dir = file_paths[0].parent
411410
=== modified file 'openlp/plugins/presentations/lib/mediaitem.py'
--- openlp/plugins/presentations/lib/mediaitem.py 2019-04-13 13:00:22 +0000
+++ openlp/plugins/presentations/lib/mediaitem.py 2019-05-04 18:26:49 +0000
@@ -24,7 +24,7 @@
24from PyQt5 import QtCore, QtWidgets24from PyQt5 import QtCore, QtWidgets
2525
26from openlp.core.common.i18n import UiStrings, get_natural_key, translate26from openlp.core.common.i18n import UiStrings, get_natural_key, translate
27from openlp.core.common.path import path_to_str, str_to_path27from openlp.core.common.path import path_to_str
28from openlp.core.common.registry import Registry28from openlp.core.common.registry import Registry
29from openlp.core.common.settings import Settings29from openlp.core.common.settings import Settings
30from openlp.core.lib import ServiceItemContext, build_icon, check_item_selected, create_thumb, validate_thumb30from openlp.core.lib import ServiceItemContext, build_icon, check_item_selected, create_thumb, validate_thumb
@@ -127,7 +127,7 @@
127 """127 """
128 self.list_view.setIconSize(QtCore.QSize(88, 50))128 self.list_view.setIconSize(QtCore.QSize(88, 50))
129 file_paths = Settings().value(self.settings_section + '/presentations files')129 file_paths = Settings().value(self.settings_section + '/presentations files')
130 self.load_list([path_to_str(path) for path in file_paths], initial_load=True)130 self.load_list(file_paths, initial_load=True)
131 self.populate_display_types()131 self.populate_display_types()
132132
133 def populate_display_types(self):133 def populate_display_types(self):
@@ -158,7 +158,6 @@
158158
159 :param list[openlp.core.common.path.Path] file_paths: List of file paths to add to the media manager.159 :param list[openlp.core.common.path.Path] file_paths: List of file paths to add to the media manager.
160 """160 """
161 file_paths = [str_to_path(filename) for filename in file_paths]
162 current_paths = self.get_file_list()161 current_paths = self.get_file_list()
163 titles = [file_path.name for file_path in current_paths]162 titles = [file_path.name for file_path in current_paths]
164 self.application.set_busy_cursor()163 self.application.set_busy_cursor()
@@ -175,7 +174,7 @@
175 if not file_path.exists():174 if not file_path.exists():
176 item_name = QtWidgets.QListWidgetItem(file_name)175 item_name = QtWidgets.QListWidgetItem(file_name)
177 item_name.setIcon(UiIcons().delete)176 item_name.setIcon(UiIcons().delete)
178 item_name.setData(QtCore.Qt.UserRole, path_to_str(file_path))177 item_name.setData(QtCore.Qt.UserRole, file_path)
179 item_name.setToolTip(str(file_path))178 item_name.setToolTip(str(file_path))
180 self.list_view.addItem(item_name)179 self.list_view.addItem(item_name)
181 else:180 else:
@@ -211,7 +210,7 @@
211 'This type of presentation is not supported.'))210 'This type of presentation is not supported.'))
212 continue211 continue
213 item_name = QtWidgets.QListWidgetItem(file_name)212 item_name = QtWidgets.QListWidgetItem(file_name)
214 item_name.setData(QtCore.Qt.UserRole, path_to_str(file_path))213 item_name.setData(QtCore.Qt.UserRole, file_path)
215 item_name.setIcon(icon)214 item_name.setIcon(icon)
216 item_name.setToolTip(str(file_path))215 item_name.setToolTip(str(file_path))
217 self.list_view.addItem(item_name)216 self.list_view.addItem(item_name)
@@ -230,8 +229,7 @@
230 self.application.set_busy_cursor()229 self.application.set_busy_cursor()
231 self.main_window.display_progress_bar(len(row_list))230 self.main_window.display_progress_bar(len(row_list))
232 for item in items:231 for item in items:
233 file_path = str_to_path(item.data(QtCore.Qt.UserRole))232 self.clean_up_thumbnails(item.data(QtCore.Qt.UserRole))
234 self.clean_up_thumbnails(file_path)
235 self.main_window.increment_progress_bar()233 self.main_window.increment_progress_bar()
236 self.main_window.finished_progress_bar()234 self.main_window.finished_progress_bar()
237 for row in row_list:235 for row in row_list:
@@ -278,7 +276,7 @@
278 if len(items) > 1:276 if len(items) > 1:
279 return False277 return False
280 if file_path is None:278 if file_path is None:
281 file_path = str_to_path(items[0].data(QtCore.Qt.UserRole))279 file_path = items[0].data(QtCore.Qt.UserRole)
282 file_type = file_path.suffix.lower()[1:]280 file_type = file_path.suffix.lower()[1:]
283 if not self.display_type_combo_box.currentText():281 if not self.display_type_combo_box.currentText():
284 return False282 return False
@@ -293,7 +291,7 @@
293 service_item.theme = -1291 service_item.theme = -1
294 for bitem in items:292 for bitem in items:
295 if file_path is None:293 if file_path is None:
296 file_path = str_to_path(bitem.data(QtCore.Qt.UserRole))294 file_path = bitem.data(QtCore.Qt.UserRole)
297 path, file_name = file_path.parent, file_path.name295 path, file_name = file_path.parent, file_path.name
298 service_item.title = file_name296 service_item.title = file_name
299 if file_path.exists():297 if file_path.exists():
@@ -329,7 +327,7 @@
329 service_item.processor = self.display_type_combo_box.currentText()327 service_item.processor = self.display_type_combo_box.currentText()
330 service_item.add_capability(ItemCapabilities.ProvidesOwnDisplay)328 service_item.add_capability(ItemCapabilities.ProvidesOwnDisplay)
331 for bitem in items:329 for bitem in items:
332 file_path = str_to_path(bitem.data(QtCore.Qt.UserRole))330 file_path = bitem.data(QtCore.Qt.UserRole)
333 path, file_name = file_path.parent, file_path.name331 path, file_name = file_path.parent, file_path.name
334 service_item.title = file_name332 service_item.title = file_name
335 if file_path.exists():333 if file_path.exists():
336334
=== modified file 'openlp/plugins/songs/lib/importers/presentationmanager.py'
--- openlp/plugins/songs/lib/importers/presentationmanager.py 2019-04-13 13:00:22 +0000
+++ openlp/plugins/songs/lib/importers/presentationmanager.py 2019-05-04 18:26:49 +0000
@@ -48,7 +48,7 @@
48 tree = etree.parse(str(file_path), parser=etree.XMLParser(recover=True))48 tree = etree.parse(str(file_path), parser=etree.XMLParser(recover=True))
49 except etree.XMLSyntaxError:49 except etree.XMLSyntaxError:
50 # Try to detect encoding and use it50 # Try to detect encoding and use it
51 encoding = get_file_encoding(file_path)['encoding']51 encoding = get_file_encoding(file_path)
52 # Open file with detected encoding and remove encoding declaration52 # Open file with detected encoding and remove encoding declaration
53 text = file_path.read_text(encoding=encoding)53 text = file_path.read_text(encoding=encoding)
54 text = re.sub(r'.+\?>\n', '', text)54 text = re.sub(r'.+\?>\n', '', text)
5555
=== modified file 'openlp/plugins/songs/lib/importers/songbeamer.py'
--- openlp/plugins/songs/lib/importers/songbeamer.py 2019-04-13 13:00:22 +0000
+++ openlp/plugins/songs/lib/importers/songbeamer.py 2019-05-04 18:26:49 +0000
@@ -124,7 +124,7 @@
124 self.chord_table = None124 self.chord_table = None
125 if file_path.is_file():125 if file_path.is_file():
126 # Detect the encoding126 # Detect the encoding
127 self.input_file_encoding = get_file_encoding(file_path)['encoding']127 self.input_file_encoding = get_file_encoding(file_path)
128 # The encoding should only be ANSI (cp1252), UTF-8, Unicode, Big-Endian-Unicode.128 # The encoding should only be ANSI (cp1252), UTF-8, Unicode, Big-Endian-Unicode.
129 # So if it doesn't start with 'u' we default to cp1252. See:129 # So if it doesn't start with 'u' we default to cp1252. See:
130 # https://forum.songbeamer.com/viewtopic.php?p=419&sid=ca4814924e37c11e4438b7272a98b6f2130 # https://forum.songbeamer.com/viewtopic.php?p=419&sid=ca4814924e37c11e4438b7272a98b6f2
131131
=== modified file 'openlp/plugins/songs/lib/importers/worshipassistant.py'
--- openlp/plugins/songs/lib/importers/worshipassistant.py 2019-04-13 13:00:22 +0000
+++ openlp/plugins/songs/lib/importers/worshipassistant.py 2019-05-04 18:26:49 +0000
@@ -82,7 +82,7 @@
82 Receive a CSV file to import.82 Receive a CSV file to import.
83 """83 """
84 # Get encoding84 # Get encoding
85 encoding = get_file_encoding(self.import_source)['encoding']85 encoding = get_file_encoding(self.import_source)
86 with self.import_source.open('r', encoding=encoding) as songs_file:86 with self.import_source.open('r', encoding=encoding) as songs_file:
87 songs_reader = csv.DictReader(songs_file, escapechar='\\')87 songs_reader = csv.DictReader(songs_file, escapechar='\\')
88 try:88 try:
8989
=== modified file 'tests/functional/openlp_core/common/test_common.py'
--- tests/functional/openlp_core/common/test_common.py 2019-04-13 13:00:22 +0000
+++ tests/functional/openlp_core/common/test_common.py 2019-05-04 18:26:49 +0000
@@ -88,7 +88,7 @@
88 extension_loader('glob')88 extension_loader('glob')
8989
90 # THEN: The `ImportError` should be caught and logged90 # THEN: The `ImportError` should be caught and logged
91 assert mocked_logger.warning.called91 assert mocked_logger.exception.called
9292
93 def test_extension_loader_os_error(self):93 def test_extension_loader_os_error(self):
94 """94 """
@@ -106,7 +106,7 @@
106 extension_loader('glob')106 extension_loader('glob')
107107
108 # THEN: The `OSError` should be caught and logged108 # THEN: The `OSError` should be caught and logged
109 assert mocked_logger.warning.called109 assert mocked_logger.exception.called
110110
111 def test_de_hump_conversion(self):111 def test_de_hump_conversion(self):
112 """112 """
113113
=== modified file 'tests/functional/openlp_core/common/test_init.py'
--- tests/functional/openlp_core/common/test_init.py 2019-04-13 13:00:22 +0000
+++ tests/functional/openlp_core/common/test_init.py 2019-05-04 18:26:49 +0000
@@ -322,7 +322,7 @@
322 mocked_open.assert_called_once_with('rb')322 mocked_open.assert_called_once_with('rb')
323 assert mocked_universal_detector_inst.feed.mock_calls == [call(b'data' * 256)]323 assert mocked_universal_detector_inst.feed.mock_calls == [call(b'data' * 256)]
324 mocked_universal_detector_inst.close.assert_called_once_with()324 mocked_universal_detector_inst.close.assert_called_once_with()
325 assert result == encoding_result325 assert result == 'UTF-8'
326326
327 def test_get_file_encoding_eof(self):327 def test_get_file_encoding_eof(self):
328 """328 """
@@ -344,7 +344,7 @@
344 mocked_open.assert_called_once_with('rb')344 mocked_open.assert_called_once_with('rb')
345 assert mocked_universal_detector_inst.feed.mock_calls == [call(b'data' * 256), call(b'data' * 4)]345 assert mocked_universal_detector_inst.feed.mock_calls == [call(b'data' * 256), call(b'data' * 4)]
346 mocked_universal_detector_inst.close.assert_called_once_with()346 mocked_universal_detector_inst.close.assert_called_once_with()
347 assert result == encoding_result347 assert result == 'UTF-8'
348348
349 def test_get_file_encoding_oserror(self):349 def test_get_file_encoding_oserror(self):
350 """350 """
@@ -367,4 +367,4 @@
367 mocked_log.exception.assert_called_once_with('Error detecting file encoding')367 mocked_log.exception.assert_called_once_with('Error detecting file encoding')
368 mocked_universal_detector_inst.feed.assert_not_called()368 mocked_universal_detector_inst.feed.assert_not_called()
369 mocked_universal_detector_inst.close.assert_called_once_with()369 mocked_universal_detector_inst.close.assert_called_once_with()
370 assert result == encoding_result370 assert result == 'UTF-8'
371371
=== modified file 'tests/functional/openlp_core/test_app.py'
--- tests/functional/openlp_core/test_app.py 2019-05-01 19:22:01 +0000
+++ tests/functional/openlp_core/test_app.py 2019-05-04 18:26:49 +0000
@@ -138,7 +138,7 @@
138 assert args.loglevel == 'warning', 'The log level should be set to warning'138 assert args.loglevel == 'warning', 'The log level should be set to warning'
139 assert args.no_error_form is False, 'The no_error_form should be set to False'139 assert args.no_error_form is False, 'The no_error_form should be set to False'
140 assert args.portable is False, 'The portable flag should be set to false'140 assert args.portable is False, 'The portable flag should be set to false'
141 assert args.rargs == 'dummy_temp', 'The service file should not be blank'141 assert args.rargs == ['dummy_temp'], 'The service file should not be blank'
142142
143143
144def test_parse_options_file_and_debug():144def test_parse_options_file_and_debug():
@@ -155,7 +155,7 @@
155 assert args.loglevel == ' debug', 'The log level should be set to debug'155 assert args.loglevel == ' debug', 'The log level should be set to debug'
156 assert args.no_error_form is False, 'The no_error_form should be set to False'156 assert args.no_error_form is False, 'The no_error_form should be set to False'
157 assert args.portable is False, 'The portable flag should be set to false'157 assert args.portable is False, 'The portable flag should be set to false'
158 assert args.rargs == 'dummy_temp', 'The service file should not be blank'158 assert args.rargs == ['dummy_temp'], 'The service file should not be blank'
159159
160160
161@skip('Figure out why this is causing a segfault')161@skip('Figure out why this is causing a segfault')
162162
=== modified file 'tests/functional/openlp_core/test_server.py'
--- tests/functional/openlp_core/test_server.py 2019-04-13 13:00:22 +0000
+++ tests/functional/openlp_core/test_server.py 2019-05-04 18:26:49 +0000
@@ -22,6 +22,7 @@
22from unittest import TestCase22from unittest import TestCase
23from unittest.mock import MagicMock, patch23from unittest.mock import MagicMock, patch
2424
25from openlp.core.common.path import Path
25from openlp.core.common.registry import Registry26from openlp.core.common.registry import Registry
26from openlp.core.server import Server27from openlp.core.server import Server
27from tests.helpers.testmixin import TestMixin28from tests.helpers.testmixin import TestMixin
@@ -83,8 +84,8 @@
83 self.server._on_ready_read()84 self.server._on_ready_read()
8485
85 # THEN: the service will be loaded86 # THEN: the service will be loaded
86 assert service_manager.on_load_service_clicked.call_count == 187 assert service_manager.load_service.call_count == 1
87 service_manager.on_load_service_clicked.assert_called_once_with(file_name)88 service_manager.load_service.assert_called_once_with(Path(file_name))
8889
89 @patch("PyQt5.QtCore.QTextStream")90 @patch("PyQt5.QtCore.QTextStream")
90 def test_post_to_server(self, mocked_stream):91 def test_post_to_server(self, mocked_stream):
9192
=== modified file 'tests/functional/openlp_core/ui/test_mainwindow.py'
--- tests/functional/openlp_core/ui/test_mainwindow.py 2019-04-13 13:00:22 +0000
+++ tests/functional/openlp_core/ui/test_mainwindow.py 2019-05-04 18:26:49 +0000
@@ -96,7 +96,7 @@
9696
97 # WHEN the argument is processed97 # WHEN the argument is processed
98 with patch.object(self.main_window.service_manager, 'load_file') as mocked_load_file:98 with patch.object(self.main_window.service_manager, 'load_file') as mocked_load_file:
99 self.main_window.open_cmd_line_files(service)99 self.main_window.open_cmd_line_files([service])
100100
101 # THEN the service from the arguments is loaded101 # THEN the service from the arguments is loaded
102 mocked_load_file.assert_called_with(Path(service))102 mocked_load_file.assert_called_with(Path(service))
@@ -108,7 +108,6 @@
108 """108 """
109 # GIVEN a non service file as an argument to openlp109 # GIVEN a non service file as an argument to openlp
110 service = 'run_openlp.py'110 service = 'run_openlp.py'
111 self.main_window.arguments = service
112111
113 # WHEN the argument is processed112 # WHEN the argument is processed
114 self.main_window.open_cmd_line_files(service)113 self.main_window.open_cmd_line_files(service)
115114
=== modified file 'tests/functional/openlp_core/ui/test_thememanager.py'
--- tests/functional/openlp_core/ui/test_thememanager.py 2019-04-13 13:00:22 +0000
+++ tests/functional/openlp_core/ui/test_thememanager.py 2019-05-04 18:26:49 +0000
@@ -143,7 +143,7 @@
143 mocked_theme.export_theme.return_value = "{}"143 mocked_theme.export_theme.return_value = "{}"
144144
145 # WHEN: Calling _write_theme with a theme with a name with special characters in it145 # WHEN: Calling _write_theme with a theme with a name with special characters in it
146 theme_manager._write_theme(mocked_theme, None, None)146 theme_manager._write_theme(mocked_theme)
147147
148 # THEN: It should have been created148 # THEN: It should have been created
149 assert os.path.exists(os.path.join(self.temp_folder, 'theme 愛 name', 'theme 愛 name.json')) is True, \149 assert os.path.exists(os.path.join(self.temp_folder, 'theme 愛 name', 'theme 愛 name.json')) is True, \
@@ -224,7 +224,7 @@
224 theme_manager = ThemeManager(None)224 theme_manager = ThemeManager(None)
225225
226 # WHEN: unzip_theme is called226 # WHEN: unzip_theme is called
227 theme_manager.unzip_theme('theme.file', 'folder')227 theme_manager.unzip_theme(Path('theme.file'), Path('folder'))
228228
229 # THEN: The critical_error_message_box should have been called229 # THEN: The critical_error_message_box should have been called
230 assert mocked_critical_error_message_box.call_count == 1, 'Should have been called once'230 assert mocked_critical_error_message_box.call_count == 1, 'Should have been called once'
231231
=== modified file 'tests/functional/openlp_plugins/bibles/test_csvimport.py'
--- tests/functional/openlp_plugins/bibles/test_csvimport.py 2019-04-13 13:00:22 +0000
+++ tests/functional/openlp_plugins/bibles/test_csvimport.py 2019-05-04 18:26:49 +0000
@@ -136,8 +136,7 @@
136 mocked_enter_file = MagicMock()136 mocked_enter_file = MagicMock()
137 mocked_csv_file.open.return_value.__enter__.return_value = mocked_enter_file137 mocked_csv_file.open.return_value.__enter__.return_value = mocked_enter_file
138138
139 with patch('openlp.plugins.bibles.lib.importers.csvbible.get_file_encoding',139 with patch('openlp.plugins.bibles.lib.importers.csvbible.get_file_encoding', return_value='utf-8'), \
140 return_value={'encoding': 'utf-8', 'confidence': 0.99}), \
141 patch('openlp.plugins.bibles.lib.importers.csvbible.csv.reader',140 patch('openlp.plugins.bibles.lib.importers.csvbible.csv.reader',
142 return_value=iter(test_data)) as mocked_reader:141 return_value=iter(test_data)) as mocked_reader:
143142