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 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
OpenLP Core | Pending | ||
Review via email: mp+366949@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 :-)
Description of the change
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 | # |
Revision history for this message
Raoul Snyman (raoul-snyman) wrote : | # |
Linux tests passed!
Revision history for this message
Raoul Snyman (raoul-snyman) wrote : | # |
Linting failed, please see https:/
lp:~phill-ridout/openlp/fixes-II
updated
Unmerged revisions
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'openlp/core/app.py' |
2 | --- openlp/core/app.py 2019-05-01 19:22:01 +0000 |
3 | +++ openlp/core/app.py 2019-05-04 18:26:39 +0000 |
4 | @@ -287,12 +287,12 @@ |
5 | return QtWidgets.QApplication.event(self, event) |
6 | |
7 | |
8 | -def parse_options(args=None): |
9 | +def parse_options(): |
10 | """ |
11 | Parse the command line arguments |
12 | |
13 | - :param args: list of command line arguments |
14 | - :return: a tuple of parsed options of type optparse.Value and a list of remaining argsZ |
15 | + :return: An :object:`argparse.Namespace` insatnce containing the parsed args. |
16 | + :rtype: argparse.Namespace |
17 | """ |
18 | # Set up command line options. |
19 | parser = argparse.ArgumentParser(prog='openlp') |
20 | @@ -307,9 +307,9 @@ |
21 | dir_name=os.path.join('<AppDir>', '..', '..'))) |
22 | parser.add_argument('-w', '--no-web-server', dest='no_web_server', action='store_true', |
23 | help='Turn off the Web and Socket Server ') |
24 | - parser.add_argument('rargs', nargs='?', default=[]) |
25 | - # Parse command line options and deal with them. Use args supplied pragmatically if possible. |
26 | - return parser.parse_args(args) if args else parser.parse_args() |
27 | + parser.add_argument('rargs', nargs='*', default=[]) |
28 | + # Parse command line options and deal with them. |
29 | + return parser.parse_args() |
30 | |
31 | |
32 | def set_up_logging(log_path): |
33 | @@ -328,13 +328,11 @@ |
34 | print('Logging to: {name}'.format(name=file_path)) |
35 | |
36 | |
37 | -def main(args=None): |
38 | +def main(): |
39 | """ |
40 | The main function which parses command line options and then runs |
41 | - |
42 | - :param args: Some args |
43 | """ |
44 | - args = parse_options(args) |
45 | + args = parse_options() |
46 | qt_args = ['--disable-web-security'] |
47 | # qt_args = [] |
48 | if args and args.loglevel.lower() in ['d', 'debug']: |
49 | |
50 | === modified file 'openlp/core/common/__init__.py' |
51 | --- openlp/core/common/__init__.py 2019-04-13 13:00:22 +0000 |
52 | +++ openlp/core/common/__init__.py 2019-05-04 18:26:39 +0000 |
53 | @@ -134,8 +134,8 @@ |
54 | importlib.import_module(module_name) |
55 | except (ImportError, OSError): |
56 | # On some platforms importing vlc.py might cause OSError exceptions. (e.g. Mac OS X) |
57 | - log.warning('Failed to import {module_name} on path {extension_path}' |
58 | - .format(module_name=module_name, extension_path=extension_path)) |
59 | + log.exception('Failed to import {module_name} on path {extension_path}' |
60 | + .format(module_name=module_name, extension_path=extension_path)) |
61 | |
62 | |
63 | def path_to_module(path): |
64 | @@ -463,8 +463,8 @@ |
65 | Utility function to incrementally detect the file encoding. |
66 | |
67 | :param openlp.core.common.path.Path file_path: Filename for the file to determine the encoding for. |
68 | - :return: A dict with the keys 'encoding' and 'confidence' |
69 | - :rtype: dict[str, float] |
70 | + :return: The name of the encoding detected |
71 | + :rtype: str |
72 | """ |
73 | detector = UniversalDetector() |
74 | try: |
75 | @@ -477,7 +477,7 @@ |
76 | except OSError: |
77 | log.exception('Error detecting file encoding') |
78 | finally: |
79 | - return detector.close() |
80 | + return detector.close()['encoding'] |
81 | |
82 | |
83 | def normalize_str(irregular_string): |
84 | |
85 | === modified file 'openlp/core/display/window.py' |
86 | --- openlp/core/display/window.py 2019-04-13 13:00:22 +0000 |
87 | +++ openlp/core/display/window.py 2019-05-04 18:26:39 +0000 |
88 | @@ -180,7 +180,7 @@ |
89 | """ |
90 | Set the URL of the webview |
91 | |
92 | - :param str url: The URL to set |
93 | + :param QtCore.QUrl | str url: The URL to set |
94 | """ |
95 | if not isinstance(url, QtCore.QUrl): |
96 | url = QtCore.QUrl(url) |
97 | |
98 | === modified file 'openlp/core/lib/mediamanageritem.py' |
99 | --- openlp/core/lib/mediamanageritem.py 2019-04-28 19:21:23 +0000 |
100 | +++ openlp/core/lib/mediamanageritem.py 2019-05-04 18:26:39 +0000 |
101 | @@ -29,7 +29,6 @@ |
102 | |
103 | from openlp.core.common.i18n import UiStrings, translate |
104 | from openlp.core.common.mixins import RegistryProperties |
105 | -from openlp.core.common.path import path_to_str, str_to_path |
106 | from openlp.core.common.registry import Registry |
107 | from openlp.core.common.settings import Settings |
108 | from openlp.core.lib import ServiceItemContext |
109 | @@ -333,7 +332,7 @@ |
110 | self.validate_and_load(file_paths) |
111 | self.application.set_normal_cursor() |
112 | |
113 | - def load_file(self, data): |
114 | + def handle_mime_data(self, data): |
115 | """ |
116 | Turn file from Drag and Drop into an array so the Validate code can run it. |
117 | |
118 | @@ -379,11 +378,11 @@ |
119 | duplicates_found = False |
120 | files_added = False |
121 | for file_path in file_paths: |
122 | - if path_to_str(file_path) in full_list: |
123 | + if file_path in full_list: |
124 | duplicates_found = True |
125 | else: |
126 | files_added = True |
127 | - full_list.append(path_to_str(file_path)) |
128 | + full_list.append(file_path) |
129 | if full_list and files_added: |
130 | if target_group is None: |
131 | self.list_view.clear() |
132 | @@ -416,8 +415,8 @@ |
133 | file_paths = [] |
134 | for index in range(self.list_view.count()): |
135 | list_item = self.list_view.item(index) |
136 | - filename = list_item.data(QtCore.Qt.UserRole) |
137 | - file_paths.append(str_to_path(filename)) |
138 | + file_path = list_item.data(QtCore.Qt.UserRole) |
139 | + file_paths.append(file_path) |
140 | return file_paths |
141 | |
142 | def load_list(self, load_list, target_group): |
143 | |
144 | === modified file 'openlp/core/lib/theme.py' |
145 | --- openlp/core/lib/theme.py 2019-04-13 13:00:22 +0000 |
146 | +++ openlp/core/lib/theme.py 2019-05-04 18:26:39 +0000 |
147 | @@ -333,7 +333,7 @@ |
148 | else: |
149 | # make string value unicode |
150 | if not isinstance(value, str): |
151 | - value = str(str(value), 'utf-8') |
152 | + value = str(value, 'utf-8') |
153 | # None means an empty string so lets have one. |
154 | if value == 'None': |
155 | value = '' |
156 | |
157 | === modified file 'openlp/core/server.py' |
158 | --- openlp/core/server.py 2019-04-13 13:00:22 +0000 |
159 | +++ openlp/core/server.py 2019-05-04 18:26:39 +0000 |
160 | @@ -22,6 +22,7 @@ |
161 | from PyQt5 import QtCore, QtNetwork |
162 | |
163 | from openlp.core.common.mixins import LogMixin |
164 | +from openlp.core.common.path import Path |
165 | from openlp.core.common.registry import Registry |
166 | |
167 | |
168 | @@ -97,7 +98,7 @@ |
169 | msg = self.in_stream.readLine() |
170 | if msg: |
171 | self.log_debug("socket msg = " + msg) |
172 | - Registry().get('service_manager').on_load_service_clicked(msg) |
173 | + Registry().get('service_manager').load_service(Path(msg)) |
174 | |
175 | def close_server(self): |
176 | """ |
177 | |
178 | === modified file 'openlp/core/ui/firsttimewizard.py' |
179 | --- openlp/core/ui/firsttimewizard.py 2019-04-13 13:00:22 +0000 |
180 | +++ openlp/core/ui/firsttimewizard.py 2019-05-04 18:26:39 +0000 |
181 | @@ -78,7 +78,7 @@ |
182 | """ |
183 | nominal_width = 141 # Icon width of 133 + 4 each side |
184 | max_items_per_row = self.viewport().width() // nominal_width or 1 # or 1 to avoid divide by 0 errors |
185 | - col_size = (self.viewport().width() - 1) / max_items_per_row |
186 | + col_size = (self.viewport().width() - 1) // max_items_per_row |
187 | self.setGridSize(QtCore.QSize(col_size, 140)) |
188 | |
189 | |
190 | |
191 | === modified file 'openlp/core/ui/mainwindow.py' |
192 | --- openlp/core/ui/mainwindow.py 2019-04-13 13:00:22 +0000 |
193 | +++ openlp/core/ui/mainwindow.py 2019-05-04 18:26:39 +0000 |
194 | @@ -22,7 +22,7 @@ |
195 | """ |
196 | This is the main window, where all the action happens. |
197 | """ |
198 | -import sys |
199 | +import os |
200 | from datetime import datetime |
201 | from distutils import dir_util |
202 | from distutils.errors import DistutilsFileError |
203 | @@ -475,7 +475,6 @@ |
204 | super(MainWindow, self).__init__() |
205 | Registry().register('main_window', self) |
206 | self.clipboard = self.application.clipboard() |
207 | - self.arguments = ''.join(self.application.args) |
208 | # Set up settings sections for the main application (not for use by plugins). |
209 | self.ui_settings_section = 'user interface' |
210 | self.general_settings_section = 'core' |
211 | @@ -632,8 +631,8 @@ |
212 | # if self.live_controller.display.isVisible(): |
213 | # self.live_controller.display.setFocus() |
214 | self.activateWindow() |
215 | - if self.arguments: |
216 | - self.open_cmd_line_files(self.arguments) |
217 | + if self.application.args: |
218 | + self.open_cmd_line_files(self.application.args) |
219 | elif Settings().value(self.general_settings_section + '/auto open'): |
220 | self.service_manager_contents.load_last_file() |
221 | # This will store currently used layout preset so it remains enabled on next startup. |
222 | @@ -1339,7 +1338,7 @@ |
223 | self.application.set_normal_cursor() |
224 | self.log_exception('Data copy failed {err}'.format(err=str(why))) |
225 | err_text = translate('OpenLP.MainWindow', |
226 | - 'OpenLP Data directory copy failed\n\n{err}').format(err=str(why)), |
227 | + 'OpenLP Data directory copy failed\n\n{err}').format(err=str(why)) |
228 | QtWidgets.QMessageBox.critical(self, translate('OpenLP.MainWindow', 'New Data Directory Error'), |
229 | err_text, |
230 | QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Ok)) |
231 | @@ -1354,11 +1353,13 @@ |
232 | settings.remove('advanced/data path') |
233 | self.application.set_normal_cursor() |
234 | |
235 | - def open_cmd_line_files(self, filename): |
236 | + def open_cmd_line_files(self, args): |
237 | """ |
238 | Open files passed in through command line arguments |
239 | + |
240 | + :param list[str] args: List of remaining positionall arguments |
241 | """ |
242 | - if not isinstance(filename, str): |
243 | - filename = str(filename, sys.getfilesystemencoding()) |
244 | - if filename.endswith(('.osz', '.oszl')): |
245 | - self.service_manager_contents.load_file(Path(filename)) |
246 | + for arg in args: |
247 | + file_name = os.path.expanduser(arg) |
248 | + if os.path.isfile(file_name): |
249 | + self.service_manager_contents.load_file(Path(file_name)) |
250 | |
251 | === modified file 'openlp/core/ui/servicemanager.py' |
252 | --- openlp/core/ui/servicemanager.py 2019-04-13 13:00:22 +0000 |
253 | +++ openlp/core/ui/servicemanager.py 2019-05-04 18:26:39 +0000 |
254 | @@ -38,7 +38,7 @@ |
255 | from openlp.core.common.i18n import UiStrings, format_time, translate |
256 | from openlp.core.common.json import OpenLPJsonDecoder, OpenLPJsonEncoder |
257 | from openlp.core.common.mixins import LogMixin, RegistryProperties |
258 | -from openlp.core.common.path import Path, str_to_path |
259 | +from openlp.core.common.path import Path |
260 | from openlp.core.common.registry import Registry, RegistryBase |
261 | from openlp.core.common.settings import Settings |
262 | from openlp.core.lib import build_icon |
263 | @@ -430,11 +430,20 @@ |
264 | return False |
265 | self.new_file() |
266 | |
267 | - def on_load_service_clicked(self, load_file=None): |
268 | + def on_load_service_clicked(self, checked): |
269 | + """ |
270 | + Handle the `fileOpenItem` action |
271 | + |
272 | + :param bool checked: Not used. |
273 | + :rtype: None |
274 | + """ |
275 | + self.load_service() |
276 | + |
277 | + def load_service(self, file_path=None): |
278 | """ |
279 | Loads the service file and saves the existing one it there is one unchanged. |
280 | |
281 | - :param load_file: The service file to the loaded. Will be None is from menu so selection will be required. |
282 | + :param openlp.core.common.path.Path | None file_path: The service file to the loaded. |
283 | """ |
284 | if self.is_modified(): |
285 | result = self.save_modified_service() |
286 | @@ -442,7 +451,7 @@ |
287 | return False |
288 | elif result == QtWidgets.QMessageBox.Save: |
289 | self.decide_save_method() |
290 | - if not load_file: |
291 | + if not file_path: |
292 | file_path, filter_used = FileDialog.getOpenFileName( |
293 | self.main_window, |
294 | translate('OpenLP.ServiceManager', 'Open File'), |
295 | @@ -450,8 +459,6 @@ |
296 | translate('OpenLP.ServiceManager', 'OpenLP Service Files (*.osz *.oszl)')) |
297 | if not file_path: |
298 | return False |
299 | - else: |
300 | - file_path = str_to_path(load_file) |
301 | Settings().setValue(self.main_window.service_manager_settings_section + '/last directory', file_path.parent) |
302 | self.load_file(file_path) |
303 | |
304 | @@ -670,8 +677,9 @@ |
305 | |
306 | def load_file(self, file_path): |
307 | """ |
308 | - Load an existing service file |
309 | - :param file_path: |
310 | + Load an existing service file. |
311 | + |
312 | + :param openlp.core.common.path.Path file_path: The service file to load. |
313 | """ |
314 | if not file_path.exists(): |
315 | return False |
316 | @@ -1520,12 +1528,12 @@ |
317 | event.setDropAction(QtCore.Qt.CopyAction) |
318 | event.accept() |
319 | for url in link.urls(): |
320 | - file_name = url.toLocalFile() |
321 | - if file_name.endswith('.osz'): |
322 | - self.on_load_service_clicked(file_name) |
323 | - elif file_name.endswith('.oszl'): |
324 | + file_path = Path(url.toLocalFile()) |
325 | + if file_path.suffix == '.osz': |
326 | + self.load_service(file_path) |
327 | + elif file_path.suffix == '.oszl': |
328 | # todo correct |
329 | - self.on_load_service_clicked(file_name) |
330 | + self.load_service(file_path) |
331 | elif link.hasText(): |
332 | plugin = link.text() |
333 | item = self.service_manager_list.itemAt(event.pos()) |
334 | |
335 | === modified file 'openlp/core/ui/slidecontroller.py' |
336 | --- openlp/core/ui/slidecontroller.py 2019-04-13 13:00:22 +0000 |
337 | +++ openlp/core/ui/slidecontroller.py 2019-05-04 18:26:39 +0000 |
338 | @@ -112,7 +112,7 @@ |
339 | |
340 | class InfoLabel(QtWidgets.QLabel): |
341 | """ |
342 | - InfoLabel is a subclassed QLabel. Created to provide the ablilty to add a ellipsis if the text is cut off. Original |
343 | + InfoLabel is a subclassed QLabel. Created to provide the ability to add a ellipsis if the text is cut off. Original |
344 | source: https://stackoverflow.com/questions/11446478/pyside-pyqt-truncate-text-in-qlabel-based-on-minimumsize |
345 | """ |
346 | |
347 | |
348 | === modified file 'openlp/core/widgets/dialogs.py' |
349 | --- openlp/core/widgets/dialogs.py 2019-04-13 13:00:22 +0000 |
350 | +++ openlp/core/widgets/dialogs.py 2019-05-04 18:26:39 +0000 |
351 | @@ -35,7 +35,7 @@ |
352 | :type caption: str |
353 | :type directory: openlp.core.common.path.Path |
354 | :type options: QtWidgets.QFileDialog.Options |
355 | - :rtype: tuple[openlp.core.common.path.Path, str] |
356 | + :rtype: openlp.core.common.path.Path |
357 | """ |
358 | args, kwargs = replace_params(args, kwargs, ((2, 'directory', path_to_str),)) |
359 | |
360 | |
361 | === modified file 'openlp/core/widgets/layouts.py' |
362 | --- openlp/core/widgets/layouts.py 2019-04-13 13:00:22 +0000 |
363 | +++ openlp/core/widgets/layouts.py 2019-05-04 18:26:39 +0000 |
364 | @@ -37,7 +37,7 @@ |
365 | """ |
366 | Create a layout. |
367 | |
368 | - :param PyQt5.QtWidgets.QWidget parent: The parent widget, can be None. |
369 | + :param QtWidgets.QWidget | None parent: The parent widget |
370 | :param float aspect_ratio: The aspect ratio as a float (e.g. 16.0/9.0) |
371 | """ |
372 | super().__init__(parent) |
373 | |
374 | === modified file 'openlp/core/widgets/views.py' |
375 | --- openlp/core/widgets/views.py 2019-04-13 13:00:22 +0000 |
376 | +++ openlp/core/widgets/views.py 2019-05-04 18:26:39 +0000 |
377 | @@ -39,7 +39,7 @@ |
378 | """ |
379 | Process the data from a drag and drop operation. |
380 | |
381 | - :param PyQt5.QtCore.QMimeData mime_data: The mime data from the drag and drop opperation. |
382 | + :param QtCore.QMimeData mime_data: The mime data from the drag and drop opperation. |
383 | :return: A list of file paths that were dropped |
384 | :rtype: list[openlp.core.common.path.Path] |
385 | """ |
386 | @@ -297,7 +297,7 @@ |
387 | """ |
388 | self.setAcceptDrops(True) |
389 | self.setDragDropMode(QtWidgets.QAbstractItemView.DragDrop) |
390 | - Registry().register_function(('%s_dnd' % self.mime_data_text), self.parent().load_file) |
391 | + Registry().register_function(('%s_dnd' % self.mime_data_text), self.parent().handle_mime_data) |
392 | |
393 | def clear(self, search_while_typing=False): |
394 | """ |
395 | @@ -412,7 +412,7 @@ |
396 | """ |
397 | self.setAcceptDrops(True) |
398 | self.setDragDropMode(QtWidgets.QAbstractItemView.DragDrop) |
399 | - Registry().register_function(('%s_dnd' % self.mime_data_text), self.parent().load_file) |
400 | + Registry().register_function(('%s_dnd' % self.mime_data_text), self.parent().handle_mime_data) |
401 | Registry().register_function(('%s_dnd_internal' % self.mime_data_text), self.parent().dnd_move_internal) |
402 | |
403 | def mouseMoveEvent(self, event): |
404 | |
405 | === modified file 'openlp/plugins/bibles/lib/importers/csvbible.py' |
406 | --- openlp/plugins/bibles/lib/importers/csvbible.py 2019-04-13 13:00:22 +0000 |
407 | +++ openlp/plugins/bibles/lib/importers/csvbible.py 2019-05-04 18:26:39 +0000 |
408 | @@ -102,7 +102,7 @@ |
409 | :rtype: list[namedtuple] |
410 | """ |
411 | try: |
412 | - encoding = get_file_encoding(file_path)['encoding'] |
413 | + encoding = get_file_encoding(file_path) |
414 | with file_path.open('r', encoding=encoding, newline='') as csv_file: |
415 | csv_reader = csv.reader(csv_file, delimiter=',', quotechar='"') |
416 | return [results_tuple(*line) for line in csv_reader] |
417 | |
418 | === modified file 'openlp/plugins/images/lib/mediaitem.py' |
419 | --- openlp/plugins/images/lib/mediaitem.py 2019-04-13 13:00:22 +0000 |
420 | +++ openlp/plugins/images/lib/mediaitem.py 2019-05-04 18:26:39 +0000 |
421 | @@ -401,10 +401,9 @@ |
422 | Process a list for files either from the File Dialog or from Drag and Drop. |
423 | This method is overloaded from MediaManagerItem. |
424 | |
425 | - :param files: A List of strings containing the filenames of the files to be loaded |
426 | + :param list[openlp.core.common.path.Path] file_paths: A List of paths to be loaded |
427 | :param target_group: The QTreeWidgetItem of the group that will be the parent of the added files |
428 | """ |
429 | - file_paths = [Path(file) for file in file_paths] |
430 | self.application.set_normal_cursor() |
431 | self.load_list(file_paths, target_group) |
432 | last_dir = file_paths[0].parent |
433 | |
434 | === modified file 'openlp/plugins/presentations/lib/mediaitem.py' |
435 | --- openlp/plugins/presentations/lib/mediaitem.py 2019-04-13 13:00:22 +0000 |
436 | +++ openlp/plugins/presentations/lib/mediaitem.py 2019-05-04 18:26:39 +0000 |
437 | @@ -24,7 +24,7 @@ |
438 | from PyQt5 import QtCore, QtWidgets |
439 | |
440 | from openlp.core.common.i18n import UiStrings, get_natural_key, translate |
441 | -from openlp.core.common.path import path_to_str, str_to_path |
442 | +from openlp.core.common.path import path_to_str |
443 | from openlp.core.common.registry import Registry |
444 | from openlp.core.common.settings import Settings |
445 | from openlp.core.lib import ServiceItemContext, build_icon, check_item_selected, create_thumb, validate_thumb |
446 | @@ -127,7 +127,7 @@ |
447 | """ |
448 | self.list_view.setIconSize(QtCore.QSize(88, 50)) |
449 | file_paths = Settings().value(self.settings_section + '/presentations files') |
450 | - self.load_list([path_to_str(path) for path in file_paths], initial_load=True) |
451 | + self.load_list(file_paths, initial_load=True) |
452 | self.populate_display_types() |
453 | |
454 | def populate_display_types(self): |
455 | @@ -158,7 +158,6 @@ |
456 | |
457 | :param list[openlp.core.common.path.Path] file_paths: List of file paths to add to the media manager. |
458 | """ |
459 | - file_paths = [str_to_path(filename) for filename in file_paths] |
460 | current_paths = self.get_file_list() |
461 | titles = [file_path.name for file_path in current_paths] |
462 | self.application.set_busy_cursor() |
463 | @@ -175,7 +174,7 @@ |
464 | if not file_path.exists(): |
465 | item_name = QtWidgets.QListWidgetItem(file_name) |
466 | item_name.setIcon(UiIcons().delete) |
467 | - item_name.setData(QtCore.Qt.UserRole, path_to_str(file_path)) |
468 | + item_name.setData(QtCore.Qt.UserRole, file_path) |
469 | item_name.setToolTip(str(file_path)) |
470 | self.list_view.addItem(item_name) |
471 | else: |
472 | @@ -211,7 +210,7 @@ |
473 | 'This type of presentation is not supported.')) |
474 | continue |
475 | item_name = QtWidgets.QListWidgetItem(file_name) |
476 | - item_name.setData(QtCore.Qt.UserRole, path_to_str(file_path)) |
477 | + item_name.setData(QtCore.Qt.UserRole, file_path) |
478 | item_name.setIcon(icon) |
479 | item_name.setToolTip(str(file_path)) |
480 | self.list_view.addItem(item_name) |
481 | @@ -230,8 +229,7 @@ |
482 | self.application.set_busy_cursor() |
483 | self.main_window.display_progress_bar(len(row_list)) |
484 | for item in items: |
485 | - file_path = str_to_path(item.data(QtCore.Qt.UserRole)) |
486 | - self.clean_up_thumbnails(file_path) |
487 | + self.clean_up_thumbnails(item.data(QtCore.Qt.UserRole)) |
488 | self.main_window.increment_progress_bar() |
489 | self.main_window.finished_progress_bar() |
490 | for row in row_list: |
491 | @@ -278,7 +276,7 @@ |
492 | if len(items) > 1: |
493 | return False |
494 | if file_path is None: |
495 | - file_path = str_to_path(items[0].data(QtCore.Qt.UserRole)) |
496 | + file_path = items[0].data(QtCore.Qt.UserRole) |
497 | file_type = file_path.suffix.lower()[1:] |
498 | if not self.display_type_combo_box.currentText(): |
499 | return False |
500 | @@ -293,7 +291,7 @@ |
501 | service_item.theme = -1 |
502 | for bitem in items: |
503 | if file_path is None: |
504 | - file_path = str_to_path(bitem.data(QtCore.Qt.UserRole)) |
505 | + file_path = bitem.data(QtCore.Qt.UserRole) |
506 | path, file_name = file_path.parent, file_path.name |
507 | service_item.title = file_name |
508 | if file_path.exists(): |
509 | @@ -329,7 +327,7 @@ |
510 | service_item.processor = self.display_type_combo_box.currentText() |
511 | service_item.add_capability(ItemCapabilities.ProvidesOwnDisplay) |
512 | for bitem in items: |
513 | - file_path = str_to_path(bitem.data(QtCore.Qt.UserRole)) |
514 | + file_path = bitem.data(QtCore.Qt.UserRole) |
515 | path, file_name = file_path.parent, file_path.name |
516 | service_item.title = file_name |
517 | if file_path.exists(): |
518 | |
519 | === modified file 'openlp/plugins/songs/lib/importers/presentationmanager.py' |
520 | --- openlp/plugins/songs/lib/importers/presentationmanager.py 2019-04-13 13:00:22 +0000 |
521 | +++ openlp/plugins/songs/lib/importers/presentationmanager.py 2019-05-04 18:26:39 +0000 |
522 | @@ -48,7 +48,7 @@ |
523 | tree = etree.parse(str(file_path), parser=etree.XMLParser(recover=True)) |
524 | except etree.XMLSyntaxError: |
525 | # Try to detect encoding and use it |
526 | - encoding = get_file_encoding(file_path)['encoding'] |
527 | + encoding = get_file_encoding(file_path) |
528 | # Open file with detected encoding and remove encoding declaration |
529 | text = file_path.read_text(encoding=encoding) |
530 | text = re.sub(r'.+\?>\n', '', text) |
531 | |
532 | === modified file 'openlp/plugins/songs/lib/importers/songbeamer.py' |
533 | --- openlp/plugins/songs/lib/importers/songbeamer.py 2019-04-13 13:00:22 +0000 |
534 | +++ openlp/plugins/songs/lib/importers/songbeamer.py 2019-05-04 18:26:39 +0000 |
535 | @@ -124,7 +124,7 @@ |
536 | self.chord_table = None |
537 | if file_path.is_file(): |
538 | # Detect the encoding |
539 | - self.input_file_encoding = get_file_encoding(file_path)['encoding'] |
540 | + self.input_file_encoding = get_file_encoding(file_path) |
541 | # The encoding should only be ANSI (cp1252), UTF-8, Unicode, Big-Endian-Unicode. |
542 | # So if it doesn't start with 'u' we default to cp1252. See: |
543 | # https://forum.songbeamer.com/viewtopic.php?p=419&sid=ca4814924e37c11e4438b7272a98b6f2 |
544 | |
545 | === modified file 'openlp/plugins/songs/lib/importers/worshipassistant.py' |
546 | --- openlp/plugins/songs/lib/importers/worshipassistant.py 2019-04-13 13:00:22 +0000 |
547 | +++ openlp/plugins/songs/lib/importers/worshipassistant.py 2019-05-04 18:26:39 +0000 |
548 | @@ -82,7 +82,7 @@ |
549 | Receive a CSV file to import. |
550 | """ |
551 | # Get encoding |
552 | - encoding = get_file_encoding(self.import_source)['encoding'] |
553 | + encoding = get_file_encoding(self.import_source) |
554 | with self.import_source.open('r', encoding=encoding) as songs_file: |
555 | songs_reader = csv.DictReader(songs_file, escapechar='\\') |
556 | try: |
557 | |
558 | === modified file 'tests/functional/openlp_core/common/test_common.py' |
559 | --- tests/functional/openlp_core/common/test_common.py 2019-04-13 13:00:22 +0000 |
560 | +++ tests/functional/openlp_core/common/test_common.py 2019-05-04 18:26:39 +0000 |
561 | @@ -88,7 +88,7 @@ |
562 | extension_loader('glob') |
563 | |
564 | # THEN: The `ImportError` should be caught and logged |
565 | - assert mocked_logger.warning.called |
566 | + assert mocked_logger.exception.called |
567 | |
568 | def test_extension_loader_os_error(self): |
569 | """ |
570 | @@ -106,7 +106,7 @@ |
571 | extension_loader('glob') |
572 | |
573 | # THEN: The `OSError` should be caught and logged |
574 | - assert mocked_logger.warning.called |
575 | + assert mocked_logger.exception.called |
576 | |
577 | def test_de_hump_conversion(self): |
578 | """ |
579 | |
580 | === modified file 'tests/functional/openlp_core/common/test_init.py' |
581 | --- tests/functional/openlp_core/common/test_init.py 2019-04-13 13:00:22 +0000 |
582 | +++ tests/functional/openlp_core/common/test_init.py 2019-05-04 18:26:39 +0000 |
583 | @@ -322,7 +322,7 @@ |
584 | mocked_open.assert_called_once_with('rb') |
585 | assert mocked_universal_detector_inst.feed.mock_calls == [call(b'data' * 256)] |
586 | mocked_universal_detector_inst.close.assert_called_once_with() |
587 | - assert result == encoding_result |
588 | + assert result == 'UTF-8' |
589 | |
590 | def test_get_file_encoding_eof(self): |
591 | """ |
592 | @@ -344,7 +344,7 @@ |
593 | mocked_open.assert_called_once_with('rb') |
594 | assert mocked_universal_detector_inst.feed.mock_calls == [call(b'data' * 256), call(b'data' * 4)] |
595 | mocked_universal_detector_inst.close.assert_called_once_with() |
596 | - assert result == encoding_result |
597 | + assert result == 'UTF-8' |
598 | |
599 | def test_get_file_encoding_oserror(self): |
600 | """ |
601 | @@ -367,4 +367,4 @@ |
602 | mocked_log.exception.assert_called_once_with('Error detecting file encoding') |
603 | mocked_universal_detector_inst.feed.assert_not_called() |
604 | mocked_universal_detector_inst.close.assert_called_once_with() |
605 | - assert result == encoding_result |
606 | + assert result == 'UTF-8' |
607 | |
608 | === modified file 'tests/functional/openlp_core/test_app.py' |
609 | --- tests/functional/openlp_core/test_app.py 2019-05-01 19:22:01 +0000 |
610 | +++ tests/functional/openlp_core/test_app.py 2019-05-04 18:26:39 +0000 |
611 | @@ -138,7 +138,7 @@ |
612 | assert args.loglevel == 'warning', 'The log level should be set to warning' |
613 | assert args.no_error_form is False, 'The no_error_form should be set to False' |
614 | assert args.portable is False, 'The portable flag should be set to false' |
615 | - assert args.rargs == 'dummy_temp', 'The service file should not be blank' |
616 | + assert args.rargs == ['dummy_temp'], 'The service file should not be blank' |
617 | |
618 | |
619 | def test_parse_options_file_and_debug(): |
620 | @@ -155,7 +155,7 @@ |
621 | assert args.loglevel == ' debug', 'The log level should be set to debug' |
622 | assert args.no_error_form is False, 'The no_error_form should be set to False' |
623 | assert args.portable is False, 'The portable flag should be set to false' |
624 | - assert args.rargs == 'dummy_temp', 'The service file should not be blank' |
625 | + assert args.rargs == ['dummy_temp'], 'The service file should not be blank' |
626 | |
627 | |
628 | @skip('Figure out why this is causing a segfault') |
629 | |
630 | === modified file 'tests/functional/openlp_core/test_server.py' |
631 | --- tests/functional/openlp_core/test_server.py 2019-04-13 13:00:22 +0000 |
632 | +++ tests/functional/openlp_core/test_server.py 2019-05-04 18:26:39 +0000 |
633 | @@ -22,6 +22,7 @@ |
634 | from unittest import TestCase |
635 | from unittest.mock import MagicMock, patch |
636 | |
637 | +from openlp.core.common.path import Path |
638 | from openlp.core.common.registry import Registry |
639 | from openlp.core.server import Server |
640 | from tests.helpers.testmixin import TestMixin |
641 | @@ -83,8 +84,8 @@ |
642 | self.server._on_ready_read() |
643 | |
644 | # THEN: the service will be loaded |
645 | - assert service_manager.on_load_service_clicked.call_count == 1 |
646 | - service_manager.on_load_service_clicked.assert_called_once_with(file_name) |
647 | + assert service_manager.load_service.call_count == 1 |
648 | + service_manager.load_service.assert_called_once_with(Path(file_name)) |
649 | |
650 | @patch("PyQt5.QtCore.QTextStream") |
651 | def test_post_to_server(self, mocked_stream): |
652 | |
653 | === modified file 'tests/functional/openlp_core/ui/test_mainwindow.py' |
654 | --- tests/functional/openlp_core/ui/test_mainwindow.py 2019-04-13 13:00:22 +0000 |
655 | +++ tests/functional/openlp_core/ui/test_mainwindow.py 2019-05-04 18:26:39 +0000 |
656 | @@ -96,7 +96,7 @@ |
657 | |
658 | # WHEN the argument is processed |
659 | with patch.object(self.main_window.service_manager, 'load_file') as mocked_load_file: |
660 | - self.main_window.open_cmd_line_files(service) |
661 | + self.main_window.open_cmd_line_files([service]) |
662 | |
663 | # THEN the service from the arguments is loaded |
664 | mocked_load_file.assert_called_with(Path(service)) |
665 | @@ -108,7 +108,6 @@ |
666 | """ |
667 | # GIVEN a non service file as an argument to openlp |
668 | service = 'run_openlp.py' |
669 | - self.main_window.arguments = service |
670 | |
671 | # WHEN the argument is processed |
672 | self.main_window.open_cmd_line_files(service) |
673 | |
674 | === modified file 'tests/functional/openlp_core/ui/test_thememanager.py' |
675 | --- tests/functional/openlp_core/ui/test_thememanager.py 2019-04-13 13:00:22 +0000 |
676 | +++ tests/functional/openlp_core/ui/test_thememanager.py 2019-05-04 18:26:39 +0000 |
677 | @@ -143,7 +143,7 @@ |
678 | mocked_theme.export_theme.return_value = "{}" |
679 | |
680 | # WHEN: Calling _write_theme with a theme with a name with special characters in it |
681 | - theme_manager._write_theme(mocked_theme, None, None) |
682 | + theme_manager._write_theme(mocked_theme) |
683 | |
684 | # THEN: It should have been created |
685 | assert os.path.exists(os.path.join(self.temp_folder, 'theme 愛 name', 'theme 愛 name.json')) is True, \ |
686 | @@ -224,7 +224,7 @@ |
687 | theme_manager = ThemeManager(None) |
688 | |
689 | # WHEN: unzip_theme is called |
690 | - theme_manager.unzip_theme('theme.file', 'folder') |
691 | + theme_manager.unzip_theme(Path('theme.file'), Path('folder')) |
692 | |
693 | # THEN: The critical_error_message_box should have been called |
694 | assert mocked_critical_error_message_box.call_count == 1, 'Should have been called once' |
695 | |
696 | === modified file 'tests/functional/openlp_plugins/bibles/test_csvimport.py' |
697 | --- tests/functional/openlp_plugins/bibles/test_csvimport.py 2019-04-13 13:00:22 +0000 |
698 | +++ tests/functional/openlp_plugins/bibles/test_csvimport.py 2019-05-04 18:26:39 +0000 |
699 | @@ -136,8 +136,7 @@ |
700 | mocked_enter_file = MagicMock() |
701 | mocked_csv_file.open.return_value.__enter__.return_value = mocked_enter_file |
702 | |
703 | - with patch('openlp.plugins.bibles.lib.importers.csvbible.get_file_encoding', |
704 | - return_value={'encoding': 'utf-8', 'confidence': 0.99}), \ |
705 | + with patch('openlp.plugins.bibles.lib.importers.csvbible.get_file_encoding', return_value='utf-8'), \ |
706 | patch('openlp.plugins.bibles.lib.importers.csvbible.csv.reader', |
707 | return_value=iter(test_data)) as mocked_reader: |
708 |
Linux tests failed, please see https:/ /ci.openlp. io/job/ MP-02-Linux_ Tests/142/ for more details