From 4d1061f72309d91092b4efb11e96f3922c60afa3 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 21 Jun 2013 06:16:35 +0100 Subject: [PATCH 01/15] Clean up registry for application --- openlp/core/lib/mediamanageritem.py | 12 +++-- openlp/core/lib/registry.py | 3 -- openlp/core/ui/firsttimeform.py | 12 +++-- openlp/core/ui/maindisplay.py | 12 +++-- openlp/core/ui/mainwindow.py | 15 ++++-- openlp/core/ui/media/mediaplayer.py | 12 +++-- openlp/core/ui/pluginform.py | 12 +++-- openlp/core/ui/servicemanager.py | 12 +++-- openlp/core/ui/thememanager.py | 12 +++-- openlp/core/ui/wizard.py | 12 +++-- openlp/plugins/bibles/forms/editbibleform.py | 12 +++-- openlp/plugins/bibles/lib/db.py | 12 +++-- openlp/plugins/bibles/lib/http.py | 48 ++++++++++++------- .../songs/forms/duplicatesongremovalform.py | 12 +++-- .../songs/forms/songmaintenanceform.py | 12 +++-- openlp/plugins/songs/lib/openlyricsexport.py | 12 +++-- 16 files changed, 147 insertions(+), 75 deletions(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index c3e1fa366..11565607e 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -728,10 +728,14 @@ class MediaManagerItem(QtGui.QWidget): def _get_application(self): """ - Adds the openlp to the class dynamically + Adds the openlp to the class dynamically. + Windows needs to access the application in a dynamic manner. """ - if not hasattr(self, u'_application'): - self._application = Registry().get(u'application') - return self._application + if os.name == u'nt': + Registry().get(u'application') + else: + if not hasattr(self, u'_application'): + self._application = Registry().get(u'application') + return self._application application = property(_get_application) diff --git a/openlp/core/lib/registry.py b/openlp/core/lib/registry.py index 7e880f1f9..cee9e0329 100644 --- a/openlp/core/lib/registry.py +++ b/openlp/core/lib/registry.py @@ -103,9 +103,6 @@ class Registry(object): ``key`` The service to be deleted. """ - if self.running_under_test is False: - log.error(u'Invalid Method call for key %s' % key) - raise KeyError(u'Invalid Method call for key %s' % key) if key in self.service_list: del self.service_list[key] diff --git a/openlp/core/ui/firsttimeform.py b/openlp/core/ui/firsttimeform.py index 0f3f3cc18..d6bb59daf 100644 --- a/openlp/core/ui/firsttimeform.py +++ b/openlp/core/ui/firsttimeform.py @@ -484,10 +484,14 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): def _get_application(self): """ - Adds the openlp to the class dynamically + Adds the openlp to the class dynamically. + Windows needs to access the application in a dynamic manner. """ - if not hasattr(self, u'_application'): - self._application = Registry().get(u'application') - return self._application + if os.name == u'nt': + Registry().get(u'application') + else: + if not hasattr(self, u'_application'): + self._application = Registry().get(u'application') + return self._application application = property(_get_application) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 7069cb9b7..74cea4f1f 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -494,11 +494,15 @@ class MainDisplay(Display): def _get_application(self): """ - Adds the openlp to the class dynamically + Adds the openlp to the class dynamically. + Windows needs to access the application in a dynamic manner. """ - if not hasattr(self, u'_application'): - self._application = Registry().get(u'application') - return self._application + if os.name == u'nt': + Registry().get(u'application') + else: + if not hasattr(self, u'_application'): + self._application = Registry().get(u'application') + return self._application application = property(_get_application) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 4607c441f..6a285de4c 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -1064,6 +1064,9 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): if self.live_controller.display: self.live_controller.display.close() self.live_controller.display = None + if os.name == u'nt': + # Needed for Windows to stop crashes on exit + Registry.remove(u'application') def service_changed(self, reset=False, serviceName=None): """ @@ -1374,10 +1377,14 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): def _get_application(self): """ - Adds the openlp to the class dynamically + Adds the openlp to the class dynamically. + Windows needs to access the application in a dynamic manner. """ - if not hasattr(self, u'_application'): - self._application = Registry().get(u'application') - return self._application + if os.name == u'nt': + Registry().get(u'application') + else: + if not hasattr(self, u'_application'): + self._application = Registry().get(u'application') + return self._application application = property(_get_application) diff --git a/openlp/core/ui/media/mediaplayer.py b/openlp/core/ui/media/mediaplayer.py index c1f060f60..d76bbef58 100644 --- a/openlp/core/ui/media/mediaplayer.py +++ b/openlp/core/ui/media/mediaplayer.py @@ -153,10 +153,14 @@ class MediaPlayer(object): def _get_application(self): """ - Adds the openlp to the class dynamically + Adds the openlp to the class dynamically. + Windows needs to access the application in a dynamic manner. """ - if not hasattr(self, u'_application'): - self._application = Registry().get(u'application') - return self._application + if os.name == u'nt': + Registry().get(u'application') + else: + if not hasattr(self, u'_application'): + self._application = Registry().get(u'application') + return self._application application = property(_get_application) \ No newline at end of file diff --git a/openlp/core/ui/pluginform.py b/openlp/core/ui/pluginform.py index dd497bd68..d54bb8b6d 100644 --- a/openlp/core/ui/pluginform.py +++ b/openlp/core/ui/pluginform.py @@ -166,10 +166,14 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog): def _get_application(self): """ - Adds the openlp to the class dynamically + Adds the openlp to the class dynamically. + Windows needs to access the application in a dynamic manner. """ - if not hasattr(self, u'_application'): - self._application = Registry().get(u'application') - return self._application + if os.name == u'nt': + Registry().get(u'application') + else: + if not hasattr(self, u'_application'): + self._application = Registry().get(u'application') + return self._application application = property(_get_application) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 444edc814..718a66ec8 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -1588,10 +1588,14 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): def _get_application(self): """ - Adds the openlp to the class dynamically + Adds the openlp to the class dynamically. + Windows needs to access the application in a dynamic manner. """ - if not hasattr(self, u'_application'): - self._application = Registry().get(u'application') - return self._application + if os.name == u'nt': + Registry().get(u'application') + else: + if not hasattr(self, u'_application'): + self._application = Registry().get(u'application') + return self._application application = property(_get_application) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index be0e3bfa1..07595b4a5 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -836,10 +836,14 @@ class ThemeManager(QtGui.QWidget): def _get_application(self): """ - Adds the openlp to the class dynamically + Adds the openlp to the class dynamically. + Windows needs to access the application in a dynamic manner. """ - if not hasattr(self, u'_application'): - self._application = Registry().get(u'application') - return self._application + if os.name == u'nt': + Registry().get(u'application') + else: + if not hasattr(self, u'_application'): + self._application = Registry().get(u'application') + return self._application application = property(_get_application) diff --git a/openlp/core/ui/wizard.py b/openlp/core/ui/wizard.py index 0b142b459..0101b9d0e 100644 --- a/openlp/core/ui/wizard.py +++ b/openlp/core/ui/wizard.py @@ -320,10 +320,14 @@ class OpenLPWizard(QtGui.QWizard): def _get_application(self): """ - Adds the openlp to the class dynamically + Adds the openlp to the class dynamically. + Windows needs to access the application in a dynamic manner. """ - if not hasattr(self, u'_application'): - self._application = Registry().get(u'application') - return self._application + if os.name == u'nt': + Registry().get(u'application') + else: + if not hasattr(self, u'_application'): + self._application = Registry().get(u'application') + return self._application application = property(_get_application) diff --git a/openlp/plugins/bibles/forms/editbibleform.py b/openlp/plugins/bibles/forms/editbibleform.py index b05fb68fb..36e41eb51 100644 --- a/openlp/plugins/bibles/forms/editbibleform.py +++ b/openlp/plugins/bibles/forms/editbibleform.py @@ -191,10 +191,14 @@ class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog): def _get_application(self): """ - Adds the openlp to the class dynamically + Adds the openlp to the class dynamically. + Windows needs to access the application in a dynamic manner. """ - if not hasattr(self, u'_application'): - self._application = Registry().get(u'application') - return self._application + if os.name == u'nt': + Registry().get(u'application') + else: + if not hasattr(self, u'_application'): + self._application = Registry().get(u'application') + return self._application application = property(_get_application) diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index 837dbec38..b8e85afaf 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -544,11 +544,15 @@ class BibleDB(QtCore.QObject, Manager): def _get_application(self): """ - Adds the openlp to the class dynamically + Adds the openlp to the class dynamically. + Windows needs to access the application in a dynamic manner. """ - if not hasattr(self, u'_application'): - self._application = Registry().get(u'application') - return self._application + if os.name == u'nt': + Registry().get(u'application') + else: + if not hasattr(self, u'_application'): + self._application = Registry().get(u'application') + return self._application application = property(_get_application) diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index efab9106b..332194049 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -301,11 +301,15 @@ class BGExtract(object): def _get_application(self): """ - Adds the openlp to the class dynamically + Adds the openlp to the class dynamically. + Windows needs to access the application in a dynamic manner. """ - if not hasattr(self, u'_application'): - self._application = Registry().get(u'application') - return self._application + if os.name == u'nt': + Registry().get(u'application') + else: + if not hasattr(self, u'_application'): + self._application = Registry().get(u'application') + return self._application application = property(_get_application) @@ -377,11 +381,15 @@ class BSExtract(object): def _get_application(self): """ - Adds the openlp to the class dynamically + Adds the openlp to the class dynamically. + Windows needs to access the application in a dynamic manner. """ - if not hasattr(self, u'_application'): - self._application = Registry().get(u'application') - return self._application + if os.name == u'nt': + Registry().get(u'application') + else: + if not hasattr(self, u'_application'): + self._application = Registry().get(u'application') + return self._application application = property(_get_application) @@ -477,11 +485,15 @@ class CWExtract(object): def _get_application(self): """ - Adds the openlp to the class dynamically + Adds the openlp to the class dynamically. + Windows needs to access the application in a dynamic manner. """ - if not hasattr(self, u'_application'): - self._application = Registry().get(u'application') - return self._application + if os.name == u'nt': + Registry().get(u'application') + else: + if not hasattr(self, u'_application'): + self._application = Registry().get(u'application') + return self._application application = property(_get_application) @@ -667,11 +679,15 @@ class HTTPBible(BibleDB): def _get_application(self): """ - Adds the openlp to the class dynamically + Adds the openlp to the class dynamically. + Windows needs to access the application in a dynamic manner. """ - if not hasattr(self, u'_application'): - self._application = Registry().get(u'application') - return self._application + if os.name == u'nt': + Registry().get(u'application') + else: + if not hasattr(self, u'_application'): + self._application = Registry().get(u'application') + return self._application application = property(_get_application) diff --git a/openlp/plugins/songs/forms/duplicatesongremovalform.py b/openlp/plugins/songs/forms/duplicatesongremovalform.py index d612a5627..0b2b2457a 100644 --- a/openlp/plugins/songs/forms/duplicatesongremovalform.py +++ b/openlp/plugins/songs/forms/duplicatesongremovalform.py @@ -349,10 +349,14 @@ class DuplicateSongRemovalForm(OpenLPWizard): def _get_application(self): """ - Adds the openlp to the class dynamically + Adds the openlp to the class dynamically. + Windows needs to access the application in a dynamic manner. """ - if not hasattr(self, u'_application'): - self._application = Registry().get(u'application') - return self._application + if os.name == u'nt': + Registry().get(u'application') + else: + if not hasattr(self, u'_application'): + self._application = Registry().get(u'application') + return self._application application = property(_get_application) \ No newline at end of file diff --git a/openlp/plugins/songs/forms/songmaintenanceform.py b/openlp/plugins/songs/forms/songmaintenanceform.py index 9f003b2a0..9c2d49a5d 100644 --- a/openlp/plugins/songs/forms/songmaintenanceform.py +++ b/openlp/plugins/songs/forms/songmaintenanceform.py @@ -525,10 +525,14 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): def _get_application(self): """ - Adds the application to the class dynamically + Adds the openlp to the class dynamically. + Windows needs to access the application in a dynamic manner. """ - if not hasattr(self, u'_application'): - self._application = Registry().get(u'application') - return self._application + if os.name == u'nt': + Registry().get(u'application') + else: + if not hasattr(self, u'_application'): + self._application = Registry().get(u'application') + return self._application application = property(_get_application) diff --git a/openlp/plugins/songs/lib/openlyricsexport.py b/openlp/plugins/songs/lib/openlyricsexport.py index f9ac6ebb3..be68a55c6 100644 --- a/openlp/plugins/songs/lib/openlyricsexport.py +++ b/openlp/plugins/songs/lib/openlyricsexport.py @@ -84,10 +84,14 @@ class OpenLyricsExport(object): def _get_application(self): """ - Adds the openlp to the class dynamically + Adds the openlp to the class dynamically. + Windows needs to access the application in a dynamic manner. """ - if not hasattr(self, u'_application'): - self._application = Registry().get(u'application') - return self._application + if os.name == u'nt': + Registry().get(u'application') + else: + if not hasattr(self, u'_application'): + self._application = Registry().get(u'application') + return self._application application = property(_get_application) From d32ece04a5304120b8afa014aea92b2a7eb03bc6 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 23 Jun 2013 20:51:17 +0100 Subject: [PATCH 02/15] add missing imports --- openlp/core/lib/plugin.py | 10 +++++++--- openlp/core/ui/maindisplay.py | 1 + openlp/core/ui/media/mediaplayer.py | 2 ++ openlp/core/ui/pluginform.py | 1 + openlp/plugins/bibles/forms/editbibleform.py | 1 + openlp/plugins/bibles/lib/http.py | 2 ++ openlp/plugins/songs/forms/songmaintenanceform.py | 1 + 7 files changed, 15 insertions(+), 3 deletions(-) diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index b4f851b24..4a82783e3 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -30,6 +30,7 @@ Provide the generic plugin functionality for OpenLP plugins. """ import logging +import os from PyQt4 import QtCore @@ -424,8 +425,11 @@ class Plugin(QtCore.QObject): """ Adds the openlp to the class dynamically """ - if not hasattr(self, u'_application'): - self._application = Registry().get(u'application') - return self._application + if os.name == u'nt': + Registry().get(u'application') + else: + if not hasattr(self, u'_application'): + self._application = Registry().get(u'application') + return self._application application = property(_get_application) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 74cea4f1f..ee3ddd6b5 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -38,6 +38,7 @@ Some of the code for this form is based on the examples at: from __future__ import division import cgi import logging +import os import sys from PyQt4 import QtCore, QtGui, QtWebKit, QtOpenGL diff --git a/openlp/core/ui/media/mediaplayer.py b/openlp/core/ui/media/mediaplayer.py index d76bbef58..bfa3bb5da 100644 --- a/openlp/core/ui/media/mediaplayer.py +++ b/openlp/core/ui/media/mediaplayer.py @@ -29,6 +29,8 @@ """ The :mod:`~openlp.core.ui.media.mediaplayer` module contains the MediaPlayer class. """ +import os + from openlp.core.lib import Registry from openlp.core.ui.media import MediaState diff --git a/openlp/core/ui/pluginform.py b/openlp/core/ui/pluginform.py index d54bb8b6d..4e766c15b 100644 --- a/openlp/core/ui/pluginform.py +++ b/openlp/core/ui/pluginform.py @@ -30,6 +30,7 @@ The actual plugin view form """ import logging +import os from PyQt4 import QtGui diff --git a/openlp/plugins/bibles/forms/editbibleform.py b/openlp/plugins/bibles/forms/editbibleform.py index 36e41eb51..53ab37e0f 100644 --- a/openlp/plugins/bibles/forms/editbibleform.py +++ b/openlp/plugins/bibles/forms/editbibleform.py @@ -28,6 +28,7 @@ ############################################################################### import logging +import os import re from PyQt4 import QtGui diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index 332194049..7e441becc 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -29,6 +29,7 @@ """ The :mod:`http` module enables OpenLP to retrieve scripture from bible websites. """ +import os import logging import re import socket @@ -691,6 +692,7 @@ class HTTPBible(BibleDB): application = property(_get_application) + def get_soup_for_bible_ref(reference_url, header=None, pre_parse_regex=None, pre_parse_substitute=None): """ Gets a webpage and returns a parsed and optionally cleaned soup or None. diff --git a/openlp/plugins/songs/forms/songmaintenanceform.py b/openlp/plugins/songs/forms/songmaintenanceform.py index 9c2d49a5d..ff9e2d562 100644 --- a/openlp/plugins/songs/forms/songmaintenanceform.py +++ b/openlp/plugins/songs/forms/songmaintenanceform.py @@ -27,6 +27,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### import logging +import os from PyQt4 import QtGui, QtCore from sqlalchemy.sql import and_ From 32c7663a45b97aedb48b81f4ee00be80c57b2431 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Mon, 24 Jun 2013 17:21:46 +0100 Subject: [PATCH 03/15] Convert formatting tags to json --- openlp/core/lib/formattingtags.py | 10 ++++++++-- openlp/core/lib/settings.py | 1 + .../functional/openlp_core_lib/test_formattingtags.py | 8 ++++---- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/openlp/core/lib/formattingtags.py b/openlp/core/lib/formattingtags.py index b2d8f6ea7..c136f00aa 100644 --- a/openlp/core/lib/formattingtags.py +++ b/openlp/core/lib/formattingtags.py @@ -30,6 +30,7 @@ Provide HTML Tag management and Formatting Tag access class """ import cPickle +import json from openlp.core.lib import Settings, translate @@ -66,7 +67,8 @@ class FormattingTags(object): if isinstance(tag[element], unicode): tag[element] = tag[element].encode('utf8') # Formatting Tags were also known as display tags. - Settings().setValue(u'displayTags/html_tags', cPickle.dumps(tags) if tags else u'') + Settings().setValue(u'displayTags/html_tags', json.dumps(tags) if tags else u'') + Settings().setValue(u'displayTags/html_tags_json', True) @staticmethod def load_tags(): @@ -159,10 +161,14 @@ class FormattingTags(object): # Formatting Tags were also known as display tags. user_expands = Settings().value(u'displayTags/html_tags') + user_format_json = Settings().value(u'displayTags/html_tags_json') # cPickle only accepts str not unicode strings user_expands_string = str(user_expands) if user_expands_string: - user_tags = cPickle.loads(user_expands_string) + if user_format_json: + user_tags = json.loads(user_expands_string) + else: + user_tags = cPickle.loads(user_expands_string) for tag in user_tags: for element in tag: if isinstance(tag[element], str): diff --git a/openlp/core/lib/settings.py b/openlp/core/lib/settings.py index 5e73ffc1d..427c24c58 100644 --- a/openlp/core/lib/settings.py +++ b/openlp/core/lib/settings.py @@ -116,6 +116,7 @@ class Settings(QtCore.QSettings): u'advanced/x11 bypass wm': X11_BYPASS_DEFAULT, u'crashreport/last directory': u'', u'displayTags/html_tags': u'', + u'displayTags/html_tags_json': False, u'core/audio repeat list': False, u'core/auto open': False, u'core/auto preview': False, diff --git a/tests/functional/openlp_core_lib/test_formattingtags.py b/tests/functional/openlp_core_lib/test_formattingtags.py index 26d87f466..326dde5c8 100644 --- a/tests/functional/openlp_core_lib/test_formattingtags.py +++ b/tests/functional/openlp_core_lib/test_formattingtags.py @@ -33,11 +33,11 @@ class TestFormattingTags(TestCase): """ with patch(u'openlp.core.lib.translate') as mocked_translate, \ patch(u'openlp.core.lib.settings') as mocked_settings, \ - patch(u'openlp.core.lib.formattingtags.cPickle') as mocked_cPickle: + patch(u'openlp.core.lib.formattingtags.json') as mocked_json: # GIVEN: Our mocked modules and functions. mocked_translate.side_effect = lambda module, string_to_translate, comment: string_to_translate mocked_settings.value.return_value = u'' - mocked_cPickle.load.return_value = [] + mocked_json.load.return_value = [] # WHEN: Get the display tags. FormattingTags.load_tags() @@ -54,11 +54,11 @@ class TestFormattingTags(TestCase): """ with patch(u'openlp.core.lib.translate') as mocked_translate, \ patch(u'openlp.core.lib.settings') as mocked_settings, \ - patch(u'openlp.core.lib.formattingtags.cPickle') as mocked_cPickle: + patch(u'openlp.core.lib.formattingtags.json') as mocked_json: # GIVEN: Our mocked modules and functions. mocked_translate.side_effect = lambda module, string_to_translate: string_to_translate mocked_settings.value.return_value = u'' - mocked_cPickle.loads.side_effect = [[], [TAG]] + mocked_json.loads.side_effect = [[], [TAG]] # WHEN: Get the display tags. FormattingTags.load_tags() From 26e80be5b76016c9ae2384168753e12af21f9020 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Mon, 24 Jun 2013 17:54:23 +0100 Subject: [PATCH 04/15] Who forgot the return --- openlp/core/lib/mediamanageritem.py | 2 +- openlp/core/lib/plugin.py | 2 +- openlp/core/ui/firsttimeform.py | 2 +- openlp/core/ui/maindisplay.py | 2 +- openlp/core/ui/mainwindow.py | 2 +- openlp/core/ui/media/mediaplayer.py | 2 +- openlp/core/ui/pluginform.py | 2 +- openlp/core/ui/servicemanager.py | 2 +- openlp/core/ui/thememanager.py | 2 +- openlp/core/ui/wizard.py | 2 +- openlp/plugins/bibles/forms/editbibleform.py | 2 +- openlp/plugins/bibles/lib/db.py | 2 +- openlp/plugins/bibles/lib/http.py | 8 ++++---- openlp/plugins/songs/forms/duplicatesongremovalform.py | 2 +- openlp/plugins/songs/forms/songmaintenanceform.py | 2 +- openlp/plugins/songs/lib/openlyricsexport.py | 2 +- 16 files changed, 19 insertions(+), 19 deletions(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 11565607e..973d457bb 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -732,7 +732,7 @@ class MediaManagerItem(QtGui.QWidget): Windows needs to access the application in a dynamic manner. """ if os.name == u'nt': - Registry().get(u'application') + return Registry().get(u'application') else: if not hasattr(self, u'_application'): self._application = Registry().get(u'application') diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index 4a82783e3..a79ba850a 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -426,7 +426,7 @@ class Plugin(QtCore.QObject): Adds the openlp to the class dynamically """ if os.name == u'nt': - Registry().get(u'application') + return Registry().get(u'application') else: if not hasattr(self, u'_application'): self._application = Registry().get(u'application') diff --git a/openlp/core/ui/firsttimeform.py b/openlp/core/ui/firsttimeform.py index d6bb59daf..f06b02a9a 100644 --- a/openlp/core/ui/firsttimeform.py +++ b/openlp/core/ui/firsttimeform.py @@ -488,7 +488,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): Windows needs to access the application in a dynamic manner. """ if os.name == u'nt': - Registry().get(u'application') + return Registry().get(u'application') else: if not hasattr(self, u'_application'): self._application = Registry().get(u'application') diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index ee3ddd6b5..eab89cb7d 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -499,7 +499,7 @@ class MainDisplay(Display): Windows needs to access the application in a dynamic manner. """ if os.name == u'nt': - Registry().get(u'application') + return Registry().get(u'application') else: if not hasattr(self, u'_application'): self._application = Registry().get(u'application') diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 6a285de4c..ffc0ebf16 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -1381,7 +1381,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): Windows needs to access the application in a dynamic manner. """ if os.name == u'nt': - Registry().get(u'application') + return Registry().get(u'application') else: if not hasattr(self, u'_application'): self._application = Registry().get(u'application') diff --git a/openlp/core/ui/media/mediaplayer.py b/openlp/core/ui/media/mediaplayer.py index bfa3bb5da..5d9e3663f 100644 --- a/openlp/core/ui/media/mediaplayer.py +++ b/openlp/core/ui/media/mediaplayer.py @@ -159,7 +159,7 @@ class MediaPlayer(object): Windows needs to access the application in a dynamic manner. """ if os.name == u'nt': - Registry().get(u'application') + return Registry().get(u'application') else: if not hasattr(self, u'_application'): self._application = Registry().get(u'application') diff --git a/openlp/core/ui/pluginform.py b/openlp/core/ui/pluginform.py index 4e766c15b..4f4824fb7 100644 --- a/openlp/core/ui/pluginform.py +++ b/openlp/core/ui/pluginform.py @@ -171,7 +171,7 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog): Windows needs to access the application in a dynamic manner. """ if os.name == u'nt': - Registry().get(u'application') + return Registry().get(u'application') else: if not hasattr(self, u'_application'): self._application = Registry().get(u'application') diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 718a66ec8..9ef1269ba 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -1592,7 +1592,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog): Windows needs to access the application in a dynamic manner. """ if os.name == u'nt': - Registry().get(u'application') + return Registry().get(u'application') else: if not hasattr(self, u'_application'): self._application = Registry().get(u'application') diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 07595b4a5..58f29cab6 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -840,7 +840,7 @@ class ThemeManager(QtGui.QWidget): Windows needs to access the application in a dynamic manner. """ if os.name == u'nt': - Registry().get(u'application') + return Registry().get(u'application') else: if not hasattr(self, u'_application'): self._application = Registry().get(u'application') diff --git a/openlp/core/ui/wizard.py b/openlp/core/ui/wizard.py index 0101b9d0e..ca89808ff 100644 --- a/openlp/core/ui/wizard.py +++ b/openlp/core/ui/wizard.py @@ -324,7 +324,7 @@ class OpenLPWizard(QtGui.QWizard): Windows needs to access the application in a dynamic manner. """ if os.name == u'nt': - Registry().get(u'application') + return Registry().get(u'application') else: if not hasattr(self, u'_application'): self._application = Registry().get(u'application') diff --git a/openlp/plugins/bibles/forms/editbibleform.py b/openlp/plugins/bibles/forms/editbibleform.py index 53ab37e0f..4e0a5a7c0 100644 --- a/openlp/plugins/bibles/forms/editbibleform.py +++ b/openlp/plugins/bibles/forms/editbibleform.py @@ -196,7 +196,7 @@ class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog): Windows needs to access the application in a dynamic manner. """ if os.name == u'nt': - Registry().get(u'application') + return Registry().get(u'application') else: if not hasattr(self, u'_application'): self._application = Registry().get(u'application') diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index b8e85afaf..69ec72ee5 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -548,7 +548,7 @@ class BibleDB(QtCore.QObject, Manager): Windows needs to access the application in a dynamic manner. """ if os.name == u'nt': - Registry().get(u'application') + return Registry().get(u'application') else: if not hasattr(self, u'_application'): self._application = Registry().get(u'application') diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index 7e441becc..624836860 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -306,7 +306,7 @@ class BGExtract(object): Windows needs to access the application in a dynamic manner. """ if os.name == u'nt': - Registry().get(u'application') + return Registry().get(u'application') else: if not hasattr(self, u'_application'): self._application = Registry().get(u'application') @@ -386,7 +386,7 @@ class BSExtract(object): Windows needs to access the application in a dynamic manner. """ if os.name == u'nt': - Registry().get(u'application') + return Registry().get(u'application') else: if not hasattr(self, u'_application'): self._application = Registry().get(u'application') @@ -490,7 +490,7 @@ class CWExtract(object): Windows needs to access the application in a dynamic manner. """ if os.name == u'nt': - Registry().get(u'application') + return Registry().get(u'application') else: if not hasattr(self, u'_application'): self._application = Registry().get(u'application') @@ -684,7 +684,7 @@ class HTTPBible(BibleDB): Windows needs to access the application in a dynamic manner. """ if os.name == u'nt': - Registry().get(u'application') + return Registry().get(u'application') else: if not hasattr(self, u'_application'): self._application = Registry().get(u'application') diff --git a/openlp/plugins/songs/forms/duplicatesongremovalform.py b/openlp/plugins/songs/forms/duplicatesongremovalform.py index 0b2b2457a..4427bbb31 100644 --- a/openlp/plugins/songs/forms/duplicatesongremovalform.py +++ b/openlp/plugins/songs/forms/duplicatesongremovalform.py @@ -353,7 +353,7 @@ class DuplicateSongRemovalForm(OpenLPWizard): Windows needs to access the application in a dynamic manner. """ if os.name == u'nt': - Registry().get(u'application') + return Registry().get(u'application') else: if not hasattr(self, u'_application'): self._application = Registry().get(u'application') diff --git a/openlp/plugins/songs/forms/songmaintenanceform.py b/openlp/plugins/songs/forms/songmaintenanceform.py index ff9e2d562..2eb895a9a 100644 --- a/openlp/plugins/songs/forms/songmaintenanceform.py +++ b/openlp/plugins/songs/forms/songmaintenanceform.py @@ -530,7 +530,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): Windows needs to access the application in a dynamic manner. """ if os.name == u'nt': - Registry().get(u'application') + return Registry().get(u'application') else: if not hasattr(self, u'_application'): self._application = Registry().get(u'application') diff --git a/openlp/plugins/songs/lib/openlyricsexport.py b/openlp/plugins/songs/lib/openlyricsexport.py index be68a55c6..35a9a29ec 100644 --- a/openlp/plugins/songs/lib/openlyricsexport.py +++ b/openlp/plugins/songs/lib/openlyricsexport.py @@ -88,7 +88,7 @@ class OpenLyricsExport(object): Windows needs to access the application in a dynamic manner. """ if os.name == u'nt': - Registry().get(u'application') + return Registry().get(u'application') else: if not hasattr(self, u'_application'): self._application = Registry().get(u'application') From b6954eba0f4f6d6314ed51d1ef19dc89115014f4 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Tue, 25 Jun 2013 15:44:56 +0100 Subject: [PATCH 05/15] Rename tag --- openlp/core/lib/formattingtags.py | 12 +++++++----- openlp/core/lib/imagemanager.py | 7 ++++++- openlp/core/lib/settings.py | 3 ++- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/openlp/core/lib/formattingtags.py b/openlp/core/lib/formattingtags.py index c136f00aa..96591e1c4 100644 --- a/openlp/core/lib/formattingtags.py +++ b/openlp/core/lib/formattingtags.py @@ -67,8 +67,8 @@ class FormattingTags(object): if isinstance(tag[element], unicode): tag[element] = tag[element].encode('utf8') # Formatting Tags were also known as display tags. - Settings().setValue(u'displayTags/html_tags', json.dumps(tags) if tags else u'') - Settings().setValue(u'displayTags/html_tags_json', True) + Settings().setValue(u'formattingTags/html_tags', json.dumps(tags) if tags else u'') + Settings().setValue(u'formattingTags/html_tags_json', True) @staticmethod def load_tags(): @@ -160,10 +160,12 @@ class FormattingTags(object): FormattingTags.add_html_tags(temporary_tags) # Formatting Tags were also known as display tags. - user_expands = Settings().value(u'displayTags/html_tags') - user_format_json = Settings().value(u'displayTags/html_tags_json') + user_format_json = Settings().value(u'formattingTags/html_tags_json') # cPickle only accepts str not unicode strings - user_expands_string = str(user_expands) + if user_format_json: + user_expands_string = str(Settings().value(u'formattingTags/html_tags')) + else: + user_expands_string = str(Settings().value(u'displayTags/html_tags')) if user_expands_string: if user_format_json: user_tags = json.loads(user_expands_string) diff --git a/openlp/core/lib/imagemanager.py b/openlp/core/lib/imagemanager.py index 412eddd1e..f8af5d0a0 100644 --- a/openlp/core/lib/imagemanager.py +++ b/openlp/core/lib/imagemanager.py @@ -1,9 +1,14 @@ + # -*- coding: utf-8 -*- # vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # -# --------------------------------------------------------------------------- # + + + + + # --------------------------------------------------------------------------- # # Copyright (c) 2008-2013 Raoul Snyman # # Portions copyright (c) 2008-2013 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, # diff --git a/openlp/core/lib/settings.py b/openlp/core/lib/settings.py index 427c24c58..48a3a72c1 100644 --- a/openlp/core/lib/settings.py +++ b/openlp/core/lib/settings.py @@ -116,7 +116,8 @@ class Settings(QtCore.QSettings): u'advanced/x11 bypass wm': X11_BYPASS_DEFAULT, u'crashreport/last directory': u'', u'displayTags/html_tags': u'', - u'displayTags/html_tags_json': False, + u'formattingTags/html_tags': u'', + u'formattingTags/html_tags_json': False, u'core/audio repeat list': False, u'core/auto open': False, u'core/auto preview': False, From 96fbb5ddbb216037ad2fb6fcd95dcede2712e0bd Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 30 Jun 2013 06:30:42 +0100 Subject: [PATCH 06/15] clean up tags --- openlp/core/lib/formattingtags.py | 13 ++----------- openlp/core/lib/settings.py | 2 -- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/openlp/core/lib/formattingtags.py b/openlp/core/lib/formattingtags.py index 96591e1c4..2dcae334f 100644 --- a/openlp/core/lib/formattingtags.py +++ b/openlp/core/lib/formattingtags.py @@ -158,19 +158,10 @@ class FormattingTags(object): u'end html': u'', u'protected': True, u'temporary': False}) FormattingTags.add_html_tags(base_tags) FormattingTags.add_html_tags(temporary_tags) - # Formatting Tags were also known as display tags. - user_format_json = Settings().value(u'formattingTags/html_tags_json') - # cPickle only accepts str not unicode strings - if user_format_json: - user_expands_string = str(Settings().value(u'formattingTags/html_tags')) - else: - user_expands_string = str(Settings().value(u'displayTags/html_tags')) + user_expands_string = str(Settings().value(u'formattingTags/html_tags')) if user_expands_string: - if user_format_json: - user_tags = json.loads(user_expands_string) - else: - user_tags = cPickle.loads(user_expands_string) + user_tags = json.loads(user_expands_string) for tag in user_tags: for element in tag: if isinstance(tag[element], str): diff --git a/openlp/core/lib/settings.py b/openlp/core/lib/settings.py index 48a3a72c1..a20e3e1a8 100644 --- a/openlp/core/lib/settings.py +++ b/openlp/core/lib/settings.py @@ -115,9 +115,7 @@ class Settings(QtCore.QSettings): u'advanced/single click preview': False, u'advanced/x11 bypass wm': X11_BYPASS_DEFAULT, u'crashreport/last directory': u'', - u'displayTags/html_tags': u'', u'formattingTags/html_tags': u'', - u'formattingTags/html_tags_json': False, u'core/audio repeat list': False, u'core/auto open': False, u'core/auto preview': False, From 74432f93e27bca26645396b191d79009178e186a Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 30 Jun 2013 06:35:57 +0100 Subject: [PATCH 07/15] oops --- openlp/core/lib/imagemanager.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/openlp/core/lib/imagemanager.py b/openlp/core/lib/imagemanager.py index f8af5d0a0..dc535a665 100644 --- a/openlp/core/lib/imagemanager.py +++ b/openlp/core/lib/imagemanager.py @@ -4,11 +4,7 @@ ############################################################################### # OpenLP - Open Source Lyrics Projection # - - - - - # --------------------------------------------------------------------------- # +# --------------------------------------------------------------------------- # # Copyright (c) 2008-2013 Raoul Snyman # # Portions copyright (c) 2008-2013 Tim Bentley, Gerald Britton, Jonathan # # Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, # From 5af820b7cd4596caaeac9bf4b399ab7c8dadc02a Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 30 Jun 2013 06:45:34 +0100 Subject: [PATCH 08/15] more cleanups --- openlp/core/lib/formattingtags.py | 1 - openlp/plugins/bibles/lib/http.py | 20 ++++++++------------ 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/openlp/core/lib/formattingtags.py b/openlp/core/lib/formattingtags.py index 2dcae334f..be9cbe82e 100644 --- a/openlp/core/lib/formattingtags.py +++ b/openlp/core/lib/formattingtags.py @@ -68,7 +68,6 @@ class FormattingTags(object): tag[element] = tag[element].encode('utf8') # Formatting Tags were also known as display tags. Settings().setValue(u'formattingTags/html_tags', json.dumps(tags) if tags else u'') - Settings().setValue(u'formattingTags/html_tags_json', True) @staticmethod def load_tags(): diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index 624836860..de48b2617 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -367,8 +367,8 @@ class BSExtract(object): The version of the Bible like NIV for New International Version """ log.debug(u'BSExtract.get_books_from_http("%s")', version) - urlversion = urllib.quote(version.encode("utf-8")) - chapter_url = u'http://m.bibleserver.com/overlay/selectBook?translation=%s' % (urlversion) + url_version = urllib.quote(version.encode("utf-8")) + chapter_url = u'http://m.bibleserver.com/overlay/selectBook?translation=%s' % (url_version) soup = get_soup_for_bible_ref(chapter_url) if not soup: return None @@ -611,9 +611,8 @@ class HTTPBible(BibleDB): if show_error: critical_error_message_box( translate('BiblesPlugin', 'No Book Found'), - translate('BiblesPlugin', 'No matching ' - 'book could be found in this Bible. Check that you ' - 'have spelled the name of the book correctly.')) + translate('BiblesPlugin', 'No matching book could be found in this Bible. Check that you have ' + 'spelled the name of the book correctly.')) return [] book = db_book.name if BibleDB.get_verse_count(self, book_id, reference[1]) == 0: @@ -742,13 +741,10 @@ def send_error_message(error_type): if error_type == u'download': critical_error_message_box( translate('BiblesPlugin.HTTPBible', 'Download Error'), - translate('BiblesPlugin.HTTPBible', 'There was a ' - 'problem downloading your verse selection. Please check your ' - 'Internet connection, and if this error continues to occur ' - 'please consider reporting a bug.')) + translate('BiblesPlugin.HTTPBible', 'There was a problem downloading your verse selection. Please check ' + 'your Internet connection, and if this error continues to occur please consider reporting a bug.')) elif error_type == u'parse': critical_error_message_box( translate('BiblesPlugin.HTTPBible', 'Parse Error'), - translate('BiblesPlugin.HTTPBible', 'There was a ' - 'problem extracting your verse selection. If this error continues ' - 'to occur please consider reporting a bug.')) + translate('BiblesPlugin.HTTPBible', 'There was a problem extracting your verse selection. If this error ' + 'continues to occur please consider reporting a bug.')) From 8dd068b9c1beece6dfcea22abad0c270901445cc Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sun, 30 Jun 2013 20:03:26 +0200 Subject: [PATCH 09/15] print func --- .../plugins/presentations/lib/pptviewlib/ppttest.py | 12 ++++++------ openlp/plugins/songs/lib/test/test_opensongimport.py | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/openlp/plugins/presentations/lib/pptviewlib/ppttest.py b/openlp/plugins/presentations/lib/pptviewlib/ppttest.py index c8573c807..f07468bb8 100644 --- a/openlp/plugins/presentations/lib/pptviewlib/ppttest.py +++ b/openlp/plugins/presentations/lib/pptviewlib/ppttest.py @@ -174,13 +174,13 @@ class PPTViewer(QtGui.QWidget): int(self.widthEdit.text()), int(self.heightEdit.text())) filename = str(self.pptEdit.text().replace(u'/', u'\\')) folder = str(self.folderEdit.text().replace(u'/', u'\\')) - print filename, folder + print(filename, folder) self.pptid = self.pptdll.OpenPPT(filename, None, rect, folder) - print u'id: ' + unicode(self.pptid) + print(u'id: ' + unicode(self.pptid)) if oldid >= 0: self.pptdll.ClosePPT(oldid); slides = self.pptdll.GetSlideCount(self.pptid) - print u'slidecount: ' + unicode(slides) + print(u'slidecount: ' + unicode(slides)) self.total.setNum(self.pptdll.GetSlideCount(self.pptid)) self.updateCurrSlide() @@ -188,14 +188,14 @@ class PPTViewer(QtGui.QWidget): if self.pptid < 0: return slide = unicode(self.pptdll.GetCurrentSlide(self.pptid)) - print u'currslide: ' + slide + print(u'currslide: ' + slide) self.slideEdit.setText(slide) app.processEvents() def gotoClick(self): if self.pptid < 0: return - print self.slideEdit.text() + print(self.slideEdit.text()) self.pptdll.GotoSlide(self.pptid, int(self.slideEdit.text())) self.updateCurrSlide() app.processEvents() @@ -207,7 +207,7 @@ class PPTViewer(QtGui.QWidget): if __name__ == '__main__': pptdll = cdll.LoadLibrary(r'pptviewlib.dll') pptdll.SetDebug(1) - print u'Begin...' + print(u'Begin...') app = QtGui.QApplication(sys.argv) window = PPTViewer() window.pptdll = pptdll diff --git a/openlp/plugins/songs/lib/test/test_opensongimport.py b/openlp/plugins/songs/lib/test/test_opensongimport.py index 8f09ea875..3d367a166 100644 --- a/openlp/plugins/songs/lib/test/test_opensongimport.py +++ b/openlp/plugins/songs/lib/test/test_opensongimport.py @@ -89,7 +89,7 @@ def test(): assert not [u'C3', u'Chorus 3'] in o.verses assert [u'V1', u'v1 Line 1\nV1 Line 2'] in o.verses assert [u'V2', u'v2 Line 1\nV2 Line 2'] in o.verses - print o.verse_order_list + print(o.verse_order_list) assert o.verse_order_list == [u'V1', u'C1', u'V2', u'C2', u'V3', u'B1', u'V1'] o.filenames = [u'test2.opensong'] @@ -101,14 +101,14 @@ def test(): assert o.title == u'Martins 2nd Test' assert o.alternate_title == u'' assert o.song_number == u'2' - print o.verses + print(o.verses) assert [u'B1', u'Bridge 1\nBridge 1 line 2'] in o.verses assert [u'C1', u'Chorus 1'] in o.verses assert [u'C2', u'Chorus 2'] in o.verses assert not [u'C3', u'Chorus 3'] in o.verses assert [u'V1', u'v1 Line 1\nV1 Line 2'] in o.verses assert [u'V2', u'v2 Line 1\nV2 Line 2'] in o.verses - print o.verse_order_list + print(o.verse_order_list) assert o.verse_order_list == [u'V1', u'V2', u'B1', u'C1', u'C2'] o.filenames = [u'test3.opensong'] @@ -122,10 +122,10 @@ def test(): assert o.ccli_number == u'123456' assert o.verse_order_list == [u'V1'] assert o.topics == [u'Worship: Declaration'] - print o.verses[0] + print(o.verses[0]) assert [u'V1', u'Line 1\nLine 2'] in o.verses - print "Tests passed" + print("Tests passed") if __name__ == "__main__": test() From aa2df0c5d1d9c5beacf5ff4384f1e3d137e01f06 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sun, 30 Jun 2013 20:08:50 +0200 Subject: [PATCH 10/15] removed test --- .../songs/lib/test/test_opensongimport.py | 131 ------------------ 1 file changed, 131 deletions(-) delete mode 100644 openlp/plugins/songs/lib/test/test_opensongimport.py diff --git a/openlp/plugins/songs/lib/test/test_opensongimport.py b/openlp/plugins/songs/lib/test/test_opensongimport.py deleted file mode 100644 index 3d367a166..000000000 --- a/openlp/plugins/songs/lib/test/test_opensongimport.py +++ /dev/null @@ -1,131 +0,0 @@ -# -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 - -############################################################################### -# OpenLP - Open Source Lyrics Projection # -# --------------------------------------------------------------------------- # -# Copyright (c) 2008-2013 Raoul Snyman # -# Portions copyright (c) 2008-2013 Tim Bentley, Gerald Britton, Jonathan # -# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, # -# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. # -# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, # -# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # -# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, # -# Frode Woldsund, Martin Zibricky, Patrick Zimmermann # -# --------------------------------------------------------------------------- # -# This program is free software; you can redistribute it and/or modify it # -# under the terms of the GNU General Public License as published by the Free # -# Software Foundation; version 2 of the License. # -# # -# This program is distributed in the hope that it will be useful, but WITHOUT # -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # -# more details. # -# # -# You should have received a copy of the GNU General Public License along # -# with this program; if not, write to the Free Software Foundation, Inc., 59 # -# Temple Place, Suite 330, Boston, MA 02111-1307 USA # -############################################################################### - -from openlp.plugins.songs.lib.opensongimport import OpenSongImport -from openlp.core.lib.db import Manager -from openlp.plugins.songs.lib.db import init_schema - -import logging -LOG_FILENAME = 'test.log' -logging.basicConfig(filename=LOG_FILENAME,level=logging.INFO) - -# Stubs to replace the UI functions for raw testing -class wizard_stub: - def __init__(self): - self.progressBar=progbar_stub() - def incrementProgressBar(self, str): - pass -class progbar_stub: - def __init__(self): - pass - def setMaximum(self, arg): - pass - -def test(): - manager = Manager(u'songs', init_schema) - o = OpenSongImport(manager, filenames=[u'test.opensong']) - o.import_wizard = wizard_stub() - o.commit = False - o.do_import() - o.print_song() - assert o.copyright == u'2010 Martin Thompson' - assert o.authors == [u'MartiÑ Thómpson', u'Martin2 Thómpson'] - assert o.title == u'Martins Test' - assert o.alternate_title == u'' - assert o.song_number == u'1' - assert [u'C1', u'Chorus 1'] in o.verses - assert [u'C2', u'Chorus 2'] in o.verses - assert not [u'C3', u'Chorus 3'] in o.verses - assert [u'B1', u'Bridge 1\nBridge 1 line 2'] in o.verses - assert [u'V1', u'v1 Line 1\nV1 Line 2'] in o.verses - assert [u'V2', u'v2 Line 1\nV2 Line 2'] in o.verses - assert [u'V3A', u'V3 Line 1\nV3 Line 2'] in o.verses - assert [u'RAP1', u'Rap 1 Line 1\nRap 1 Line 2'] in o.verses - assert [u'RAP2', u'Rap 2 Line 1\nRap 2 Line 2'] in o.verses - assert [u'RAP3', u'Rap 3 Line 1\nRap 3 Line 2'] in o.verses - assert [u'X1', u'Unreferenced verse line 1'] in o.verses - assert o.verse_order_list == [u'V1', u'C1', u'V2', u'C2', u'V3A', u'B1', u'V1', u'T1', u'RAP1', u'RAP2', u'RAP3'] - assert o.ccli_number == u'Blah' - assert o.topics == [u'TestTheme', u'TestAltTheme'] - - o.filenames = [u'test.opensong.zip'] - o.set_defaults() - o.do_import() - o.print_song() - assert o.copyright == u'2010 Martin Thompson' - assert o.authors == [u'MartiÑ Thómpson'] - assert o.title == u'Martins Test' - assert o.alternate_title == u'' - assert o.song_number == u'1' - assert [u'B1', u'Bridge 1\nBridge 1 line 2'] in o.verses - assert [u'C1', u'Chorus 1'] in o.verses - assert [u'C2', u'Chorus 2'] in o.verses - assert not [u'C3', u'Chorus 3'] in o.verses - assert [u'V1', u'v1 Line 1\nV1 Line 2'] in o.verses - assert [u'V2', u'v2 Line 1\nV2 Line 2'] in o.verses - print(o.verse_order_list) - assert o.verse_order_list == [u'V1', u'C1', u'V2', u'C2', u'V3', u'B1', u'V1'] - - o.filenames = [u'test2.opensong'] - o.set_defaults() - o.do_import() - o.print_song() - assert o.copyright == u'2010 Martin Thompson' - assert o.authors == [u'Martin Thompson'] - assert o.title == u'Martins 2nd Test' - assert o.alternate_title == u'' - assert o.song_number == u'2' - print(o.verses) - assert [u'B1', u'Bridge 1\nBridge 1 line 2'] in o.verses - assert [u'C1', u'Chorus 1'] in o.verses - assert [u'C2', u'Chorus 2'] in o.verses - assert not [u'C3', u'Chorus 3'] in o.verses - assert [u'V1', u'v1 Line 1\nV1 Line 2'] in o.verses - assert [u'V2', u'v2 Line 1\nV2 Line 2'] in o.verses - print(o.verse_order_list) - assert o.verse_order_list == [u'V1', u'V2', u'B1', u'C1', u'C2'] - - o.filenames = [u'test3.opensong'] - o.set_defaults() - o.do_import() - o.print_song() - assert o.copyright == u'2010' - assert o.authors == [u'Martin Thompson'] - assert o.title == u'Test single verse' - assert o.alternate_title == u'' - assert o.ccli_number == u'123456' - assert o.verse_order_list == [u'V1'] - assert o.topics == [u'Worship: Declaration'] - print(o.verses[0]) - assert [u'V1', u'Line 1\nLine 2'] in o.verses - - print("Tests passed") - -if __name__ == "__main__": - test() From 143ce0015f06f07e38db4d03d0b0f98389997975 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sun, 30 Jun 2013 20:33:41 +0200 Subject: [PATCH 11/15] added __hash__ methods --- openlp/core/lib/serviceitem.py | 6 ++++++ openlp/plugins/custom/lib/db.py | 9 +++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index b32e1aaf0..ee1a5c588 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -485,6 +485,12 @@ class ServiceItem(object): """ return self.unique_identifier != other.unique_identifier + def __hash__(self): + """ + Return the hash for the service item. + """ + return self.unique_identifier + def is_media(self): """ Confirms if the ServiceItem is media diff --git a/openlp/plugins/custom/lib/db.py b/openlp/plugins/custom/lib/db.py index 253ca5432..2f6eb5d6d 100644 --- a/openlp/plugins/custom/lib/db.py +++ b/openlp/plugins/custom/lib/db.py @@ -41,14 +41,19 @@ class CustomSlide(BaseModel): """ CustomSlide model """ - # By default sort the customs by its title considering language specific - # characters. + # By default sort the customs by its title considering language specific characters. def __lt__(self, other): return get_locale_key(self.title) < get_locale_key(other.title) def __eq__(self, other): return get_locale_key(self.title) == get_locale_key(other.title) + def __hash__(self): + """ + Return the hash for a custom slide. + """ + return self.id + def init_schema(url): """ From 1d571507dbc08edefd9390bfad13292cad8ace71 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 30 Jun 2013 19:36:52 +0100 Subject: [PATCH 12/15] remove import --- openlp/core/lib/formattingtags.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openlp/core/lib/formattingtags.py b/openlp/core/lib/formattingtags.py index be9cbe82e..1984b08ba 100644 --- a/openlp/core/lib/formattingtags.py +++ b/openlp/core/lib/formattingtags.py @@ -29,7 +29,6 @@ """ Provide HTML Tag management and Formatting Tag access class """ -import cPickle import json from openlp.core.lib import Settings, translate From 72933138a29b5e8c1ab8383f25e133740e8da793 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sun, 30 Jun 2013 20:37:12 +0200 Subject: [PATCH 13/15] clean up --- openlp/plugins/custom/forms/editcustomform.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/openlp/plugins/custom/forms/editcustomform.py b/openlp/plugins/custom/forms/editcustomform.py index 580fbde07..1009ea8d3 100644 --- a/openlp/plugins/custom/forms/editcustomform.py +++ b/openlp/plugins/custom/forms/editcustomform.py @@ -100,8 +100,7 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): self.credit_edit.setText(self.custom_slide.credits) custom_XML = CustomXMLParser(self.custom_slide.text) slide_list = custom_XML.get_verses() - for slide in slide_list: - self.slide_list_view.addItem(slide[1]) + self.slide_list_view.addItems([slide[1] for slide in slide_list]) theme = self.custom_slide.theme_name find_and_set_in_combo_box(self.theme_combo_box, theme) self.title_edit.setFocus() From f583be0c76725a0e7d2b884ab2108f52a672a066 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 30 Jun 2013 19:39:38 +0100 Subject: [PATCH 14/15] fix registry call --- openlp/core/ui/mainwindow.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index ffc0ebf16..c14a50d69 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -1066,7 +1066,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.live_controller.display = None if os.name == u'nt': # Needed for Windows to stop crashes on exit - Registry.remove(u'application') + Registry().remove(u'application') def service_changed(self, reset=False, serviceName=None): """ From d1bbc5e7576434803029e29bcdf7209075611cbe Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sun, 30 Jun 2013 21:23:26 +0200 Subject: [PATCH 15/15] empty commit, hoping that the 2.2.2 tag is deleted properly bzr-revno: 2265