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

Proposed by Phill
Status: Superseded
Proposed branch: lp:~phill-ridout/openlp/fixes-mkII
Merge into: lp:openlp
Diff against target: 1064 lines (+169/-142)
47 files modified
openlp/core/common/__init__.py (+21/-3)
openlp/core/common/applocation.py (+1/-1)
openlp/core/common/httputils.py (+4/-4)
openlp/core/common/i18n.py (+1/-1)
openlp/core/common/mixins.py (+14/-0)
openlp/core/common/path.py (+1/-1)
openlp/core/common/settings.py (+6/-0)
openlp/core/lib/__init__.py (+1/-1)
openlp/core/lib/mediamanageritem.py (+4/-2)
openlp/core/ui/exceptionform.py (+1/-1)
openlp/core/ui/formattingtagcontroller.py (+1/-1)
openlp/core/ui/mainwindow.py (+2/-2)
openlp/core/ui/servicemanager.py (+28/-28)
openlp/core/ui/thememanager.py (+3/-3)
openlp/core/version.py (+2/-2)
openlp/core/widgets/edits.py (+13/-3)
openlp/core/widgets/views.py (+1/-1)
openlp/plugins/bibles/forms/booknameform.py (+1/-2)
openlp/plugins/bibles/lib/__init__.py (+3/-3)
openlp/plugins/bibles/lib/db.py (+1/-2)
openlp/plugins/images/lib/mediaitem.py (+2/-1)
openlp/plugins/presentations/lib/pptviewcontroller.py (+1/-1)
openlp/plugins/songs/forms/editsongform.py (+3/-3)
openlp/plugins/songs/lib/__init__.py (+2/-3)
openlp/plugins/songs/lib/importers/easyslides.py (+2/-1)
openlp/plugins/songs/lib/importers/mediashout.py (+1/-1)
openlp/plugins/songs/lib/importers/openoffice.py (+2/-2)
openlp/plugins/songs/lib/importers/opensong.py (+2/-1)
openlp/plugins/songs/lib/importers/songimport.py (+2/-21)
openlp/plugins/songs/lib/importers/songsoffellowship.py (+0/-1)
openlp/plugins/songs/lib/importers/zionworx.py (+5/-15)
openlp/plugins/songs/lib/openlyricsxml.py (+1/-1)
openlp/plugins/songusage/forms/songusagedetailform.py (+8/-2)
openlp/plugins/songusage/songusageplugin.py (+6/-9)
tests/functional/openlp_core/common/test_actions.py (+1/-0)
tests/functional/openlp_core/common/test_httputils.py (+1/-1)
tests/functional/openlp_core/common/test_i18n.py (+1/-1)
tests/functional/openlp_core/common/test_path.py (+4/-4)
tests/functional/openlp_core/lib/test_lib.py (+1/-1)
tests/functional/openlp_core/ui/test_first_time.py (+1/-1)
tests/functional/openlp_core/widgets/test_views.py (+0/-1)
tests/functional/openlp_plugins/presentations/test_presentationcontroller.py (+1/-1)
tests/interfaces/openlp_core/ui/test_projectormanager.py (+1/-1)
tests/interfaces/openlp_core/ui/test_projectorsourceform.py (+1/-1)
tests/interfaces/openlp_core/ui/test_thememanager.py (+1/-1)
tests/utils/__init__.py (+1/-1)
tests/utils/test_pylint.py (+9/-5)
To merge this branch: bzr merge lp:~phill-ridout/openlp/fixes-mkII
Reviewer Review Type Date Requested Status
Tim Bentley Approve
Review via email: mp+333491@code.launchpad.net

This proposal supersedes a proposal from 2017-10-27.

This proposal has been superseded by a proposal from 2017-11-10.

Description of the change

Fixed a number of bugs, and tests.

Failing on Code Analysis2, but this looks like fallout from the refactors (it hasn't passed since the beginning of october)

Add this to your merge proposal:
--------------------------------
lp:~phill-ridout/openlp/fixes-mkII (revision 2792)
[SUCCESS] https://ci.openlp.io/job/Branch-01-Pull/2263/
[SUCCESS] https://ci.openlp.io/job/Branch-02-Functional-Tests/2165/
[SUCCESS] https://ci.openlp.io/job/Branch-03-Interface-Tests/2046/
[SUCCESS] https://ci.openlp.io/job/Branch-04a-Code_Analysis/1387/
[SUCCESS] https://ci.openlp.io/job/Branch-04b-Test_Coverage/1212/
[FAILURE] https://ci.openlp.io/job/Branch-04c-Code_Analysis2/342/
Stopping after failure

To post a comment you must log in.
Revision history for this message
Tim Bentley (trb143) wrote :

Looks good.

review: Approve
lp:~phill-ridout/openlp/fixes-mkII updated
2793. By Phill

Merge superflys branch

2794. By Phill

Small modification to upgrade settings as per superflys request

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'openlp/core/common/__init__.py'
2--- openlp/core/common/__init__.py 2017-10-07 07:05:07 +0000
3+++ openlp/core/common/__init__.py 2017-11-10 20:40:07 +0000
4@@ -43,9 +43,13 @@
5
6 FIRST_CAMEL_REGEX = re.compile('(.)([A-Z][a-z]+)')
7 SECOND_CAMEL_REGEX = re.compile('([a-z0-9])([A-Z])')
8-CONTROL_CHARS = re.compile(r'[\x00-\x1F\x7F-\x9F]', re.UNICODE)
9-INVALID_FILE_CHARS = re.compile(r'[\\/:\*\?"<>\|\+\[\]%]', re.UNICODE)
10+CONTROL_CHARS = re.compile(r'[\x00-\x1F\x7F-\x9F]')
11+INVALID_FILE_CHARS = re.compile(r'[\\/:\*\?"<>\|\+\[\]%]')
12 IMAGES_FILTER = None
13+REPLACMENT_CHARS_MAP = str.maketrans({'\u2018': '\'', '\u2019': '\'', '\u201c': '"', '\u201d': '"', '\u2026': '...',
14+ '\u2013': '-', '\u2014': '-', '\v': '\n\n', '\f': '\n\n'})
15+NEW_LINE_REGEX = re.compile(r' ?(\r\n?|\n) ?')
16+WHITESPACE_REGEX = re.compile(r'[ \t]+')
17
18
19 def trace_error_handler(logger):
20@@ -339,7 +343,7 @@
21 if file_path.exists():
22 file_path.unlink()
23 return True
24- except (IOError, OSError):
25+ except OSError:
26 log.exception('Unable to delete file {file_path}'.format(file_path=file_path))
27 return False
28
29@@ -436,3 +440,17 @@
30 return detector.result
31 except OSError:
32 log.exception('Error detecting file encoding')
33+
34+
35+def normalize_str(irreg_str):
36+ """
37+ Normalize the supplied string. Remove unicode control chars and tidy up white space.
38+
39+ :param str irreg_str: The string to normalize.
40+ :return: The normalized string
41+ :rtype: str
42+ """
43+ irreg_str = irreg_str.translate(REPLACMENT_CHARS_MAP)
44+ irreg_str = CONTROL_CHARS.sub('', irreg_str)
45+ irreg_str = NEW_LINE_REGEX.sub('\n', irreg_str)
46+ return WHITESPACE_REGEX.sub(' ', irreg_str)
47
48=== modified file 'openlp/core/common/applocation.py'
49--- openlp/core/common/applocation.py 2017-10-07 07:05:07 +0000
50+++ openlp/core/common/applocation.py 2017-11-10 20:40:07 +0000
51@@ -83,7 +83,7 @@
52 """
53 # Check if we have a different data location.
54 if Settings().contains('advanced/data path'):
55- path = Settings().value('advanced/data path')
56+ path = Path(Settings().value('advanced/data path'))
57 else:
58 path = AppLocation.get_directory(AppLocation.DataDir)
59 create_paths(path)
60
61=== modified file 'openlp/core/common/httputils.py'
62--- openlp/core/common/httputils.py 2017-10-07 07:05:07 +0000
63+++ openlp/core/common/httputils.py 2017-11-10 20:40:07 +0000
64@@ -97,8 +97,8 @@
65 response = requests.get(url, headers=headers, proxies=proxies, timeout=float(CONNECTION_TIMEOUT))
66 log.debug('Downloaded page {url}'.format(url=response.url))
67 break
68- except IOError:
69- # For now, catch IOError. All requests errors inherit from IOError
70+ except OSError:
71+ # For now, catch OSError. All requests errors inherit from OSError
72 log.exception('Unable to connect to {url}'.format(url=url))
73 response = None
74 if retries >= CONNECTION_RETRIES:
75@@ -127,7 +127,7 @@
76 try:
77 response = requests.head(url, timeout=float(CONNECTION_TIMEOUT), allow_redirects=True)
78 return int(response.headers['Content-Length'])
79- except IOError:
80+ except OSError:
81 if retries > CONNECTION_RETRIES:
82 raise ConnectionError('Unable to download {url}'.format(url=url))
83 else:
84@@ -173,7 +173,7 @@
85 file_path.unlink()
86 return False
87 break
88- except IOError:
89+ except OSError:
90 trace_error_handler(log)
91 if retries > CONNECTION_RETRIES:
92 if file_path.exists():
93
94=== modified file 'openlp/core/common/i18n.py'
95--- openlp/core/common/i18n.py 2017-10-07 07:05:07 +0000
96+++ openlp/core/common/i18n.py 2017-11-10 20:40:07 +0000
97@@ -53,7 +53,7 @@
98
99 Language = namedtuple('Language', ['id', 'name', 'code'])
100 ICU_COLLATOR = None
101-DIGITS_OR_NONDIGITS = re.compile(r'\d+|\D+', re.UNICODE)
102+DIGITS_OR_NONDIGITS = re.compile(r'\d+|\D+')
103 LANGUAGES = sorted([
104 Language(1, translate('common.languages', '(Afan) Oromo', 'Language code: om'), 'om'),
105 Language(2, translate('common.languages', 'Abkhazian', 'Language code: ab'), 'ab'),
106
107=== modified file 'openlp/core/common/mixins.py'
108--- openlp/core/common/mixins.py 2017-10-23 22:09:57 +0000
109+++ openlp/core/common/mixins.py 2017-11-10 20:40:07 +0000
110@@ -101,6 +101,20 @@
111 """
112 This adds registry components to classes to use at run time.
113 """
114+ _application = None
115+ _plugin_manager = None
116+ _image_manager = None
117+ _media_controller = None
118+ _service_manager = None
119+ _preview_controller = None
120+ _live_controller = None
121+ _main_window = None
122+ _renderer = None
123+ _theme_manager = None
124+ _settings_form = None
125+ _alerts_manager = None
126+ _projector_manager = None
127+
128 @property
129 def application(self):
130 """
131
132=== modified file 'openlp/core/common/path.py'
133--- openlp/core/common/path.py 2017-10-07 07:05:07 +0000
134+++ openlp/core/common/path.py 2017-11-10 20:40:07 +0000
135@@ -233,7 +233,7 @@
136 try:
137 if not path.exists():
138 path.mkdir(parents=True)
139- except IOError:
140+ except OSError:
141 if not kwargs.get('do_not_log', False):
142 log.exception('failed to check if directory exists or create directory')
143
144
145=== modified file 'openlp/core/common/settings.py'
146--- openlp/core/common/settings.py 2017-10-07 07:05:07 +0000
147+++ openlp/core/common/settings.py 2017-11-10 20:40:07 +0000
148@@ -258,6 +258,12 @@
149 ('media/last directory', 'media/last directory', [(str_to_path, None)])
150 ]
151
152+ __setting_upgrade_3__ = [
153+ ('songuasge/db password', 'songusage/db password', []),
154+ ('songuasge/db hostname', 'songusage/db hostname', []),
155+ ('songuasge/db database', 'songusage/db database', [])
156+ ]
157+
158 @staticmethod
159 def extend_default_settings(default_values):
160 """
161
162=== modified file 'openlp/core/lib/__init__.py'
163--- openlp/core/lib/__init__.py 2017-10-10 07:08:44 +0000
164+++ openlp/core/lib/__init__.py 2017-11-10 20:40:07 +0000
165@@ -104,7 +104,7 @@
166 # no BOM was found
167 file_handle.seek(0)
168 content = file_handle.read()
169- except (IOError, UnicodeError):
170+ except (OSError, UnicodeError):
171 log.exception('Failed to open text file {text}'.format(text=text_file_path))
172 return content
173
174
175=== modified file 'openlp/core/lib/mediamanageritem.py'
176--- openlp/core/lib/mediamanageritem.py 2017-10-23 22:09:57 +0000
177+++ openlp/core/lib/mediamanageritem.py 2017-11-10 20:40:07 +0000
178@@ -92,7 +92,7 @@
179 Run some initial setup. This method is separate from __init__ in order to mock it out in tests.
180 """
181 self.hide()
182- self.whitespace = re.compile(r'[\W_]+', re.UNICODE)
183+ self.whitespace = re.compile(r'[\W_]+')
184 visible_title = self.plugin.get_string(StringContent.VisibleName)
185 self.title = str(visible_title['title'])
186 Registry().register(self.plugin.name, self)
187@@ -344,7 +344,9 @@
188 else:
189 new_files.append(file_name)
190 if new_files:
191- self.validate_and_load(new_files, data['target'])
192+ if 'target' in data:
193+ self.validate_and_load(new_files, data['target'])
194+ self.validate_and_load(new_files)
195
196 def dnd_move_internal(self, target):
197 """
198
199=== modified file 'openlp/core/ui/exceptionform.py'
200--- openlp/core/ui/exceptionform.py 2017-10-23 22:09:57 +0000
201+++ openlp/core/ui/exceptionform.py 2017-11-10 20:40:07 +0000
202@@ -155,7 +155,7 @@
203 try:
204 with file_path.open('w') as report_file:
205 report_file.write(report_text)
206- except IOError:
207+ except OSError:
208 log.exception('Failed to write crash report')
209
210 def on_send_report_button_clicked(self):
211
212=== modified file 'openlp/core/ui/formattingtagcontroller.py'
213--- openlp/core/ui/formattingtagcontroller.py 2017-10-07 07:05:07 +0000
214+++ openlp/core/ui/formattingtagcontroller.py 2017-11-10 20:40:07 +0000
215@@ -43,7 +43,7 @@
216 r'(?P<tag>[^\s/!\?>]+)(?:\s+[^\s=]+="[^"]*")*\s*(?P<empty>/)?'
217 r'|(?P<cdata>!\[CDATA\[(?:(?!\]\]>).)*\]\])'
218 r'|(?P<procinst>\?(?:(?!\?>).)*\?)'
219- r'|(?P<comment>!--(?:(?!-->).)*--))>', re.UNICODE)
220+ r'|(?P<comment>!--(?:(?!-->).)*--))>')
221 self.html_regex = re.compile(r'^(?:[^<>]*%s)*[^<>]*$' % self.html_tag_regex.pattern)
222
223 def pre_save(self):
224
225=== added directory 'openlp/core/ui/lib'
226=== modified file 'openlp/core/ui/mainwindow.py'
227--- openlp/core/ui/mainwindow.py 2017-10-23 22:09:57 +0000
228+++ openlp/core/ui/mainwindow.py 2017-11-10 20:40:07 +0000
229@@ -180,7 +180,7 @@
230 triggers=self.service_manager_contents.on_load_service_clicked)
231 self.file_save_item = create_action(main_window, 'fileSaveItem', icon=':/general/general_save.png',
232 can_shortcuts=True, category=UiStrings().File,
233- triggers=self.service_manager_contents.save_file)
234+ triggers=self.service_manager_contents.decide_save_method)
235 self.file_save_as_item = create_action(main_window, 'fileSaveAsItem', can_shortcuts=True,
236 category=UiStrings().File,
237 triggers=self.service_manager_contents.save_file_as)
238@@ -1367,7 +1367,7 @@
239 '- Please wait for copy to finish').format(path=self.new_data_path))
240 dir_util.copy_tree(str(old_data_path), str(self.new_data_path))
241 log.info('Copy successful')
242- except (IOError, os.error, DistutilsFileError) as why:
243+ except (OSError, DistutilsFileError) as why:
244 self.application.set_normal_cursor()
245 log.exception('Data copy failed {err}'.format(err=str(why)))
246 err_text = translate('OpenLP.MainWindow',
247
248=== modified file 'openlp/core/ui/servicemanager.py'
249--- openlp/core/ui/servicemanager.py 2017-10-23 22:09:57 +0000
250+++ openlp/core/ui/servicemanager.py 2017-11-10 20:40:07 +0000
251@@ -193,18 +193,6 @@
252 text=translate('OpenLP.ServiceManager', 'Move to &bottom'), icon=':/services/service_bottom.png',
253 tooltip=translate('OpenLP.ServiceManager', 'Move item to the end of the service.'),
254 can_shortcuts=True, category=UiStrings().Service, triggers=self.on_service_end)
255- self.down_action = self.order_toolbar.add_toolbar_action(
256- 'down',
257- text=translate('OpenLP.ServiceManager', 'Move &down'), can_shortcuts=True,
258- tooltip=translate('OpenLP.ServiceManager', 'Moves the selection down the window.'), visible=False,
259- triggers=self.on_move_selection_down)
260- action_list.add_action(self.down_action)
261- self.up_action = self.order_toolbar.add_toolbar_action(
262- 'up',
263- text=translate('OpenLP.ServiceManager', 'Move up'), can_shortcuts=True,
264- tooltip=translate('OpenLP.ServiceManager', 'Moves the selection up the window.'), visible=False,
265- triggers=self.on_move_selection_up)
266- action_list.add_action(self.up_action)
267 self.order_toolbar.addSeparator()
268 self.delete_action = self.order_toolbar.add_toolbar_action(
269 'delete', can_shortcuts=True,
270@@ -300,8 +288,8 @@
271 self.theme_menu = QtWidgets.QMenu(translate('OpenLP.ServiceManager', '&Change Item Theme'))
272 self.menu.addMenu(self.theme_menu)
273 self.service_manager_list.addActions([self.move_down_action, self.move_up_action, self.make_live_action,
274- self.move_top_action, self.move_bottom_action, self.up_action,
275- self.down_action, self.expand_action, self.collapse_action])
276+ self.move_top_action, self.move_bottom_action, self.expand_action,
277+ self.collapse_action])
278 Registry().register_function('theme_update_list', self.update_theme_list)
279 Registry().register_function('config_screen_changed', self.regenerate_service_items)
280 Registry().register_function('theme_update_global', self.theme_change)
281@@ -474,6 +462,12 @@
282 Load a recent file as the service triggered by mainwindow recent service list.
283 :param field:
284 """
285+ if self.is_modified():
286+ result = self.save_modified_service()
287+ if result == QtWidgets.QMessageBox.Cancel:
288+ return False
289+ elif result == QtWidgets.QMessageBox.Save:
290+ self.decide_save_method()
291 sender = self.sender()
292 self.load_file(sender.data())
293
294@@ -603,7 +597,7 @@
295 if not os.path.exists(save_file):
296 shutil.copy(audio_from, save_file)
297 zip_file.write(audio_from, audio_to)
298- except IOError:
299+ except OSError:
300 self.log_exception('Failed to save service to disk: {name}'.format(name=temp_file_name))
301 self.main_window.error_message(translate('OpenLP.ServiceManager', 'Error Saving File'),
302 translate('OpenLP.ServiceManager', 'There was an error saving your file.'))
303@@ -664,7 +658,7 @@
304 zip_file = zipfile.ZipFile(temp_file_name, 'w', zipfile.ZIP_STORED, True)
305 # First we add service contents.
306 zip_file.writestr(service_file_name, service_content)
307- except IOError:
308+ except OSError:
309 self.log_exception('Failed to save service to disk: {name}'.format(name=temp_file_name))
310 self.main_window.error_message(translate('OpenLP.ServiceManager', 'Error Saving File'),
311 translate('OpenLP.ServiceManager', 'There was an error saving your file.'))
312@@ -712,18 +706,23 @@
313 default_file_path = directory_path / default_file_path
314 # SaveAs from osz to oszl is not valid as the files will be deleted on exit which is not sensible or usable in
315 # the long term.
316+ lite_filter = translate('OpenLP.ServiceManager', 'OpenLP Service Files - lite (*.oszl)')
317+ packaged_filter = translate('OpenLP.ServiceManager', 'OpenLP Service Files (*.osz)')
318+
319 if self._file_name.endswith('oszl') or self.service_has_all_original_files:
320 file_path, filter_used = FileDialog.getSaveFileName(
321 self.main_window, UiStrings().SaveService, default_file_path,
322- translate('OpenLP.ServiceManager',
323- 'OpenLP Service Files (*.osz);; OpenLP Service Files - lite (*.oszl)'))
324+ '{packaged};; {lite}'.format(packaged=packaged_filter, lite=lite_filter))
325 else:
326 file_path, filter_used = FileDialog.getSaveFileName(
327- self.main_window, UiStrings().SaveService, file_path,
328- translate('OpenLP.ServiceManager', 'OpenLP Service Files (*.osz);;'))
329+ self.main_window, UiStrings().SaveService, default_file_path,
330+ '{packaged};;'.format(packaged=packaged_filter))
331 if not file_path:
332 return False
333- file_path.with_suffix('.osz')
334+ if filter_used == lite_filter:
335+ file_path = file_path.with_suffix('.oszl')
336+ else:
337+ file_path = file_path.with_suffix('.osz')
338 self.set_file_name(file_path)
339 self.decide_save_method()
340
341@@ -791,11 +790,11 @@
342 else:
343 critical_error_message_box(message=translate('OpenLP.ServiceManager', 'File is not a valid service.'))
344 self.log_error('File contains no service data')
345- except (IOError, NameError):
346+ except (OSError, NameError):
347 self.log_exception('Problem loading service file {name}'.format(name=file_name))
348 critical_error_message_box(message=translate('OpenLP.ServiceManager',
349 'File could not be opened because it is corrupt.'))
350- except zipfile.BadZipfile:
351+ except zipfile.BadZipFile:
352 if os.path.getsize(file_name) == 0:
353 self.log_exception('Service file is zero sized: {name}'.format(name=file_name))
354 QtWidgets.QMessageBox.information(self, translate('OpenLP.ServiceManager', 'Empty File'),
355@@ -1657,14 +1656,15 @@
356 if start_pos == -1:
357 return
358 if item is None:
359- end_pos = len(self.service_items)
360+ end_pos = len(self.service_items) - 1
361 else:
362 end_pos = get_parent_item_data(item) - 1
363 service_item = self.service_items[start_pos]
364- self.service_items.remove(service_item)
365- self.service_items.insert(end_pos, service_item)
366- self.repaint_service_list(end_pos, child)
367- self.set_modified()
368+ if start_pos != end_pos:
369+ self.service_items.remove(service_item)
370+ self.service_items.insert(end_pos, service_item)
371+ self.repaint_service_list(end_pos, child)
372+ self.set_modified()
373 else:
374 # we are not over anything so drop
375 replace = False
376
377=== modified file 'openlp/core/ui/thememanager.py'
378--- openlp/core/ui/thememanager.py 2017-10-23 22:09:57 +0000
379+++ openlp/core/ui/thememanager.py 2017-11-10 20:40:07 +0000
380@@ -604,7 +604,7 @@
381 else:
382 with full_name.open('wb') as out_file:
383 out_file.write(theme_zip.read(zipped_file))
384- except (IOError, zipfile.BadZipfile):
385+ except (OSError, zipfile.BadZipFile):
386 self.log_exception('Importing theme from zip failed {name}'.format(name=file_path))
387 raise ValidationError
388 except ValidationError:
389@@ -667,7 +667,7 @@
390 theme_path = theme_dir / '{file_name}.json'.format(file_name=name)
391 try:
392 theme_path.write_text(theme_pretty)
393- except IOError:
394+ except OSError:
395 self.log_exception('Saving theme to file failed')
396 if image_source_path and image_destination_path:
397 if self.old_background_image_path and image_destination_path != self.old_background_image_path:
398@@ -675,7 +675,7 @@
399 if image_source_path != image_destination_path:
400 try:
401 copyfile(image_source_path, image_destination_path)
402- except IOError:
403+ except OSError:
404 self.log_exception('Failed to save theme image')
405 self.generate_and_save_image(name, theme)
406
407
408=== modified file 'openlp/core/version.py'
409--- openlp/core/version.py 2017-10-07 07:05:07 +0000
410+++ openlp/core/version.py 2017-11-10 20:40:07 +0000
411@@ -96,7 +96,7 @@
412 remote_version = response.text
413 log.debug('New version found: %s', remote_version)
414 break
415- except IOError:
416+ except OSError:
417 log.exception('Unable to connect to OpenLP server to download version file')
418 retries += 1
419 else:
420@@ -182,7 +182,7 @@
421 try:
422 version_file = open(file_path, 'r')
423 full_version = str(version_file.read()).rstrip()
424- except IOError:
425+ except OSError:
426 log.exception('Error in version file.')
427 full_version = '0.0.0-bzr000'
428 finally:
429
430=== modified file 'openlp/core/widgets/edits.py'
431--- openlp/core/widgets/edits.py 2017-10-23 22:09:57 +0000
432+++ openlp/core/widgets/edits.py 2017-11-10 20:40:07 +0000
433@@ -27,6 +27,7 @@
434
435 from PyQt5 import QtCore, QtGui, QtWidgets
436
437+from openlp.core.common import CONTROL_CHARS
438 from openlp.core.common.i18n import UiStrings, translate
439 from openlp.core.common.path import Path, path_to_str, str_to_path
440 from openlp.core.common.settings import Settings
441@@ -241,7 +242,7 @@
442 self.line_edit.editingFinished.connect(self.on_line_edit_editing_finished)
443 self.update_button_tool_tips()
444
445- @property
446+ @QtCore.pyqtProperty('QVariant')
447 def path(self):
448 """
449 A property getter method to return the selected path.
450@@ -349,7 +350,7 @@
451 :rtype: None
452 """
453 if self._path != path:
454- self.path = path
455+ self._path = path
456 self.pathChanged.emit(path)
457
458
459@@ -470,12 +471,21 @@
460 cursor.insertText(html['start tag'])
461 cursor.insertText(html['end tag'])
462
463+ def insertFromMimeData(self, source):
464+ """
465+ Reimplement `insertFromMimeData` so that we can remove any control characters
466+
467+ :param QtCore.QMimeData source: The mime data to insert
468+ :rtype: None
469+ """
470+ self.insertPlainText(CONTROL_CHARS.sub('', source.text()))
471+
472
473 class Highlighter(QtGui.QSyntaxHighlighter):
474 """
475 Provides a text highlighter for pointing out spelling errors in text.
476 """
477- WORDS = r'(?iu)[\w\']+'
478+ WORDS = r'(?i)[\w\']+'
479
480 def __init__(self, *args):
481 """
482
483=== modified file 'openlp/core/widgets/views.py'
484--- openlp/core/widgets/views.py 2017-10-23 22:09:57 +0000
485+++ openlp/core/widgets/views.py 2017-11-10 20:40:07 +0000
486@@ -336,7 +336,7 @@
487 for file in listing:
488 files.append(os.path.join(local_file, file))
489 Registry().execute('{mime_data}_dnd'.format(mime_data=self.mime_data_text),
490- {'files': files, 'target': self.itemAt(event.pos())})
491+ {'files': files})
492 else:
493 event.ignore()
494
495
496=== modified file 'openlp/plugins/bibles/forms/booknameform.py'
497--- openlp/plugins/bibles/forms/booknameform.py 2017-10-07 07:05:07 +0000
498+++ openlp/plugins/bibles/forms/booknameform.py 2017-11-10 20:40:07 +0000
499@@ -113,8 +113,7 @@
500 cor_book = self.corresponding_combo_box.currentText()
501 for character in '\\.^$*+?{}[]()':
502 cor_book = cor_book.replace(character, '\\' + character)
503- books = [key for key in list(self.book_names.keys()) if re.match(cor_book, str(self.book_names[key]),
504- re.UNICODE)]
505+ books = [key for key in list(self.book_names.keys()) if re.match(cor_book, str(self.book_names[key]))]
506 books = [_f for _f in map(BiblesResourcesDB.get_book, books) if _f]
507 if books:
508 self.book_id = books[0]['id']
509
510=== modified file 'openlp/plugins/bibles/lib/__init__.py'
511--- openlp/plugins/bibles/lib/__init__.py 2017-10-07 07:05:07 +0000
512+++ openlp/plugins/bibles/lib/__init__.py 2017-11-10 20:40:07 +0000
513@@ -224,13 +224,13 @@
514 range_regex = '(?:(?P<from_chapter>[0-9]+){sep_v})?' \
515 '(?P<from_verse>[0-9]+)(?P<range_to>{sep_r}(?:(?:(?P<to_chapter>' \
516 '[0-9]+){sep_v})?(?P<to_verse>[0-9]+)|{sep_e})?)?'.format_map(REFERENCE_SEPARATORS)
517- REFERENCE_MATCHES['range'] = re.compile(r'^\s*{range}\s*$'.format(range=range_regex), re.UNICODE)
518- REFERENCE_MATCHES['range_separator'] = re.compile(REFERENCE_SEPARATORS['sep_l'], re.UNICODE)
519+ REFERENCE_MATCHES['range'] = re.compile(r'^\s*{range}\s*$'.format(range=range_regex))
520+ REFERENCE_MATCHES['range_separator'] = re.compile(REFERENCE_SEPARATORS['sep_l'])
521 # full reference match: <book>(<range>(,(?!$)|(?=$)))+
522 REFERENCE_MATCHES['full'] = \
523 re.compile(r'^\s*(?!\s)(?P<book>[\d]*[.]?[^\d\.]+)\.*(?<!\s)\s*'
524 r'(?P<ranges>(?:{range_regex}(?:{sep_l}(?!\s*$)|(?=\s*$)))+)\s*$'.format(
525- range_regex=range_regex, sep_l=REFERENCE_SEPARATORS['sep_l']), re.UNICODE)
526+ range_regex=range_regex, sep_l=REFERENCE_SEPARATORS['sep_l']))
527
528
529 def get_reference_separator(separator_type):
530
531=== modified file 'openlp/plugins/bibles/lib/db.py'
532--- openlp/plugins/bibles/lib/db.py 2017-10-23 22:09:57 +0000
533+++ openlp/plugins/bibles/lib/db.py 2017-11-10 20:40:07 +0000
534@@ -307,8 +307,7 @@
535 book_escaped = book
536 for character in RESERVED_CHARACTERS:
537 book_escaped = book_escaped.replace(character, '\\' + character)
538- regex_book = re.compile('\\s*{book}\\s*'.format(book='\\s*'.join(book_escaped.split())),
539- re.UNICODE | re.IGNORECASE)
540+ regex_book = re.compile('\\s*{book}\\s*'.format(book='\\s*'.join(book_escaped.split())), re.IGNORECASE)
541 if language_selection == LanguageSelection.Bible:
542 db_book = self.get_book(book)
543 if db_book:
544
545=== modified file 'openlp/plugins/images/lib/mediaitem.py'
546--- openlp/plugins/images/lib/mediaitem.py 2017-10-23 22:09:57 +0000
547+++ openlp/plugins/images/lib/mediaitem.py 2017-11-10 20:40:07 +0000
548@@ -366,7 +366,7 @@
549 if validate_thumb(image.file_path, thumbnail_path):
550 icon = build_icon(thumbnail_path)
551 else:
552- icon = create_thumb(image.file_path, thumbnail_path)
553+ icon = create_thumb(str(image.file_path), str(thumbnail_path))
554 item_name = QtWidgets.QTreeWidgetItem([file_name])
555 item_name.setText(0, file_name)
556 item_name.setIcon(0, icon)
557@@ -390,6 +390,7 @@
558 :param files: A List of strings containing the filenames of the files to be loaded
559 :param target_group: The QTreeWidgetItem of the group that will be the parent of the added files
560 """
561+ file_paths = [Path(file) for file in file_paths]
562 self.application.set_normal_cursor()
563 self.load_list(file_paths, target_group)
564 last_dir = file_paths[0].parent
565
566=== modified file 'openlp/plugins/presentations/lib/pptviewcontroller.py'
567--- openlp/plugins/presentations/lib/pptviewcontroller.py 2017-10-10 07:08:44 +0000
568+++ openlp/plugins/presentations/lib/pptviewcontroller.py 2017-11-10 20:40:07 +0000
569@@ -70,7 +70,7 @@
570 try:
571 self.start_process()
572 return self.process.CheckInstalled()
573- except WindowsError:
574+ except OSError:
575 return False
576
577 def start_process(self):
578
579=== modified file 'openlp/plugins/songs/forms/editsongform.py'
580--- openlp/plugins/songs/forms/editsongform.py 2017-10-23 22:09:57 +0000
581+++ openlp/plugins/songs/forms/editsongform.py 2017-11-10 20:40:07 +0000
582@@ -105,9 +105,9 @@
583 self.topics_list_view.setSortingEnabled(False)
584 self.topics_list_view.setAlternatingRowColors(True)
585 self.audio_list_widget.setAlternatingRowColors(True)
586- self.find_verse_split = re.compile('---\[\]---\n', re.UNICODE)
587- self.whitespace = re.compile(r'\W+', re.UNICODE)
588- self.find_tags = re.compile(u'\{/?\w+\}', re.UNICODE)
589+ self.find_verse_split = re.compile('---\[\]---\n')
590+ self.whitespace = re.compile(r'\W+')
591+ self.find_tags = re.compile(r'\{/?\w+\}')
592
593 def _load_objects(self, cls, combo, cache):
594 """
595
596=== modified file 'openlp/plugins/songs/lib/__init__.py'
597--- openlp/plugins/songs/lib/__init__.py 2017-10-10 02:29:56 +0000
598+++ openlp/plugins/songs/lib/__init__.py 2017-11-10 20:40:07 +0000
599@@ -24,7 +24,6 @@
600 """
601
602 import logging
603-import os
604 import re
605
606 from PyQt5 import QtWidgets
607@@ -39,8 +38,8 @@
608
609 log = logging.getLogger(__name__)
610
611-WHITESPACE = re.compile(r'[\W_]+', re.UNICODE)
612-APOSTROPHE = re.compile('[\'`’ʻ′]', re.UNICODE)
613+WHITESPACE = re.compile(r'[\W_]+')
614+APOSTROPHE = re.compile(r'[\'`’ʻ′]')
615 # PATTERN will look for the next occurence of one of these symbols:
616 # \controlword - optionally preceded by \*, optionally followed by a number
617 # \'## - where ## is a pair of hex digits, representing a single character
618
619=== modified file 'openlp/plugins/songs/lib/importers/easyslides.py'
620--- openlp/plugins/songs/lib/importers/easyslides.py 2017-09-30 20:16:30 +0000
621+++ openlp/plugins/songs/lib/importers/easyslides.py 2017-11-10 20:40:07 +0000
622@@ -25,6 +25,7 @@
623
624 from lxml import etree, objectify
625
626+from openlp.core.common import normalize_str
627 from openlp.plugins.songs.lib import VerseType
628 from openlp.plugins.songs.lib.importers.songimport import SongImport
629
630@@ -225,7 +226,7 @@
631 verses[reg].setdefault(vt, {})
632 verses[reg][vt].setdefault(vn, {})
633 verses[reg][vt][vn].setdefault(inst, [])
634- verses[reg][vt][vn][inst].append(self.tidy_text(line))
635+ verses[reg][vt][vn][inst].append(normalize_str(line))
636 # done parsing
637 versetags = []
638 # we use our_verse_order to ensure, we insert lyrics in the same order
639
640=== modified file 'openlp/plugins/songs/lib/importers/mediashout.py'
641--- openlp/plugins/songs/lib/importers/mediashout.py 2017-10-07 07:05:07 +0000
642+++ openlp/plugins/songs/lib/importers/mediashout.py 2017-11-10 20:40:07 +0000
643@@ -101,7 +101,7 @@
644 self.song_book_name = song.SongID
645 for verse in verses:
646 tag = VERSE_TAGS[verse.Type] + str(verse.Number) if verse.Type < len(VERSE_TAGS) else 'O'
647- self.add_verse(self.tidy_text(verse.Text), tag)
648+ self.add_verse(verse.Text, tag)
649 for order in verse_order:
650 if order.Type < len(VERSE_TAGS):
651 self.verse_order_list.append(VERSE_TAGS[order.Type] + str(order.Number))
652
653=== modified file 'openlp/plugins/songs/lib/importers/openoffice.py'
654--- openlp/plugins/songs/lib/importers/openoffice.py 2017-10-10 02:29:56 +0000
655+++ openlp/plugins/songs/lib/importers/openoffice.py 2017-11-10 20:40:07 +0000
656@@ -24,7 +24,7 @@
657
658 from PyQt5 import QtCore
659
660-from openlp.core.common import is_win, get_uno_command, get_uno_instance
661+from openlp.core.common import get_uno_command, get_uno_instance, is_win, normalize_str
662 from openlp.core.common.i18n import translate
663 from .songimport import SongImport
664
665@@ -241,7 +241,7 @@
666
667 :param text: The text.
668 """
669- song_texts = self.tidy_text(text).split('\f')
670+ song_texts = normalize_str(text).split('\f')
671 self.set_defaults()
672 for song_text in song_texts:
673 if song_text.strip():
674
675=== modified file 'openlp/plugins/songs/lib/importers/opensong.py'
676--- openlp/plugins/songs/lib/importers/opensong.py 2017-10-10 02:29:56 +0000
677+++ openlp/plugins/songs/lib/importers/opensong.py 2017-11-10 20:40:07 +0000
678@@ -25,6 +25,7 @@
679 from lxml import objectify
680 from lxml.etree import Error, LxmlError
681
682+from openlp.core.common import normalize_str
683 from openlp.core.common.i18n import translate
684 from openlp.core.common.settings import Settings
685 from openlp.plugins.songs.lib import VerseType
686@@ -262,7 +263,7 @@
687 post=this_line[offset + column:])
688 offset += len(chord) + 2
689 # Tidy text and remove the ____s from extended words
690- this_line = self.tidy_text(this_line)
691+ this_line = normalize_str(this_line)
692 this_line = this_line.replace('_', '')
693 this_line = this_line.replace('||', '\n[---]\n')
694 this_line = this_line.strip()
695
696=== modified file 'openlp/plugins/songs/lib/importers/songimport.py'
697--- openlp/plugins/songs/lib/importers/songimport.py 2017-10-23 22:09:57 +0000
698+++ openlp/plugins/songs/lib/importers/songimport.py 2017-11-10 20:40:07 +0000
699@@ -25,6 +25,7 @@
700
701 from PyQt5 import QtCore
702
703+from openlp.core.common import normalize_str
704 from openlp.core.common.applocation import AppLocation
705 from openlp.core.common.i18n import translate
706 from openlp.core.common.path import copyfile, create_paths
707@@ -130,26 +131,6 @@
708 def register(self, import_wizard):
709 self.import_wizard = import_wizard
710
711- def tidy_text(self, text):
712- """
713- Get rid of some dodgy unicode and formatting characters we're not interested in. Some can be converted to ascii.
714- """
715- text = text.replace('\u2018', '\'')
716- text = text.replace('\u2019', '\'')
717- text = text.replace('\u201c', '"')
718- text = text.replace('\u201d', '"')
719- text = text.replace('\u2026', '...')
720- text = text.replace('\u2013', '-')
721- text = text.replace('\u2014', '-')
722- # Replace vertical tab with 2 linebreaks
723- text = text.replace('\v', '\n\n')
724- # Replace form feed (page break) with 2 linebreaks
725- text = text.replace('\f', '\n\n')
726- # Remove surplus blank lines, spaces, trailing/leading spaces
727- text = re.sub(r'[ \t]+', ' ', text)
728- text = re.sub(r' ?(\r\n?|\n) ?', '\n', text)
729- return text
730-
731 def process_song_text(self, text):
732 """
733 Process the song text from import
734@@ -368,7 +349,7 @@
735 verse_tag = VerseType.tags[VerseType.Other]
736 log.info('Versetype {old} changing to {new}'.format(old=verse_def, new=new_verse_def))
737 verse_def = new_verse_def
738- sxml.add_verse_to_lyrics(verse_tag, verse_def[1:], verse_text, lang)
739+ sxml.add_verse_to_lyrics(verse_tag, verse_def[1:], normalize_str(verse_text), lang)
740 song.lyrics = str(sxml.extract_xml(), 'utf-8')
741 if not self.verse_order_list and self.verse_order_list_generated_useful:
742 self.verse_order_list = self.verse_order_list_generated
743
744=== modified file 'openlp/plugins/songs/lib/importers/songsoffellowship.py'
745--- openlp/plugins/songs/lib/importers/songsoffellowship.py 2016-12-31 11:01:36 +0000
746+++ openlp/plugins/songs/lib/importers/songsoffellowship.py 2017-11-10 20:40:07 +0000
747@@ -194,7 +194,6 @@
748 :param text_portion: A Piece of text
749 """
750 text = text_portion.getString()
751- text = self.tidy_text(text)
752 if text.strip() == '':
753 return text
754 if text_portion.CharWeight == BOLD:
755
756=== modified file 'openlp/plugins/songs/lib/importers/zionworx.py'
757--- openlp/plugins/songs/lib/importers/zionworx.py 2017-10-10 02:29:56 +0000
758+++ openlp/plugins/songs/lib/importers/zionworx.py 2017-11-10 20:40:07 +0000
759@@ -30,9 +30,6 @@
760
761 log = logging.getLogger(__name__)
762
763-# Used to strip control chars (except 10=LF, 13=CR)
764-CONTROL_CHARS_MAP = dict.fromkeys(list(range(10)) + [11, 12] + list(range(14, 32)) + [127])
765-
766
767 class ZionWorxImport(SongImport):
768 """
769@@ -95,12 +92,12 @@
770 return
771 self.set_defaults()
772 try:
773- self.title = self._decode(record['Title1'])
774+ self.title = record['Title1']
775 if record['Title2']:
776- self.alternate_title = self._decode(record['Title2'])
777- self.parse_author(self._decode(record['Writer']))
778- self.add_copyright(self._decode(record['Copyright']))
779- lyrics = self._decode(record['Lyrics'])
780+ self.alternate_title = record['Title2']
781+ self.parse_author(record['Writer'])
782+ self.add_copyright(record['Copyright'])
783+ lyrics = record['Lyrics']
784 except UnicodeDecodeError as e:
785 self.log_error(translate('SongsPlugin.ZionWorxImport', 'Record {index}').format(index=index),
786 translate('SongsPlugin.ZionWorxImport', 'Decoding error: {error}').format(error=e))
787@@ -122,10 +119,3 @@
788 if not self.finish():
789 self.log_error(translate('SongsPlugin.ZionWorxImport', 'Record %d') % index +
790 (': "' + title + '"' if title else ''))
791-
792- def _decode(self, str):
793- """
794- Strips all control characters (except new lines).
795- """
796- # ZionWorx has no option for setting the encoding for its songs, so we assume encoding is always the same.
797- return str.translate(CONTROL_CHARS_MAP)
798
799=== modified file 'openlp/plugins/songs/lib/openlyricsxml.py'
800--- openlp/plugins/songs/lib/openlyricsxml.py 2017-10-10 02:29:56 +0000
801+++ openlp/plugins/songs/lib/openlyricsxml.py 2017-11-10 20:40:07 +0000
802@@ -281,7 +281,7 @@
803 # Process the formatting tags.
804 # Have we any tags in song lyrics?
805 tags_element = None
806- match = re.search('\{/?\w+\}', song.lyrics, re.UNICODE)
807+ match = re.search(r'\{/?\w+\}', song.lyrics)
808 if match:
809 # Named 'format_' - 'format' is built-in function in Python.
810 format_ = etree.SubElement(song_xml, 'format')
811
812=== modified file 'openlp/plugins/songusage/forms/songusagedetailform.py'
813--- openlp/plugins/songusage/forms/songusagedetailform.py 2017-10-23 22:09:57 +0000
814+++ openlp/plugins/songusage/forms/songusagedetailform.py 2017-11-10 20:40:07 +0000
815@@ -54,8 +54,14 @@
816 """
817 We need to set up the screen
818 """
819- self.from_date_calendar.setSelectedDate(Settings().value(self.plugin.settings_section + '/from date'))
820- self.to_date_calendar.setSelectedDate(Settings().value(self.plugin.settings_section + '/to date'))
821+ to_date = Settings().value(self.plugin.settings_section + '/to date')
822+ if not (isinstance(to_date, QtCore.QDate) and to_date.isValid()):
823+ to_date = QtCore.QDate.currentDate()
824+ from_date = Settings().value(self.plugin.settings_section + '/from date')
825+ if not (isinstance(from_date, QtCore.QDate) and from_date.isValid()):
826+ from_date = to_date.addYears(-1)
827+ self.from_date_calendar.setSelectedDate(from_date)
828+ self.to_date_calendar.setSelectedDate(to_date)
829 self.report_path_edit.path = Settings().value(self.plugin.settings_section + '/last directory export')
830
831 def on_report_path_edit_path_changed(self, file_path):
832
833=== modified file 'openlp/plugins/songusage/songusageplugin.py'
834--- openlp/plugins/songusage/songusageplugin.py 2017-10-07 07:05:07 +0000
835+++ openlp/plugins/songusage/songusageplugin.py 2017-11-10 20:40:07 +0000
836@@ -38,20 +38,17 @@
837
838 log = logging.getLogger(__name__)
839
840-YEAR = QtCore.QDate().currentDate().year()
841-if QtCore.QDate().currentDate().month() < 9:
842- YEAR -= 1
843-
844+TODAY = QtCore.QDate.currentDate()
845
846 __default_settings__ = {
847 'songusage/db type': 'sqlite',
848 'songusage/db username': '',
849- 'songuasge/db password': '',
850- 'songuasge/db hostname': '',
851- 'songuasge/db database': '',
852+ 'songusage/db password': '',
853+ 'songusage/db hostname': '',
854+ 'songusage/db database': '',
855 'songusage/active': False,
856- 'songusage/to date': QtCore.QDate(YEAR, 8, 31),
857- 'songusage/from date': QtCore.QDate(YEAR - 1, 9, 1),
858+ 'songusage/to date': TODAY,
859+ 'songusage/from date': TODAY.addYears(-1),
860 'songusage/last directory export': None
861 }
862
863
864=== modified file 'tests/functional/openlp_core/common/test_actions.py'
865--- tests/functional/openlp_core/common/test_actions.py 2017-10-07 07:05:07 +0000
866+++ tests/functional/openlp_core/common/test_actions.py 2017-11-10 20:40:07 +0000
867@@ -153,6 +153,7 @@
868 """
869 Prepare the tests
870 """
871+ self.setup_application()
872 self.action_list = ActionList.get_instance()
873 self.build_settings()
874 self.settings = Settings()
875
876=== modified file 'tests/functional/openlp_core/common/test_httputils.py'
877--- tests/functional/openlp_core/common/test_httputils.py 2017-09-25 20:34:05 +0000
878+++ tests/functional/openlp_core/common/test_httputils.py 2017-11-10 20:40:07 +0000
879@@ -233,7 +233,7 @@
880 Test socket timeout gets caught
881 """
882 # GIVEN: Mocked urlopen to fake a network disconnect in the middle of a download
883- mocked_requests.get.side_effect = IOError
884+ mocked_requests.get.side_effect = OSError
885
886 # WHEN: Attempt to retrieve a file
887 url_get_file(MagicMock(), url='http://localhost/test', file_path=Path(self.tempfile))
888
889=== modified file 'tests/functional/openlp_core/common/test_i18n.py'
890--- tests/functional/openlp_core/common/test_i18n.py 2017-10-07 07:05:07 +0000
891+++ tests/functional/openlp_core/common/test_i18n.py 2017-11-10 20:40:07 +0000
892@@ -155,7 +155,7 @@
893 assert first_instance is second_instance, 'Two UiStrings objects should be the same instance'
894
895
896-def test_translate(self):
897+def test_translate():
898 """
899 Test the translate() function
900 """
901
902=== modified file 'tests/functional/openlp_core/common/test_path.py'
903--- tests/functional/openlp_core/common/test_path.py 2017-10-07 07:05:07 +0000
904+++ tests/functional/openlp_core/common/test_path.py 2017-11-10 20:40:07 +0000
905@@ -371,13 +371,13 @@
906 @patch('openlp.core.common.path.log')
907 def test_create_paths_dir_io_error(self, mocked_logger):
908 """
909- Test the create_paths() when an IOError is raised
910+ Test the create_paths() when an OSError is raised
911 """
912 # GIVEN: A `Path` to check with patched out mkdir and exists methods
913 mocked_path = MagicMock()
914- mocked_path.exists.side_effect = IOError('Cannot make directory')
915+ mocked_path.exists.side_effect = OSError('Cannot make directory')
916
917- # WHEN: An IOError is raised when checking the if the path exists.
918+ # WHEN: An OSError is raised when checking the if the path exists.
919 create_paths(mocked_path)
920
921 # THEN: The Error should have been logged
922@@ -385,7 +385,7 @@
923
924 def test_create_paths_dir_value_error(self):
925 """
926- Test the create_paths() when an error other than IOError is raised
927+ Test the create_paths() when an error other than OSError is raised
928 """
929 # GIVEN: A `Path` to check with patched out mkdir and exists methods
930 mocked_path = MagicMock()
931
932=== modified file 'tests/functional/openlp_core/lib/test_lib.py'
933--- tests/functional/openlp_core/lib/test_lib.py 2017-10-10 07:08:44 +0000
934+++ tests/functional/openlp_core/lib/test_lib.py 2017-11-10 20:40:07 +0000
935@@ -168,7 +168,7 @@
936 patch.object(Path, 'open'):
937 file_path = Path('testfile.txt')
938 file_path.is_file.return_value = True
939- file_path.open.side_effect = IOError()
940+ file_path.open.side_effect = OSError()
941
942 # WHEN: get_text_file_string is called
943 result = get_text_file_string(file_path)
944
945=== modified file 'tests/functional/openlp_core/ui/test_first_time.py'
946--- tests/functional/openlp_core/ui/test_first_time.py 2017-09-20 16:55:21 +0000
947+++ tests/functional/openlp_core/ui/test_first_time.py 2017-11-10 20:40:07 +0000
948@@ -40,7 +40,7 @@
949 Test get_web_page will attempt CONNECTION_RETRIES+1 connections - bug 1409031
950 """
951 # GIVEN: Initial settings and mocks
952- mocked_requests.get.side_effect = IOError('Unable to connect')
953+ mocked_requests.get.side_effect = OSError('Unable to connect')
954
955 # WHEN: A webpage is requested
956 try:
957
958=== modified file 'tests/functional/openlp_core/widgets/test_views.py'
959--- tests/functional/openlp_core/widgets/test_views.py 2017-10-23 22:09:57 +0000
960+++ tests/functional/openlp_core/widgets/test_views.py 2017-11-10 20:40:07 +0000
961@@ -627,4 +627,3 @@
962 assert widget.allow_internal_dnd is False
963 assert widget.indentation() == 0
964 assert widget.isAnimated() is True
965-
966
967=== modified file 'tests/functional/openlp_plugins/presentations/test_presentationcontroller.py'
968--- tests/functional/openlp_plugins/presentations/test_presentationcontroller.py 2017-10-07 07:05:07 +0000
969+++ tests/functional/openlp_plugins/presentations/test_presentationcontroller.py 2017-11-10 20:40:07 +0000
970@@ -144,7 +144,7 @@
971 # GIVEN: A mocked open, get_thumbnail_folder and exists
972 with patch('openlp.plugins.presentations.lib.presentationcontroller.Path.read_text') as mocked_read_text, \
973 patch(FOLDER_TO_PATCH) as mocked_get_thumbnail_folder:
974- mocked_read_text.side_effect = IOError()
975+ mocked_read_text.side_effect = OSError()
976 mocked_get_thumbnail_folder.return_value = Path('test')
977
978 # WHEN: calling get_titles_and_notes
979
980=== modified file 'tests/interfaces/openlp_core/ui/test_projectormanager.py'
981--- tests/interfaces/openlp_core/ui/test_projectormanager.py 2017-10-07 07:05:07 +0000
982+++ tests/interfaces/openlp_core/ui/test_projectormanager.py 2017-11-10 20:40:07 +0000
983@@ -42,8 +42,8 @@
984 """
985 Create the UI and setup necessary options
986 """
987+ self.setup_application()
988 self.build_settings()
989- self.setup_application()
990 Registry.create()
991 with patch('openlp.core.lib.projector.db.init_url') as mocked_init_url:
992 if os.path.exists(TEST_DB):
993
994=== modified file 'tests/interfaces/openlp_core/ui/test_projectorsourceform.py'
995--- tests/interfaces/openlp_core/ui/test_projectorsourceform.py 2017-10-07 07:05:07 +0000
996+++ tests/interfaces/openlp_core/ui/test_projectorsourceform.py 2017-11-10 20:40:07 +0000
997@@ -64,8 +64,8 @@
998 Set up anything necessary for all tests
999 """
1000 mocked_init_url.return_value = 'sqlite:///{}'.format(TEST_DB)
1001+ self.setup_application()
1002 self.build_settings()
1003- self.setup_application()
1004 Registry.create()
1005 # Do not try to recreate if we've already been created from a previous test
1006 if not hasattr(self, 'projectordb'):
1007
1008=== modified file 'tests/interfaces/openlp_core/ui/test_thememanager.py'
1009--- tests/interfaces/openlp_core/ui/test_thememanager.py 2017-10-10 01:08:09 +0000
1010+++ tests/interfaces/openlp_core/ui/test_thememanager.py 2017-11-10 20:40:07 +0000
1011@@ -41,8 +41,8 @@
1012 """
1013 Create the UI
1014 """
1015+ self.setup_application()
1016 self.build_settings()
1017- self.setup_application()
1018 Registry.create()
1019 self.theme_manager = ThemeManager()
1020
1021
1022=== modified file 'tests/utils/__init__.py'
1023--- tests/utils/__init__.py 2016-12-31 11:01:36 +0000
1024+++ tests/utils/__init__.py 2017-11-10 20:40:07 +0000
1025@@ -36,7 +36,7 @@
1026 try:
1027 items = json.load(open_file)
1028 first_line = items[row]
1029- except IOError:
1030+ except OSError:
1031 first_line = ''
1032 finally:
1033 open_file.close()
1034
1035=== modified file 'tests/utils/test_pylint.py'
1036--- tests/utils/test_pylint.py 2016-12-31 11:01:36 +0000
1037+++ tests/utils/test_pylint.py 2017-11-10 20:40:07 +0000
1038@@ -58,17 +58,21 @@
1039 # GIVEN: Some checks to disable and enable, and the pylint script
1040 disabled_checks = 'import-error,no-member'
1041 enabled_checks = 'missing-format-argument-key,unused-format-string-argument,bad-format-string'
1042- if is_win() or 'arch' in platform.dist()[0].lower():
1043- pylint_script = 'pylint'
1044- else:
1045- pylint_script = 'pylint3'
1046+ pylint_kwargs = {
1047+ 'return_std': True
1048+ }
1049+ if version < '1.7.0':
1050+ if is_win() or 'arch' in platform.dist()[0].lower():
1051+ pylint_kwargs.update({'script': 'pylint'})
1052+ else:
1053+ pylint_kwargs.update({'script': 'pylint3'})
1054
1055 # WHEN: Running pylint
1056 (pylint_stdout, pylint_stderr) = \
1057 lint.py_run('openlp --errors-only --disable={disabled} --enable={enabled} '
1058 '--reports=no --output-format=parseable'.format(disabled=disabled_checks,
1059 enabled=enabled_checks),
1060- return_std=True, script=pylint_script)
1061+ **pylint_kwargs)
1062 stdout = pylint_stdout.read()
1063 stderr = pylint_stderr.read()
1064 filtered_stdout = self._filter_tolerated_errors(stdout)