From 221001b63321cff3a97cca2c2b1c1476b344e1a6 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 2 May 2013 09:21:03 +0200 Subject: [PATCH 01/51] updated vlc.py --- openlp/core/ui/media/vendor/vlc.py | 39 ++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/openlp/core/ui/media/vendor/vlc.py b/openlp/core/ui/media/vendor/vlc.py index f2cb3cad4..84d810bd5 100644 --- a/openlp/core/ui/media/vendor/vlc.py +++ b/openlp/core/ui/media/vendor/vlc.py @@ -48,7 +48,7 @@ import sys from inspect import getargspec __version__ = "N/A" -build_date = "Mon Apr 1 23:47:38 2013" +build_date = "Mon Apr 29 12:17:29 2013" if sys.version_info[0] > 2: str = str @@ -3351,6 +3351,39 @@ def libvlc_event_type_name(event_type): ctypes.c_char_p, ctypes.c_uint) return f(event_type) +def libvlc_log_get_context(ctx): + '''Gets debugging informations about a log message: the name of the VLC module + emitting the message and the message location within the source code. + The returned module name and file name will be NULL if unknown. + The returned line number will similarly be zero if unknown. + @param ctx: message context (as passed to the @ref libvlc_log_cb callback). + @return: module module name storage (or NULL), file source code file name storage (or NULL), line source code file line number storage (or NULL). + @version: LibVLC 2.1.0 or later. + ''' + f = _Cfunctions.get('libvlc_log_get_context', None) or \ + _Cfunction('libvlc_log_get_context', ((1,), (2,), (2,), (2,),), None, + None, Log_ptr, ListPOINTER(ctypes.c_char_p), ListPOINTER(ctypes.c_char_p), ctypes.POINTER(ctypes.c_uint)) + return f(ctx) + +def libvlc_log_get_object(ctx, id): + '''Gets VLC object informations about a log message: the type name of the VLC + object emitting the message, the object header if any and a temporaly-unique + object identifier. These informations are mainly meant for B{manual} + troubleshooting. + The returned type name may be "generic" if unknown, but it cannot be NULL. + The returned header will be NULL if unset; in current versions, the header + is used to distinguish for VLM inputs. + The returned object ID will be zero if the message is not associated with + any VLC object. + @param ctx: message context (as passed to the @ref libvlc_log_cb callback). + @return: name object name storage (or NULL), header object header (or NULL), line source code file line number storage (or NULL). + @version: LibVLC 2.1.0 or later. + ''' + f = _Cfunctions.get('libvlc_log_get_object', None) or \ + _Cfunction('libvlc_log_get_object', ((1,), (2,), (2,), (1,),), None, + None, Log_ptr, ListPOINTER(ctypes.c_char_p), ListPOINTER(ctypes.c_char_p), ctypes.POINTER(ctypes.c_uint)) + return f(ctx, id) + def libvlc_log_unset(p_instance): '''Unsets the logging callback for a LibVLC instance. This is rarely needed: the callback is implicitly unset when the instance is destroyed. @@ -5827,7 +5860,7 @@ def libvlc_vlm_get_event_manager(p_instance): # libvlc_printerr # libvlc_set_exit_handler -# 15 function(s) not wrapped as methods: +# 17 function(s) not wrapped as methods: # libvlc_audio_output_device_list_release # libvlc_audio_output_list_release # libvlc_clearerr @@ -5838,6 +5871,8 @@ def libvlc_vlm_get_event_manager(p_instance): # libvlc_get_changeset # libvlc_get_compiler # libvlc_get_version +# libvlc_log_get_context +# libvlc_log_get_object # libvlc_media_tracks_release # libvlc_module_description_list_release # libvlc_new From 3d738616f84f7853f11d2d3d675d4669e65d14f2 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 3 Jul 2013 19:20:23 +0200 Subject: [PATCH 02/51] updated from MASTER --- openlp/core/ui/media/vendor/vlc.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/openlp/core/ui/media/vendor/vlc.py b/openlp/core/ui/media/vendor/vlc.py index 84d810bd5..0326e4104 100644 --- a/openlp/core/ui/media/vendor/vlc.py +++ b/openlp/core/ui/media/vendor/vlc.py @@ -48,7 +48,7 @@ import sys from inspect import getargspec __version__ = "N/A" -build_date = "Mon Apr 29 12:17:29 2013" +build_date = "Tue Jul 2 10:35:53 2013" if sys.version_info[0] > 2: str = str @@ -327,6 +327,9 @@ class _Enum(ctypes.c_uint): n = self._enum_names_.get(self.value, '') or ('FIXME_(%r)' % (self.value,)) return '.'.join((self.__class__.__name__, n)) + def __hash__(self): + return self.value + def __repr__(self): return '.'.join((self.__class__.__module__, self.__str__())) From 79263bfea4e46d9717df4fb59669956f299cf011 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Tue, 18 Mar 2014 22:33:05 +0200 Subject: [PATCH 03/51] Try to fix bug #1136278 by detecting if the upgrade has already been run Fixes: https://launchpad.net/bugs/1136278 --- openlp/plugins/bibles/lib/upgrade.py | 138 +----------------------- openlp/plugins/songs/lib/upgrade.py | 46 +++++--- openlp/plugins/songusage/lib/upgrade.py | 18 +++- 3 files changed, 46 insertions(+), 156 deletions(-) diff --git a/openlp/plugins/bibles/lib/upgrade.py b/openlp/plugins/bibles/lib/upgrade.py index 3e58686d1..bf1caf025 100644 --- a/openlp/plugins/bibles/lib/upgrade.py +++ b/openlp/plugins/bibles/lib/upgrade.py @@ -31,10 +31,8 @@ The :mod:`upgrade` module provides a way for the database and schema that is the """ import logging -from sqlalchemy import Table, func, select, insert - -__version__ = 1 log = logging.getLogger(__name__) +__version__ = 1 def upgrade_1(session, metadata): @@ -43,136 +41,4 @@ def upgrade_1(session, metadata): This upgrade renames a number of keys to a single naming convention. """ - metadata_table = Table('metadata', metadata, autoload=True) - # Copy "Version" to "name" ("version" used by upgrade system) - # TODO: Clean up in a subsequent release of OpenLP (like 2.0 final) - session.execute(insert(metadata_table).values( - key='name', - value=select( - [metadata_table.c.value], - metadata_table.c.key == 'Version' - ).as_scalar() - )) - # Copy "Copyright" to "copyright" - # TODO: Clean up in a subsequent release of OpenLP (like 2.0 final) - session.execute(insert(metadata_table).values( - key='copyright', - value=select( - [metadata_table.c.value], - metadata_table.c.key == 'Copyright' - ).as_scalar() - )) - # Copy "Permissions" to "permissions" - # TODO: Clean up in a subsequent release of OpenLP (like 2.0 final) - session.execute(insert(metadata_table).values( - key='permissions', - value=select( - [metadata_table.c.value], - metadata_table.c.key == 'Permissions' - ).as_scalar() - )) - # Copy "Bookname language" to "book_name_language" - # TODO: Clean up in a subsequent release of OpenLP (like 2.0 final) - value_count = session.execute( - select( - [func.count(metadata_table.c.value)], - metadata_table.c.key == 'Bookname language' - ) - ).scalar() - if value_count > 0: - session.execute(insert(metadata_table).values( - key='book_name_language', - value=select( - [metadata_table.c.value], - metadata_table.c.key == 'Bookname language' - ).as_scalar() - )) - # Copy "download source" to "download_source" - # TODO: Clean up in a subsequent release of OpenLP (like 2.0 final) - value_count = session.execute( - select( - [func.count(metadata_table.c.value)], - metadata_table.c.key == 'download source' - ) - ).scalar() - log.debug('download source: %s', value_count) - if value_count > 0: - session.execute(insert(metadata_table).values( - key='download_source', - value=select( - [metadata_table.c.value], - metadata_table.c.key == 'download source' - ).as_scalar() - )) - # Copy "download name" to "download_name" - # TODO: Clean up in a subsequent release of OpenLP (like 2.0 final) - value_count = session.execute( - select( - [func.count(metadata_table.c.value)], - metadata_table.c.key == 'download name' - ) - ).scalar() - log.debug('download name: %s', value_count) - if value_count > 0: - session.execute(insert(metadata_table).values( - key='download_name', - value=select( - [metadata_table.c.value], - metadata_table.c.key == 'download name' - ).as_scalar() - )) - # Copy "proxy server" to "proxy_server" - # TODO: Clean up in a subsequent release of OpenLP (like 2.0 final) - value_count = session.execute( - select( - [func.count(metadata_table.c.value)], - metadata_table.c.key == 'proxy server' - ) - ).scalar() - log.debug('proxy server: %s', value_count) - if value_count > 0: - session.execute(insert(metadata_table).values( - key='proxy_server', - value=select( - [metadata_table.c.value], - metadata_table.c.key == 'proxy server' - ).as_scalar() - )) - # Copy "proxy username" to "proxy_username" - # TODO: Clean up in a subsequent release of OpenLP (like 2.0 final) - value_count = session.execute( - select( - [func.count(metadata_table.c.value)], - metadata_table.c.key == 'proxy username' - ) - ).scalar() - log.debug('proxy username: %s', value_count) - if value_count > 0: - session.execute(insert(metadata_table).values( - key='proxy_username', - value=select( - [metadata_table.c.value], - metadata_table.c.key == 'proxy username' - ).as_scalar() - )) - # Copy "proxy password" to "proxy_password" - # TODO: Clean up in a subsequent release of OpenLP (like 2.0 final) - value_count = session.execute( - select( - [func.count(metadata_table.c.value)], - metadata_table.c.key == 'proxy password' - ) - ).scalar() - log.debug('proxy password: %s', value_count) - if value_count > 0: - session.execute(insert(metadata_table).values( - key='proxy_password', - value=select( - [metadata_table.c.value], - metadata_table.c.key == 'proxy password' - ).as_scalar() - )) - # TODO: Clean up in a subsequent release of OpenLP (like 2.0 final) - #session.execute(delete(metadata_table)\ - # .where(metadata_table.c.key == u'dbversion')) - session.commit() + log.info('No upgrades to perform') diff --git a/openlp/plugins/songs/lib/upgrade.py b/openlp/plugins/songs/lib/upgrade.py index ee01fb8b0..adb7d8af5 100644 --- a/openlp/plugins/songs/lib/upgrade.py +++ b/openlp/plugins/songs/lib/upgrade.py @@ -30,12 +30,15 @@ The :mod:`upgrade` module provides a way for the database and schema that is the backend for the Songs plugin """ +import logging from sqlalchemy import Column, types +from sqlalchemy.exc import OperationalError from sqlalchemy.sql.expression import func, false, null, text from openlp.core.lib.db import get_upgrade_op +log = logging.getLogger(__name__) __version__ = 3 @@ -50,14 +53,20 @@ def upgrade_1(session, metadata): In order to facilitate this one-to-many relationship, a song_id column is added to the media_files table, and a weight column so that the media files can be ordered. + + :param session: + :param metadata: """ - op = get_upgrade_op(session) - op.drop_table('media_files_songs') - op.add_column('media_files', Column('song_id', types.Integer(), server_default=null())) - op.add_column('media_files', Column('weight', types.Integer(), server_default=text('0'))) - if metadata.bind.url.get_dialect().name != 'sqlite': - # SQLite doesn't support ALTER TABLE ADD CONSTRAINT - op.create_foreign_key('fk_media_files_song_id', 'media_files', 'songs', ['song_id', 'id']) + try: + op = get_upgrade_op(session) + op.drop_table('media_files_songs') + op.add_column('media_files', Column('song_id', types.Integer(), server_default=null())) + op.add_column('media_files', Column('weight', types.Integer(), server_default=text('0'))) + if metadata.bind.url.get_dialect().name != 'sqlite': + # SQLite doesn't support ALTER TABLE ADD CONSTRAINT + op.create_foreign_key('fk_media_files_song_id', 'media_files', 'songs', ['song_id', 'id']) + except OperationalError: + log.info('Upgrade 1 has already been run') def upgrade_2(session, metadata): @@ -66,9 +75,12 @@ def upgrade_2(session, metadata): This upgrade adds a create_date and last_modified date to the songs table """ - op = get_upgrade_op(session) - op.add_column('songs', Column('create_date', types.DateTime(), default=func.now())) - op.add_column('songs', Column('last_modified', types.DateTime(), default=func.now())) + try: + op = get_upgrade_op(session) + op.add_column('songs', Column('create_date', types.DateTime(), default=func.now())) + op.add_column('songs', Column('last_modified', types.DateTime(), default=func.now())) + except OperationalError: + log.info('Upgrade 2 has already been run') def upgrade_3(session, metadata): @@ -77,9 +89,11 @@ def upgrade_3(session, metadata): This upgrade adds a temporary song flag to the songs table """ - op = get_upgrade_op(session) - if metadata.bind.url.get_dialect().name == 'sqlite': - op.add_column('songs', Column('temporary', types.Boolean(create_constraint=False), server_default=false())) - else: - op.add_column('songs', Column('temporary', types.Boolean(), server_default=false())) - + try: + op = get_upgrade_op(session) + if metadata.bind.url.get_dialect().name == 'sqlite': + op.add_column('songs', Column('temporary', types.Boolean(create_constraint=False), server_default=false())) + else: + op.add_column('songs', Column('temporary', types.Boolean(), server_default=false())) + except OperationalError: + log.info('Upgrade 3 has already been run') diff --git a/openlp/plugins/songusage/lib/upgrade.py b/openlp/plugins/songusage/lib/upgrade.py index 08096423d..24f264824 100644 --- a/openlp/plugins/songusage/lib/upgrade.py +++ b/openlp/plugins/songusage/lib/upgrade.py @@ -30,10 +30,14 @@ The :mod:`upgrade` module provides a way for the database and schema that is the backend for the SongsUsage plugin """ -from openlp.core.lib.db import get_upgrade_op +import logging +from sqlalchemy.exc import OperationalError from sqlalchemy import Column, types +from openlp.core.lib.db import get_upgrade_op + +log = logging.getLogger(__name__) __version__ = 1 @@ -42,7 +46,13 @@ def upgrade_1(session, metadata): Version 1 upgrade. This upgrade adds two new fields to the songusage database + + :param session: SQLAlchemy Session object + :param metadata: SQLAlchemy MetaData object """ - op = get_upgrade_op(session) - op.add_column('songusage_data', Column('plugin_name', types.Unicode(20), server_default='')) - op.add_column('songusage_data', Column('source', types.Unicode(10), server_default='')) + try: + op = get_upgrade_op(session) + op.add_column('songusage_data', Column('plugin_name', types.Unicode(20), server_default='')) + op.add_column('songusage_data', Column('source', types.Unicode(10), server_default='')) + except OperationalError: + log.info('Upgrade 1 has already taken place') From 35e3564655ba8daa80f7d6df74d3bc3a783b2e6b Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Tue, 18 Mar 2014 23:03:53 +0200 Subject: [PATCH 04/51] Tests! --- openlp/core/lib/db.py | 10 ++--- tests/functional/openlp_core_lib/test_db.py | 44 ++++++++++++++++++++- 2 files changed, 48 insertions(+), 6 deletions(-) diff --git a/openlp/core/lib/db.py b/openlp/core/lib/db.py index 36bfa24ef..d43938afe 100644 --- a/openlp/core/lib/db.py +++ b/openlp/core/lib/db.py @@ -93,10 +93,11 @@ def upgrade_db(url, upgrade): """ pass - metadata_table = Table('metadata', metadata, - Column('key', types.Unicode(64), primary_key=True), - Column('value', types.UnicodeText(), default=None) - ) + metadata_table = Table( + 'metadata', metadata, + Column('key', types.Unicode(64), primary_key=True), + Column('value', types.UnicodeText(), default=None) + ) metadata_table.create(checkfirst=True) mapper(Metadata, metadata_table) version_meta = session.query(Metadata).get('version') @@ -137,7 +138,6 @@ def delete_database(plugin_name, db_file_name=None): :param plugin_name: The name of the plugin to remove the database for :param db_file_name: The database file name. Defaults to None resulting in the plugin_name being used. """ - db_file_path = None if db_file_name: db_file_path = os.path.join(AppLocation.get_section_data_path(plugin_name), db_file_name) else: diff --git a/tests/functional/openlp_core_lib/test_db.py b/tests/functional/openlp_core_lib/test_db.py index 8a2f21ec3..470bd0636 100644 --- a/tests/functional/openlp_core_lib/test_db.py +++ b/tests/functional/openlp_core_lib/test_db.py @@ -29,13 +29,14 @@ """ Package to test the openlp.core.lib package. """ +import os from unittest import TestCase from sqlalchemy.pool import NullPool from sqlalchemy.orm.scoping import ScopedSession from sqlalchemy import MetaData -from openlp.core.lib.db import init_db, get_upgrade_op +from openlp.core.lib.db import init_db, get_upgrade_op, delete_database from tests.functional import patch, MagicMock @@ -110,3 +111,44 @@ class TestDB(TestCase): mocked_session.bind.connect.assert_called_with() MockedMigrationContext.configure.assert_called_with(mocked_connection) MockedOperations.assert_called_with(mocked_context) + + def delete_database_without_db_file_name_test(self): + """ + Test that the ``delete_database`` function removes a database file, without the file name parameter + """ + # GIVEN: Mocked out AppLocation class and delete_file method, a test plugin name and a db location + with patch('openlp.core.lib.db.AppLocation') as MockedAppLocation, \ + patch('openlp.core.lib.db.delete_file') as mocked_delete_file: + MockedAppLocation.get_section_data_path.return_value = 'test-dir' + mocked_delete_file.return_value = True + test_plugin = 'test' + test_location = os.path.join('test-dir', test_plugin) + + # WHEN: delete_database is run without a database file + result = delete_database(test_plugin) + + # THEN: The AppLocation.get_section_data_path and delete_file methods should have been called + MockedAppLocation.get_section_data_path.assert_called_with(test_plugin) + mocked_delete_file.assert_called_with(test_location) + self.assertTrue(result, 'The result of delete_file should be True (was rigged that way)') + + def delete_database_with_db_file_name_test(self): + """ + Test that the ``delete_database`` function removes a database file, with the file name supplied + """ + # GIVEN: Mocked out AppLocation class and delete_file method, a test plugin name and a db location + with patch('openlp.core.lib.db.AppLocation') as MockedAppLocation, \ + patch('openlp.core.lib.db.delete_file') as mocked_delete_file: + MockedAppLocation.get_section_data_path.return_value = 'test-dir' + mocked_delete_file.return_value = False + test_plugin = 'test' + test_db_file = 'mydb.sqlite' + test_location = os.path.join('test-dir', test_db_file) + + # WHEN: delete_database is run without a database file + result = delete_database(test_plugin, test_db_file) + + # THEN: The AppLocation.get_section_data_path and delete_file methods should have been called + MockedAppLocation.get_section_data_path.assert_called_with(test_plugin) + mocked_delete_file.assert_called_with(test_location) + self.assertFalse(result, 'The result of delete_file should be False (was rigged that way)') From 5d9533947d5c35b406bf261f19786f43336f94ee Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Thu, 20 Mar 2014 19:10:31 +0000 Subject: [PATCH 05/51] Final set of PEP8 cleanups --- openlp/core/common/applocation.py | 2 +- openlp/core/common/openlpmixin.py | 2 +- openlp/core/common/registryproperties.py | 2 +- openlp/core/common/uistrings.py | 7 +- openlp/core/lib/filedialog.py | 2 +- openlp/core/lib/htmlbuilder.py | 14 +- openlp/core/lib/imagemanager.py | 4 +- openlp/core/lib/plugin.py | 2 +- openlp/core/lib/searchedit.py | 5 +- openlp/core/ui/aboutdialog.py | 1080 ++++++++++----------- openlp/core/ui/advancedtab.py | 23 +- openlp/core/ui/exceptiondialog.py | 5 +- openlp/core/ui/exceptionform.py | 18 +- openlp/core/ui/filerenameform.py | 2 +- openlp/core/ui/firsttimeform.py | 2 +- openlp/core/ui/formattingtagcontroller.py | 2 +- openlp/core/ui/formattingtagdialog.py | 3 +- openlp/core/ui/formattingtagform.py | 1 - openlp/core/ui/generaltab.py | 3 +- openlp/core/ui/listpreviewwidget.py | 2 +- openlp/core/ui/maindisplay.py | 1 - openlp/core/ui/mainwindow.py | 19 +- openlp/core/ui/media/mediacontroller.py | 12 +- openlp/core/ui/media/mediaplayer.py | 2 +- openlp/core/ui/media/phononplayer.py | 2 +- openlp/core/ui/media/vlcplayer.py | 2 +- openlp/core/ui/pluginform.py | 2 +- openlp/core/ui/printserviceform.py | 2 +- openlp/core/ui/servicemanager.py | 18 +- openlp/core/ui/servicenoteform.py | 2 +- openlp/core/ui/settingsform.py | 2 +- openlp/core/ui/shortcutlistform.py | 2 +- openlp/core/ui/slidecontroller.py | 35 +- openlp/core/ui/starttimeform.py | 6 +- openlp/core/ui/themeform.py | 4 +- openlp/core/ui/thememanager.py | 4 +- openlp/core/ui/themewizard.py | 19 +- openlp/core/ui/wizard.py | 2 +- openlp/core/utils/__init__.py | 19 +- openlp/core/utils/actions.py | 4 +- openlp/core/utils/languagemanager.py | 5 +- 41 files changed, 675 insertions(+), 670 deletions(-) diff --git a/openlp/core/common/applocation.py b/openlp/core/common/applocation.py index 7f2416676..1fce25000 100644 --- a/openlp/core/common/applocation.py +++ b/openlp/core/common/applocation.py @@ -76,7 +76,7 @@ class AppLocation(object): elif dir_type == AppLocation.PluginsDir: app_path = os.path.abspath(os.path.split(sys.argv[0])[0]) return get_frozen_path(os.path.join(app_path, 'plugins'), - os.path.join(os.path.split(openlp.__file__)[0], 'plugins')) + os.path.join(os.path.split(openlp.__file__)[0], 'plugins')) elif dir_type == AppLocation.VersionDir: return get_frozen_path(os.path.abspath(os.path.split(sys.argv[0])[0]), os.path.split(openlp.__file__)[0]) elif dir_type == AppLocation.LanguageDir: diff --git a/openlp/core/common/openlpmixin.py b/openlp/core/common/openlpmixin.py index 9e7b43539..1c7fe7d5a 100644 --- a/openlp/core/common/openlpmixin.py +++ b/openlp/core/common/openlpmixin.py @@ -91,4 +91,4 @@ class OpenLPMixin(object): Common log exception handler which prints the calling path """ trace_error_handler(self.logger) - self.logger.exception(message) \ No newline at end of file + self.logger.exception(message) diff --git a/openlp/core/common/registryproperties.py b/openlp/core/common/registryproperties.py index 663513c29..791fc33f7 100644 --- a/openlp/core/common/registryproperties.py +++ b/openlp/core/common/registryproperties.py @@ -149,4 +149,4 @@ class RegistryProperties(object): """ if not hasattr(self, '_alerts_manager') or not self._alerts_manager: self._alerts_manager = Registry().get('alerts_manager') - return self._alerts_manager \ No newline at end of file + return self._alerts_manager diff --git a/openlp/core/common/uistrings.py b/openlp/core/common/uistrings.py index 6bb44150c..3fe1485ba 100644 --- a/openlp/core/common/uistrings.py +++ b/openlp/core/common/uistrings.py @@ -73,8 +73,9 @@ class UiStrings(object): self.Default = translate('OpenLP.Ui', 'Default') self.DefaultColor = translate('OpenLP.Ui', 'Default Color:') self.DefaultServiceName = translate('OpenLP.Ui', 'Service %Y-%m-%d %H-%M', - 'This may not contain any of the following characters: /\\?*|<>\[\]":+\n' - 'See http://docs.python.org/library/datetime.html#strftime-strptime-behavior for more information.') + 'This may not contain any of the following characters: /\\?*|<>\[\]":+\n' + 'See http://docs.python.org/library/datetime' + '.html#strftime-strptime-behavior for more information.') self.Delete = translate('OpenLP.Ui', '&Delete') self.DisplayStyle = translate('OpenLP.Ui', 'Display style:') self.Duplicate = translate('OpenLP.Ui', 'Duplicate Error') @@ -132,7 +133,7 @@ class UiStrings(object): self.Service = translate('OpenLP.Ui', 'Service') self.Split = translate('OpenLP.Ui', 'Optional &Split') self.SplitToolTip = translate('OpenLP.Ui', - 'Split a slide into two only if it does not fit on the screen as one slide.') + 'Split a slide into two only if it does not fit on the screen as one slide.') self.StartTimeCode = translate('OpenLP.Ui', 'Start %s') self.StopPlaySlidesInLoop = translate('OpenLP.Ui', 'Stop Play Slides in Loop') self.StopPlaySlidesToEnd = translate('OpenLP.Ui', 'Stop Play Slides to End') diff --git a/openlp/core/lib/filedialog.py b/openlp/core/lib/filedialog.py index 989bafa6b..5bf012ee5 100644 --- a/openlp/core/lib/filedialog.py +++ b/openlp/core/lib/filedialog.py @@ -63,4 +63,4 @@ class FileDialog(QtGui.QFileDialog): UiStrings().FileNotFoundMessage % file) continue file_list.append(file) - return file_list \ No newline at end of file + return file_list diff --git a/openlp/core/lib/htmlbuilder.py b/openlp/core/lib/htmlbuilder.py index 7f6ab67b7..473aa9d7d 100644 --- a/openlp/core/lib/htmlbuilder.py +++ b/openlp/core/lib/htmlbuilder.py @@ -117,7 +117,9 @@ is the function which has to be called from outside. The generated and returned display: table-cell; word-wrap: break-word; -webkit-transition: opacity 0.4s ease; - white-space:pre-wrap; word-wrap: break-word; text-align: left; vertical-align: top; font-family: Nimbus Sans L; font-size: 40pt; color: #FFFFFF; line-height: 100%; margin: 0;padding: 0; padding-bottom: 0; padding-left: 4px; width: 1580px; height: 810px; + white-space:pre-wrap; word-wrap: break-word; text-align: left; vertical-align: top; font-family: Nimbus + Sans L; font-size: 40pt; color: #FFFFFF; line-height: 100%; margin: 0;padding: 0; padding-bottom: 0; + padding-left: 4px; width: 1580px; height: 810px; } .lyricsmain { -webkit-text-stroke: 0.125em #000000; -webkit-text-fill-color: #FFFFFF; text-shadow: #000000 5px 5px; @@ -720,12 +722,12 @@ def build_lyrics_format_css(theme_data, width, height): else: padding_bottom = '0' lyrics = '%s word-wrap: break-word; ' \ - 'text-align: %s; vertical-align: %s; font-family: %s; ' \ - 'font-size: %spt; color: %s; line-height: %d%%; margin: 0;' \ - 'padding: 0; padding-bottom: %s; padding-left: %spx; width: %spx; height: %spx; ' % \ + 'text-align: %s; vertical-align: %s; font-family: %s; ' \ + 'font-size: %spt; color: %s; line-height: %d%%; margin: 0;' \ + 'padding: 0; padding-bottom: %s; padding-left: %spx; width: %spx; height: %spx; ' % \ (justify, align, valign, theme_data.font_main_name, theme_data.font_main_size, - theme_data.font_main_color, 100 + int(theme_data.font_main_line_adjustment), padding_bottom, - left_margin, width, height) + theme_data.font_main_color, 100 + int(theme_data.font_main_line_adjustment), padding_bottom, + left_margin, width, height) if theme_data.font_main_italics: lyrics += 'font-style:italic; ' if theme_data.font_main_bold: diff --git a/openlp/core/lib/imagemanager.py b/openlp/core/lib/imagemanager.py index a22de4140..cba393815 100644 --- a/openlp/core/lib/imagemanager.py +++ b/openlp/core/lib/imagemanager.py @@ -113,8 +113,8 @@ class Image(object): :param path: The image's file path. This should be an existing file path. :param source: The source describes the image's origin. Possible values are described in the :class:`~openlp.core.lib.ImageSource` class. - :param background: A ``QtGui.QColor`` object specifying the colour to be used to fill the gabs if the image's ratio does not - match with the display ratio. + :param background: A ``QtGui.QColor`` object specifying the colour to be used to fill the gabs if the image's + ratio does not match with the display ratio. """ self.path = path diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index cafc24d9b..e14fe8bb0 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -393,4 +393,4 @@ class Plugin(QtCore.QObject, RegistryProperties): """ The plugin's needs to handle a new song creation """ - pass \ No newline at end of file + pass diff --git a/openlp/core/lib/searchedit.py b/openlp/core/lib/searchedit.py index d6eaafa7d..bb510d046 100644 --- a/openlp/core/lib/searchedit.py +++ b/openlp/core/lib/searchedit.py @@ -120,9 +120,8 @@ class SearchEdit(QtGui.QLineEdit): A list of tuples to be used in the search type menu. The first item in the list will be preselected as the default. - :param items: The list of tuples to use. The tuples should contain an integer identifier, an icon (QIcon instance or - - string) and a title for the item in the menu. In short, they should look like this:: + :param items: The list of tuples to use. The tuples should contain an integer identifier, an icon (QIcon + instance or string) and a title for the item in the menu. In short, they should look like this:: (, , , <place holder text>) diff --git a/openlp/core/ui/aboutdialog.py b/openlp/core/ui/aboutdialog.py index 21343f039..276a073bb 100644 --- a/openlp/core/ui/aboutdialog.py +++ b/openlp/core/ui/aboutdialog.py @@ -92,578 +92,574 @@ class Ui_AboutDialog(object): Dynamically translate the UI. """ about_dialog.setWindowTitle('%s OpenLP' % UiStrings().About) - self.about_text_edit.setPlainText(translate('OpenLP.AboutForm', - 'OpenLP <version><revision> - Open Source Lyrics ' - 'Projection\n' - '\n' - 'OpenLP is free church presentation software, or lyrics ' - 'projection software, used to display slides of songs, Bible ' - 'verses, videos, images, and even presentations (if ' - 'Impress, PowerPoint or PowerPoint Viewer is installed) ' - 'for church worship using a computer and a data projector.\n' - '\n' - 'Find out more about OpenLP: http://openlp.org/\n' - '\n' - 'OpenLP is written and maintained by volunteers. If you would ' - 'like to see more free Christian software being written, please ' - 'consider volunteering by using the button below.' - )) + self.about_text_edit.setPlainText( + translate('OpenLP.AboutForm', + 'OpenLP <version><revision> - Open Source Lyrics Projection\n' + '\n' + 'OpenLP is free church presentation software, or lyrics ' + 'projection software, used to display slides of songs, Bible ' + 'verses, videos, images, and even presentations (if ' + 'Impress, PowerPoint or PowerPoint Viewer is installed) ' + 'for church worship using a computer and a data projector.\n' + '\n' + 'Find out more about OpenLP: http://openlp.org/\n' + '\n' + 'OpenLP is written and maintained by volunteers. If you would ' + 'like to see more free Christian software being written, please ' + 'consider volunteering by using the button below.')) self.about_notebook.setTabText(self.about_notebook.indexOf(self.about_tab), UiStrings().About) lead = 'Raoul "superfly" Snyman' developers = ['Tim "TRB143" Bentley', 'Jonathan "gushie" Corwin', - 'Michael "cocooncrash" Gorven', - 'Andreas "googol" Preikschat', 'Raoul "superfly" Snyman', - 'Martin "mijiti" Thompson', 'Jon "Meths" Tibble'] + 'Michael "cocooncrash" Gorven', + 'Andreas "googol" Preikschat', 'Raoul "superfly" Snyman', + 'Martin "mijiti" Thompson', 'Jon "Meths" Tibble'] contributors = ['Gerald "jerryb" Britton', - 'Samuel "MrGamgee" Findlay', 'Scott "sguerrieri" Guerrieri', - 'Matthias "matthub" Hub', 'Meinert "m2j" Jordan', - 'Armin "orangeshirt" K\xf6hler', 'Erik "luen" Lundin', - 'Edwin "edwinlunando" Lunando', 'Brian "brianmeyer" Meyer', - 'Joshua "milleja46" Miller', 'Stevan "ElderP" Pettit', - 'Mattias "mahfiaz" P\xf5ldaru', 'Christian "crichter" Richter', - 'Philip "Phill" Ridout', 'Simon "samscudder" Scudder', - 'Jeffrey "whydoubt" Smith', 'Maikel Stuivenberg', - 'Dave "Dave42W" Warnock', 'Frode "frodus" Woldsund', - 'Martin "matysek" Zibricky', 'Patrick "mohij" Zimmermann'] + 'Samuel "MrGamgee" Findlay', 'Scott "sguerrieri" Guerrieri', + 'Matthias "matthub" Hub', 'Meinert "m2j" Jordan', + 'Armin "orangeshirt" K\xf6hler', 'Erik "luen" Lundin', + 'Edwin "edwinlunando" Lunando', 'Brian "brianmeyer" Meyer', + 'Joshua "milleja46" Miller', 'Stevan "ElderP" Pettit', + 'Mattias "mahfiaz" P\xf5ldaru', 'Christian "crichter" Richter', + 'Philip "Phill" Ridout', 'Simon "samscudder" Scudder', + 'Jeffrey "whydoubt" Smith', 'Maikel Stuivenberg', + 'Dave "Dave42W" Warnock', 'Frode "frodus" Woldsund', + 'Martin "matysek" Zibricky', 'Patrick "mohij" Zimmermann'] testers = ['Philip "Phill" Ridout', 'Wesley "wrst" Stout', - 'John "jseagull1" Cegalis (lead)'] + 'John "jseagull1" Cegalis (lead)'] packagers = ['Thomas "tabthorpe" Abthorpe (FreeBSD)', - 'Tim "TRB143" Bentley (Fedora and Android)', - 'Matthias "matthub" Hub (Mac OS X)', - 'Joseph "jdmulloy" Mulloy (openSUSE)', - 'Stevan "ElderP" Pettit (Windows)', - 'Raoul "superfly" Snyman (Debian, Ubuntu)', - 'Garrett "floft" Wilson (Arch Linux)'] + 'Tim "TRB143" Bentley (Fedora and Android)', + 'Matthias "matthub" Hub (Mac OS X)', + 'Joseph "jdmulloy" Mulloy (openSUSE)', + 'Stevan "ElderP" Pettit (Windows)', + 'Raoul "superfly" Snyman (Debian, Ubuntu)', + 'Garrett "floft" Wilson (Arch Linux)'] translators = { 'af': ['Johan "nuvolari" Mynhardt'], 'cs': ['Martin "matysek" Zibricky'], 'da': ['Henrik "Hsonesson" Sonesson'], - 'de': ['Patrick "madmuffin" Br\xfcckner', - 'Meinert "m2j" Jordan', 'Andreas "googol" Preikschat', - 'Christian "crichter" Richter'], + 'de': ['Patrick "madmuffin" Br\xfcckner', 'Meinert "m2j" Jordan', 'Andreas "googol" Preikschat', + 'Christian "crichter" Richter'], 'en_GB': ['Tim "TRB143" Bentley', 'Jonathan "gushie" Corwin'], - 'en_ZA': ['Raoul "superfly" Snyman', - 'Johan "nuvolari" Mynhardt'], + 'en_ZA': ['Raoul "superfly" Snyman', 'Johan "nuvolari" Mynhardt'], 'el': ['Alexander Siozos'], 'es': ['Josu\xe9 Z\xfa\xf1iga', 'Christian Gonzalez'], 'et': ['Mattias "mahfiaz" P\xf5ldaru'], 'fi': ['Jori "joribu" Brander', 'Tobbe "tobbeb" Bildo'], - 'fr': ['Stephan\xe9 "stbrunner" Brunner', 'Jeremie "jnau05"', - 'Carl "carl.fischer" Fischer'], + 'fr': ['Stephan\xe9 "stbrunner" Brunner', 'Jeremie "jnau05"', 'Carl "carl.fischer" Fischer'], 'hu': ['Gyuris Gell\xe9rt'], 'id': ['Mico "bangmico" Siahaan', ' ign_christian'], 'ja': ['Kunio "Kunio" Nakamaru', 'Chris Haris'], 'nb': ['Atle "pendlaren" Weibell', 'Frode "frodus" Woldsund'], 'nl': ['Arjen "typovar" van Voorst'], - 'pt_BR': ['David Mederiros', 'Rafael "rafaellerm" Lerm', - 'Eduardo Levi Chaves', - 'Gustavo Bim', 'Rog\xeanio Bel\xe9m', 'Samuel' - 'Simon "samscudder" Scudder', 'Van Der Fran'], + 'pt_BR': ['David Mederiros', 'Rafael "rafaellerm" Lerm', 'Eduardo Levi Chaves', + 'Gustavo Bim', 'Rog\xeanio Bel\xe9m', 'Samuel Simon "samscudder" Scudder', 'Van Der Fran'], 'ru': ['Sergey "ratz" Ratz'], 'sv': ['Erik "luen" Lundin'], 'ta_LK': ['"Prasad"'], 'zh_CN': [' "executor" '] } - documentors = ['Wesley "wrst" Stout', - 'John "jseagull1" Cegalis (lead)'] - self.credits_text_edit.setPlainText(translate('OpenLP.AboutForm', - 'Project Lead\n' - ' %s\n' - '\n' - 'Developers\n' - ' %s\n' - '\n' - 'Contributors\n' - ' %s\n' - '\n' - 'Testers\n' - ' %s\n' - '\n' - 'Packagers\n' - ' %s\n' - '\n' - 'Translators\n' - ' Afrikaans (af)\n' - ' %s\n' - ' Czech (cs)\n' - ' %s\n' - ' Danish (da)\n' - ' %s\n' - ' German (de)\n' - ' %s\n' - ' Greek (el)\n' - ' %s\n' - ' English, United Kingdom (en_GB)\n' - ' %s\n' - ' English, South Africa (en_ZA)\n' - ' %s\n' - ' Spanish (es)\n' - ' %s\n' - ' Estonian (et)\n' - ' %s\n' - ' Finnish (fi)\n' - ' %s\n' - ' French (fr)\n' - ' %s\n' - ' Hungarian (hu)\n' - ' %s\n' - ' Indonesian (id)\n' - ' %s\n' - ' Japanese (ja)\n' - ' %s\n' - ' Norwegian Bokm\xe5l (nb)\n' - ' %s\n' - ' Dutch (nl)\n' - ' %s\n' - ' Portuguese, Brazil (pt_BR)\n' - ' %s\n' - ' Russian (ru)\n' - ' %s\n' - ' Swedish (sv)\n' - ' %s\n' - ' Tamil(Sri-Lanka) (ta_LK)\n' - ' %s\n' - ' Chinese(China) (zh_CN)\n' - ' %s\n' - '\n' - 'Documentation\n' - ' %s\n' - '\n' - 'Built With\n' - ' Python: http://www.python.org/\n' - ' Qt4: http://qt.digia.com/\n' - ' PyQt4: http://www.riverbankcomputing.co.uk/software/pyqt/' - 'intro\n' - ' Oxygen Icons: http://oxygen-icons.org/\n' - '\n' - 'Final Credit\n' - ' "For God so loved the world that He gave\n' - ' His one and only Son, so that whoever\n' - ' believes in Him will not perish but inherit\n' - ' eternal life." -- John 3:16\n\n' - ' And last but not least, final credit goes to\n' - ' God our Father, for sending His Son to die\n' - ' on the cross, setting us free from sin. We\n' - ' bring this software to you for free because\n' - ' He has set us free.') % (lead, '\n '.join(developers), - '\n '.join(contributors), '\n '.join(testers), - '\n '.join(packagers), '\n '.join(translators['af']), - '\n '.join(translators['cs']), - '\n '.join(translators['da']), - '\n '.join(translators['de']), - '\n '.join(translators['el']), - '\n '.join(translators['en_GB']), - '\n '.join(translators['en_ZA']), - '\n '.join(translators['es']), - '\n '.join(translators['et']), - '\n '.join(translators['fi']), - '\n '.join(translators['fr']), - '\n '.join(translators['hu']), - '\n '.join(translators['id']), - '\n '.join(translators['ja']), - '\n '.join(translators['nb']), - '\n '.join(translators['nl']), - '\n '.join(translators['pt_BR']), - '\n '.join(translators['ru']), - '\n '.join(translators['sv']), - '\n '.join(translators['ta_LK']), - '\n '.join(translators['zh_CN']), - '\n '.join(documentors))) + documentors = ['Wesley "wrst" Stout', 'John "jseagull1" Cegalis (lead)'] + self.credits_text_edit.setPlainText( + translate('OpenLP.AboutForm', + 'Project Lead\n' + ' %s\n' + '\n' + 'Developers\n' + ' %s\n' + '\n' + 'Contributors\n' + ' %s\n' + '\n' + 'Testers\n' + ' %s\n' + '\n' + 'Packagers\n' + ' %s\n' + '\n' + 'Translators\n' + ' Afrikaans (af)\n' + ' %s\n' + ' Czech (cs)\n' + ' %s\n' + ' Danish (da)\n' + ' %s\n' + ' German (de)\n' + ' %s\n' + ' Greek (el)\n' + ' %s\n' + ' English, United Kingdom (en_GB)\n' + ' %s\n' + ' English, South Africa (en_ZA)\n' + ' %s\n' + ' Spanish (es)\n' + ' %s\n' + ' Estonian (et)\n' + ' %s\n' + ' Finnish (fi)\n' + ' %s\n' + ' French (fr)\n' + ' %s\n' + ' Hungarian (hu)\n' + ' %s\n' + ' Indonesian (id)\n' + ' %s\n' + ' Japanese (ja)\n' + ' %s\n' + ' Norwegian Bokm\xe5l (nb)\n' + ' %s\n' + ' Dutch (nl)\n' + ' %s\n' + ' Portuguese, Brazil (pt_BR)\n' + ' %s\n' + ' Russian (ru)\n' + ' %s\n' + ' Swedish (sv)\n' + ' %s\n' + ' Tamil(Sri-Lanka) (ta_LK)\n' + ' %s\n' + ' Chinese(China) (zh_CN)\n' + ' %s\n' + '\n' + 'Documentation\n' + ' %s\n' + '\n' + 'Built With\n' + ' Python: http://www.python.org/\n' + ' Qt4: http://qt.digia.com/\n' + ' PyQt4: http://www.riverbankcomputing.co.uk/software/pyqt/' + 'intro\n' + ' Oxygen Icons: http://oxygen-icons.org/\n' + '\n' + 'Final Credit\n' + ' "For God so loved the world that He gave\n' + ' His one and only Son, so that whoever\n' + ' believes in Him will not perish but inherit\n' + ' eternal life." -- John 3:16\n\n' + ' And last but not least, final credit goes to\n' + ' God our Father, for sending His Son to die\n' + ' on the cross, setting us free from sin. We\n' + ' bring this software to you for free because\n' + ' He has set us free.') % + (lead, '\n '.join(developers), + '\n '.join(contributors), '\n '.join(testers), + '\n '.join(packagers), '\n '.join(translators['af']), + '\n '.join(translators['cs']), + '\n '.join(translators['da']), + '\n '.join(translators['de']), + '\n '.join(translators['el']), + '\n '.join(translators['en_GB']), + '\n '.join(translators['en_ZA']), + '\n '.join(translators['es']), + '\n '.join(translators['et']), + '\n '.join(translators['fi']), + '\n '.join(translators['fr']), + '\n '.join(translators['hu']), + '\n '.join(translators['id']), + '\n '.join(translators['ja']), + '\n '.join(translators['nb']), + '\n '.join(translators['nl']), + '\n '.join(translators['pt_BR']), + '\n '.join(translators['ru']), + '\n '.join(translators['sv']), + '\n '.join(translators['ta_LK']), + '\n '.join(translators['zh_CN']), + '\n '.join(documentors))) self.about_notebook.setTabText(self.about_notebook.indexOf(self.credits_tab), - translate('OpenLP.AboutForm', 'Credits')) + translate('OpenLP.AboutForm', 'Credits')) copyright_note = translate('OpenLP.AboutForm', - 'Copyright \xa9 2004-2014 %s\n' - 'Portions copyright \xa9 2004-2014 %s') % ('Raoul Snyman', - 'Tim Bentley, Gerald Britton, Jonathan Corwin, Samuel Findlay, ' - 'Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, ' - 'Armin K\xf6hler, Erik Lundin, Edwin Lunando, Joshua Miller, ' - 'Brian T. Meyer, Stevan Pettit, Andreas Preikschat, ' - 'Mattias P\xf5ldaru, Christian Richter, ' - 'Philip Ridout, Simon Scudder, Jeffrey Smith, Maikel Stuivenberg, ' - 'Martin Thompson, Jon Tibble, Dave Warnock, Frode Woldsund, ' - 'Martin Zibricky, Patrick Zimmermann') + 'Copyright \xa9 2004-2014 %s\n' + 'Portions copyright \xa9 2004-2014 %s') % \ + ('Raoul Snyman', + 'Tim Bentley, Gerald Britton, Jonathan Corwin, Samuel Findlay, ' + 'Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, ' + 'Armin K\xf6hler, Erik Lundin, Edwin Lunando, Joshua Miller, ' + 'Brian T. Meyer, Stevan Pettit, Andreas Preikschat, ' + 'Mattias P\xf5ldaru, Christian Richter, ' + 'Philip Ridout, Simon Scudder, Jeffrey Smith, Maikel Stuivenberg, ' + 'Martin Thompson, Jon Tibble, Dave Warnock, Frode Woldsund, ' + 'Martin Zibricky, Patrick Zimmermann') licence = translate('OpenLP.AboutForm', - '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 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.') disclaimer = translate('OpenLP.AboutForm', - '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 below ' - 'for more details.') + '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 below ' + 'for more details.') gpl_text = ('GNU GENERAL PUBLIC LICENSE\n' - 'Version 2, June 1991\n' - '\n' - 'Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 ' - 'Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ' - 'Everyone is permitted to copy and distribute verbatim copies of ' - 'this license document, but changing it is not allowed.\n' - '\n' - 'Preamble\n' - '\n' - 'The licenses for most software are designed to take away your ' - 'freedom to share and change it. By contrast, the GNU General ' - 'Public License is intended to guarantee your freedom to share ' - 'and change free software--to make sure the software is free for ' - 'all its users. This General Public License applies to most of ' - 'the Free Software Foundation\'s software and to any other ' - 'program whose authors commit to using it. (Some other Free ' - 'Software Foundation software is covered by the GNU Lesser ' - 'General Public License instead.) You can apply it to your ' - 'programs, too.\n' - '\n' - 'When we speak of free software, we are referring to freedom, not ' - 'price. Our General Public Licenses are designed to make sure ' - 'that you have the freedom to distribute copies of free software ' - '(and charge for this service if you wish), that you receive ' - 'source code or can get it if you want it, that you can change ' - 'the software or use pieces of it in new free programs; and that ' - 'you know you can do these things.\n' - '\n' - 'To protect your rights, we need to make restrictions that forbid ' - 'anyone to deny you these rights or to ask you to surrender the ' - 'rights. These restrictions translate to certain responsibilities ' - 'for you if you distribute copies of the software, or if you ' - 'modify it.\n' - '\n' - 'For example, if you distribute copies of such a program, whether ' - 'gratis or for a fee, you must give the recipients all the rights ' - 'that you have. You must make sure that they, too, receive or ' - 'can get the source code. And you must show them these terms so ' - 'they know their rights.\n' - '\n' - 'We protect your rights with two steps: (1) copyright the ' - 'software, and (2) offer you this license which gives you legal ' - 'permission to copy, distribute and/or modify the software.\n' - '\n' - 'Also, for each author\'s protection and ours, we want to make ' - 'certain that everyone understands that there is no warranty for ' - 'this free software. If the software is modified by someone else ' - 'and passed on, we want its recipients to know that what they ' - 'have is not the original, so that any problems introduced by ' - 'others will not reflect on the original authors\' reputations.\n' - '\n' - 'Finally, any free program is threatened constantly by software ' - 'patents. We wish to avoid the danger that redistributors of a ' - 'free program will individually obtain patent licenses, in effect ' - 'making the program proprietary. To prevent this, we have made ' - 'it clear that any patent must be licensed for everyone\'s free ' - 'use or not licensed at all.\n' - '\n' - 'The precise terms and conditions for copying, distribution and ' - 'modification follow.\n' - '\n' - 'GNU GENERAL PUBLIC LICENSE\n' - 'TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION\n' - '\n' - '0. This License applies to any program or other work which ' - 'contains a notice placed by the copyright holder saying it may ' - 'be distributed under the terms of this General Public License. ' - 'The "Program", below, refers to any such program or work, and a ' - '"work based on the Program" means either the Program or any ' - 'derivative work under copyright law: that is to say, a work ' - 'containing the Program or a portion of it, either verbatim or ' - 'with modifications and/or translated into another language. ' - '(Hereinafter, translation is included without limitation in the ' - 'term "modification".) Each licensee is addressed as "you".\n' - '\n' - 'Activities other than copying, distribution and modification are ' - 'not covered by this License; they are outside its scope. The ' - 'act of running the Program is not restricted, and the output ' - 'from the Program is covered only if its contents constitute a ' - 'work based on the Program (independent of having been made by ' - 'running the Program). Whether that is true depends on what the ' - 'Program does.\n' - '\n' - '1. You may copy and distribute verbatim copies of the Program\'s ' - 'source code as you receive it, in any medium, provided that you ' - 'conspicuously and appropriately publish on each copy an ' - 'appropriate copyright notice and disclaimer of warranty; keep ' - 'intact all the notices that refer to this License and to the ' - 'absence of any warranty; and give any other recipients of the ' - 'Program a copy of this License along with the Program.\n' - '\n' - 'You may charge a fee for the physical act of transferring a ' - 'copy, and you may at your option offer warranty protection in ' - 'exchange for a fee.\n' - '\n' - '2. You may modify your copy or copies of the Program or any ' - 'portion of it, thus forming a work based on the Program, and ' - 'copy and distribute such modifications or work under the terms ' - 'of Section 1 above, provided that you also meet all of these ' - 'conditions:\n' - '\n' - 'a) You must cause the modified files to carry prominent notices ' - 'stating that you changed the files and the date of any change.\n' - '\n' - 'b) You must cause any work that you distribute or publish, that ' - 'in whole or in part contains or is derived from the Program or ' - 'any part thereof, to be licensed as a whole at no charge to all ' - 'third parties under the terms of this License.\n' - '\n' - 'c) If the modified program normally reads commands interactively ' - 'when run, you must cause it, when started running for such ' - 'interactive use in the most ordinary way, to print or display an ' - 'announcement including an appropriate copyright notice and a ' - 'notice that there is no warranty (or else, saying that you ' - 'provide a warranty) and that users may redistribute the program ' - 'under these conditions, and telling the user how to view a copy ' - 'of this License. (Exception: if the Program itself is ' - 'interactive but does not normally print such an announcement, ' - 'your work based on the Program is not required to print an ' - 'announcement.)\n' - '\n' - 'These requirements apply to the modified work as a whole. If ' - 'identifiable sections of that work are not derived from the ' - 'Program, and can be reasonably considered independent and ' - 'separate works in themselves, then this License, and its terms, ' - 'do not apply to those sections when you distribute them as ' - 'separate works. But when you distribute the same sections as ' - 'part of a whole which is a work based on the Program, the ' - 'distribution of the whole must be on the terms of this License, ' - 'whose permissions for other licensees extend to the entire ' - 'whole, and thus to each and every part regardless of who wrote ' - 'it.\n' - '\n' - 'Thus, it is not the intent of this section to claim rights or ' - 'contest your rights to work written entirely by you; rather, the ' - 'intent is to exercise the right to control the distribution of ' - 'derivative or collective works based on the Program.\n' - '\n' - 'In addition, mere aggregation of another work not based on the ' - 'Program with the Program (or with a work based on the Program) ' - 'on a volume of a storage or distribution medium does not bring ' - 'the other work under the scope of this License.\n' - '\n' - '3. You may copy and distribute the Program (or a work based on ' - 'it, under Section 2) in object code or executable form under the ' - 'terms of Sections 1 and 2 above provided that you also do one of ' - 'the following:\n' - '\n' - 'a) Accompany it with the complete corresponding machine-readable ' - 'source code, which must be distributed under the terms of ' - 'Sections 1 and 2 above on a medium customarily used for software ' - 'interchange; or,\n' - '\n' - 'b) Accompany it with a written offer, valid for at least three ' - 'years, to give any third party, for a charge no more than your ' - 'cost of physically performing source distribution, a complete ' - 'machine-readable copy of the corresponding source code, to be ' - 'distributed under the terms of Sections 1 and 2 above on a ' - 'medium customarily used for software interchange; or,\n' - '\n' - 'c) Accompany it with the information you received as to the ' - 'offer to distribute corresponding source code. (This ' - 'alternative is allowed only for noncommercial distribution and ' - 'only if you received the program in object code or executable ' - 'form with such an offer, in accord with Subsection b above.)\n' - '\n' - 'The source code for a work means the preferred form of the work ' - 'for making modifications to it. For an executable work, ' - 'complete source code means all the source code for all modules ' - 'it contains, plus any associated interface definition files, ' - 'plus the scripts used to control compilation and installation of ' - 'the executable. However, as a special exception, the source ' - 'code distributed need not include anything that is normally ' - 'distributed (in either source or binary form) with the major ' - 'components (compiler, kernel, and so on) of the operating system ' - 'on which the executable runs, unless that component itself ' - 'accompanies the executable.\n' - '\n' - 'If distribution of executable or object code is made by offering ' - 'access to copy from a designated place, then offering equivalent ' - 'access to copy the source code from the same place counts as ' - 'distribution of the source code, even though third parties are ' - 'not compelled to copy the source along with the object code.\n' - '\n' - '4. You may not copy, modify, sublicense, or distribute the ' - 'Program except as expressly provided under this License. Any ' - 'attempt otherwise to copy, modify, sublicense or distribute the ' - 'Program is void, and will automatically terminate your rights ' - 'under this License. However, parties who have received copies, ' - 'or rights, from you under this License will not have their ' - 'licenses terminated so long as such parties remain in full ' - 'compliance.\n' - '\n' - '5. You are not required to accept this License, since you have ' - 'not signed it. However, nothing else grants you permission to ' - 'modify or distribute the Program or its derivative works. These ' - 'actions are prohibited by law if you do not accept this ' - 'License. Therefore, by modifying or distributing the Program ' - '(or any work based on the Program), you indicate your acceptance ' - 'of this License to do so, and all its terms and conditions for ' - 'copying, distributing or modifying the Program or works based on ' - 'it.\n' - '\n' - '6. Each time you redistribute the Program (or any work based on ' - 'the Program), the recipient automatically receives a license ' - 'from the original licensor to copy, distribute or modify the ' - 'Program subject to these terms and conditions. You may not ' - 'impose any further restrictions on the recipients\' exercise of ' - 'the rights granted herein. You are not responsible for enforcing ' - 'compliance by third parties to this License.\n' - '\n' - '7. If, as a consequence of a court judgment or allegation of ' - 'patent infringement or for any other reason (not limited to ' - 'patent issues), conditions are imposed on you (whether by court ' - 'order, agreement or otherwise) that contradict the conditions of ' - 'this License, they do not excuse you from the conditions of this ' - 'License. If you cannot distribute so as to satisfy ' - 'simultaneously your obligations under this License and any other ' - 'pertinent obligations, then as a consequence you may not ' - 'distribute the Program at all. For example, if a patent license ' - 'would not permit royalty-free redistribution of the Program by ' - 'all those who receive copies directly or indirectly through you, ' - 'then the only way you could satisfy both it and this License ' - 'would be to refrain entirely from distribution of the Program.\n' - '\n' - 'If any portion of this section is held invalid or unenforceable ' - 'under any particular circumstance, the balance of the section is ' - 'intended to apply and the section as a whole is intended to ' - 'apply in other circumstances.\n' - '\n' - 'It is not the purpose of this section to induce you to infringe ' - 'any patents or other property right claims or to contest ' - 'validity of any such claims; this section has the sole purpose ' - 'of protecting the integrity of the free software distribution ' - 'system, which is implemented by public license practices. Many ' - 'people have made generous contributions to the wide range of ' - 'software distributed through that system in reliance on ' - 'consistent application of that system; it is up to the ' - 'author/donor to decide if he or she is willing to distribute ' - 'software through any other system and a licensee cannot impose ' - 'that choice.\n' - '\n' - 'This section is intended to make thoroughly clear what is ' - 'believed to be a consequence of the rest of this License.\n' - '\n' - '8. If the distribution and/or use of the Program is restricted ' - 'in certain countries either by patents or by copyrighted ' - 'interfaces, the original copyright holder who places the Program ' - 'under this License may add an explicit geographical distribution ' - 'limitation excluding those countries, so that distribution is ' - 'permitted only in or among countries not thus excluded. In such ' - 'case, this License incorporates the limitation as if written in ' - 'the body of this License.\n' - '\n' - '9. The Free Software Foundation may publish revised and/or new ' - 'versions of the General Public License from time to time. Such ' - 'new versions will be similar in spirit to the present version, ' - 'but may differ in detail to address new problems or concerns.\n' - '\n' - 'Each version is given a distinguishing version number. If the ' - 'Program specifies a version number of this License which applies ' - 'to it and "any later version", you have the option of ' - 'following the terms and conditions either of that version or of ' - 'any later version published by the Free Software Foundation. If ' - 'the Program does not specify a version number of this License, ' - 'you may choose any version ever published by the Free Software ' - 'Foundation.\n' - '\n' - '10. If you wish to incorporate parts of the Program into other ' - 'free programs whose distribution conditions are different, write ' - 'to the author to ask for permission. For software which is ' - 'copyrighted by the Free Software Foundation, write to the Free ' - 'Software Foundation; we sometimes make exceptions for this. Our ' - 'decision will be guided by the two goals of preserving the free ' - 'status of all derivatives of our free software and of promoting ' - 'the sharing and reuse of software generally.\n' - '\n' - 'NO WARRANTY\n' - '\n' - '11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO ' - 'WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE ' - 'LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT ' - 'HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT ' - 'WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, ' - 'BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY ' - 'AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE ' - 'QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE ' - 'PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY ' - 'SERVICING, REPAIR OR CORRECTION.\n' - '\n' - '12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO ' - 'IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY ' - 'MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE ' - 'LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, ' - 'INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR ' - 'INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS ' - 'OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY ' - 'YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ' - 'ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ' - 'ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.\n' - '\n' - 'END OF TERMS AND CONDITIONS\n' - '\n' - 'How to Apply These Terms to Your New Programs\n' - '\n' - 'If you develop a new program, and you want it to be of the ' - 'greatest possible use to the public, the best way to achieve ' - 'this is to make it free software which everyone can redistribute ' - 'and change under these terms.\n' - '\n' - 'To do so, attach the following notices to the program. It is ' - 'safest to attach them to the start of each source file to most ' - 'effectively convey the exclusion of warranty; and each file ' - 'should have at least the "copyright" line and a pointer to where ' - 'the full notice is found.\n' - '\n' - '<one line to give the program\'s name and a brief idea of what ' - 'it does.>\n' - 'Copyright (C) <year> <name of author>\n' - '\n' - '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; either version 2 of ' - 'the License, or (at your option) any later version.\n' - '\n' - '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.\n' - '\n' - '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., 51 Franklin Street, Fifth Floor, ' - 'Boston, MA 02110-1301 USA.\n' - '\n' - 'Also add information on how to contact you by electronic and ' - 'paper mail.\n' - '\n' - 'If the program is interactive, make it output a short notice ' - 'like this when it starts in an interactive mode:\n' - '\n' - 'Gnomovision version 69, Copyright (C) year name of author\n' - 'Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type ' - '"show w".\n' - 'This is free software, and you are welcome to redistribute it ' - 'under certain conditions; type "show c" for details.\n' - '\n' - 'The hypothetical commands "show w" and "show c" should show ' - 'the appropriate parts of the General Public License. Of course, ' - 'the commands you use may be called something other than "show ' - 'w" and "show c"; they could even be mouse-clicks or menu items--' - 'whatever suits your program.\n' - '\n' - 'You should also get your employer (if you work as a programmer) ' - 'or your school, if any, to sign a "copyright disclaimer" for the ' - 'program, if necessary. Here is a sample; alter the names:\n' - '\n' - 'Yoyodyne, Inc., hereby disclaims all copyright interest in the ' - 'program "Gnomovision" (which makes passes at compilers) written ' - 'by James Hacker.\n' - '\n' - '<signature of Ty Coon>, 1 April 1989\n' - 'Ty Coon, President of Vice\n' - '\n' - 'This General Public License does not permit incorporating your ' - 'program into proprietary programs. If your program is a ' - 'subroutine library, you may consider it more useful to permit ' - 'linking proprietary applications with the library. If this is ' - 'what you want to do, use the GNU Lesser General Public License ' - 'instead of this License.') + 'Version 2, June 1991\n' + '\n' + 'Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 ' + 'Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ' + 'Everyone is permitted to copy and distribute verbatim copies of ' + 'this license document, but changing it is not allowed.\n' + '\n' + 'Preamble\n' + '\n' + 'The licenses for most software are designed to take away your ' + 'freedom to share and change it. By contrast, the GNU General ' + 'Public License is intended to guarantee your freedom to share ' + 'and change free software--to make sure the software is free for ' + 'all its users. This General Public License applies to most of ' + 'the Free Software Foundation\'s software and to any other ' + 'program whose authors commit to using it. (Some other Free ' + 'Software Foundation software is covered by the GNU Lesser ' + 'General Public License instead.) You can apply it to your ' + 'programs, too.\n' + '\n' + 'When we speak of free software, we are referring to freedom, not ' + 'price. Our General Public Licenses are designed to make sure ' + 'that you have the freedom to distribute copies of free software ' + '(and charge for this service if you wish), that you receive ' + 'source code or can get it if you want it, that you can change ' + 'the software or use pieces of it in new free programs; and that ' + 'you know you can do these things.\n' + '\n' + 'To protect your rights, we need to make restrictions that forbid ' + 'anyone to deny you these rights or to ask you to surrender the ' + 'rights. These restrictions translate to certain responsibilities ' + 'for you if you distribute copies of the software, or if you ' + 'modify it.\n' + '\n' + 'For example, if you distribute copies of such a program, whether ' + 'gratis or for a fee, you must give the recipients all the rights ' + 'that you have. You must make sure that they, too, receive or ' + 'can get the source code. And you must show them these terms so ' + 'they know their rights.\n' + '\n' + 'We protect your rights with two steps: (1) copyright the ' + 'software, and (2) offer you this license which gives you legal ' + 'permission to copy, distribute and/or modify the software.\n' + '\n' + 'Also, for each author\'s protection and ours, we want to make ' + 'certain that everyone understands that there is no warranty for ' + 'this free software. If the software is modified by someone else ' + 'and passed on, we want its recipients to know that what they ' + 'have is not the original, so that any problems introduced by ' + 'others will not reflect on the original authors\' reputations.\n' + '\n' + 'Finally, any free program is threatened constantly by software ' + 'patents. We wish to avoid the danger that redistributors of a ' + 'free program will individually obtain patent licenses, in effect ' + 'making the program proprietary. To prevent this, we have made ' + 'it clear that any patent must be licensed for everyone\'s free ' + 'use or not licensed at all.\n' + '\n' + 'The precise terms and conditions for copying, distribution and ' + 'modification follow.\n' + '\n' + 'GNU GENERAL PUBLIC LICENSE\n' + 'TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION\n' + '\n' + '0. This License applies to any program or other work which ' + 'contains a notice placed by the copyright holder saying it may ' + 'be distributed under the terms of this General Public License. ' + 'The "Program", below, refers to any such program or work, and a ' + '"work based on the Program" means either the Program or any ' + 'derivative work under copyright law: that is to say, a work ' + 'containing the Program or a portion of it, either verbatim or ' + 'with modifications and/or translated into another language. ' + '(Hereinafter, translation is included without limitation in the ' + 'term "modification".) Each licensee is addressed as "you".\n' + '\n' + 'Activities other than copying, distribution and modification are ' + 'not covered by this License; they are outside its scope. The ' + 'act of running the Program is not restricted, and the output ' + 'from the Program is covered only if its contents constitute a ' + 'work based on the Program (independent of having been made by ' + 'running the Program). Whether that is true depends on what the ' + 'Program does.\n' + '\n' + '1. You may copy and distribute verbatim copies of the Program\'s ' + 'source code as you receive it, in any medium, provided that you ' + 'conspicuously and appropriately publish on each copy an ' + 'appropriate copyright notice and disclaimer of warranty; keep ' + 'intact all the notices that refer to this License and to the ' + 'absence of any warranty; and give any other recipients of the ' + 'Program a copy of this License along with the Program.\n' + '\n' + 'You may charge a fee for the physical act of transferring a ' + 'copy, and you may at your option offer warranty protection in ' + 'exchange for a fee.\n' + '\n' + '2. You may modify your copy or copies of the Program or any ' + 'portion of it, thus forming a work based on the Program, and ' + 'copy and distribute such modifications or work under the terms ' + 'of Section 1 above, provided that you also meet all of these ' + 'conditions:\n' + '\n' + 'a) You must cause the modified files to carry prominent notices ' + 'stating that you changed the files and the date of any change.\n' + '\n' + 'b) You must cause any work that you distribute or publish, that ' + 'in whole or in part contains or is derived from the Program or ' + 'any part thereof, to be licensed as a whole at no charge to all ' + 'third parties under the terms of this License.\n' + '\n' + 'c) If the modified program normally reads commands interactively ' + 'when run, you must cause it, when started running for such ' + 'interactive use in the most ordinary way, to print or display an ' + 'announcement including an appropriate copyright notice and a ' + 'notice that there is no warranty (or else, saying that you ' + 'provide a warranty) and that users may redistribute the program ' + 'under these conditions, and telling the user how to view a copy ' + 'of this License. (Exception: if the Program itself is ' + 'interactive but does not normally print such an announcement, ' + 'your work based on the Program is not required to print an ' + 'announcement.)\n' + '\n' + 'These requirements apply to the modified work as a whole. If ' + 'identifiable sections of that work are not derived from the ' + 'Program, and can be reasonably considered independent and ' + 'separate works in themselves, then this License, and its terms, ' + 'do not apply to those sections when you distribute them as ' + 'separate works. But when you distribute the same sections as ' + 'part of a whole which is a work based on the Program, the ' + 'distribution of the whole must be on the terms of this License, ' + 'whose permissions for other licensees extend to the entire ' + 'whole, and thus to each and every part regardless of who wrote ' + 'it.\n' + '\n' + 'Thus, it is not the intent of this section to claim rights or ' + 'contest your rights to work written entirely by you; rather, the ' + 'intent is to exercise the right to control the distribution of ' + 'derivative or collective works based on the Program.\n' + '\n' + 'In addition, mere aggregation of another work not based on the ' + 'Program with the Program (or with a work based on the Program) ' + 'on a volume of a storage or distribution medium does not bring ' + 'the other work under the scope of this License.\n' + '\n' + '3. You may copy and distribute the Program (or a work based on ' + 'it, under Section 2) in object code or executable form under the ' + 'terms of Sections 1 and 2 above provided that you also do one of ' + 'the following:\n' + '\n' + 'a) Accompany it with the complete corresponding machine-readable ' + 'source code, which must be distributed under the terms of ' + 'Sections 1 and 2 above on a medium customarily used for software ' + 'interchange; or,\n' + '\n' + 'b) Accompany it with a written offer, valid for at least three ' + 'years, to give any third party, for a charge no more than your ' + 'cost of physically performing source distribution, a complete ' + 'machine-readable copy of the corresponding source code, to be ' + 'distributed under the terms of Sections 1 and 2 above on a ' + 'medium customarily used for software interchange; or,\n' + '\n' + 'c) Accompany it with the information you received as to the ' + 'offer to distribute corresponding source code. (This ' + 'alternative is allowed only for noncommercial distribution and ' + 'only if you received the program in object code or executable ' + 'form with such an offer, in accord with Subsection b above.)\n' + '\n' + 'The source code for a work means the preferred form of the work ' + 'for making modifications to it. For an executable work, ' + 'complete source code means all the source code for all modules ' + 'it contains, plus any associated interface definition files, ' + 'plus the scripts used to control compilation and installation of ' + 'the executable. However, as a special exception, the source ' + 'code distributed need not include anything that is normally ' + 'distributed (in either source or binary form) with the major ' + 'components (compiler, kernel, and so on) of the operating system ' + 'on which the executable runs, unless that component itself ' + 'accompanies the executable.\n' + '\n' + 'If distribution of executable or object code is made by offering ' + 'access to copy from a designated place, then offering equivalent ' + 'access to copy the source code from the same place counts as ' + 'distribution of the source code, even though third parties are ' + 'not compelled to copy the source along with the object code.\n' + '\n' + '4. You may not copy, modify, sublicense, or distribute the ' + 'Program except as expressly provided under this License. Any ' + 'attempt otherwise to copy, modify, sublicense or distribute the ' + 'Program is void, and will automatically terminate your rights ' + 'under this License. However, parties who have received copies, ' + 'or rights, from you under this License will not have their ' + 'licenses terminated so long as such parties remain in full ' + 'compliance.\n' + '\n' + '5. You are not required to accept this License, since you have ' + 'not signed it. However, nothing else grants you permission to ' + 'modify or distribute the Program or its derivative works. These ' + 'actions are prohibited by law if you do not accept this ' + 'License. Therefore, by modifying or distributing the Program ' + '(or any work based on the Program), you indicate your acceptance ' + 'of this License to do so, and all its terms and conditions for ' + 'copying, distributing or modifying the Program or works based on ' + 'it.\n' + '\n' + '6. Each time you redistribute the Program (or any work based on ' + 'the Program), the recipient automatically receives a license ' + 'from the original licensor to copy, distribute or modify the ' + 'Program subject to these terms and conditions. You may not ' + 'impose any further restrictions on the recipients\' exercise of ' + 'the rights granted herein. You are not responsible for enforcing ' + 'compliance by third parties to this License.\n' + '\n' + '7. If, as a consequence of a court judgment or allegation of ' + 'patent infringement or for any other reason (not limited to ' + 'patent issues), conditions are imposed on you (whether by court ' + 'order, agreement or otherwise) that contradict the conditions of ' + 'this License, they do not excuse you from the conditions of this ' + 'License. If you cannot distribute so as to satisfy ' + 'simultaneously your obligations under this License and any other ' + 'pertinent obligations, then as a consequence you may not ' + 'distribute the Program at all. For example, if a patent license ' + 'would not permit royalty-free redistribution of the Program by ' + 'all those who receive copies directly or indirectly through you, ' + 'then the only way you could satisfy both it and this License ' + 'would be to refrain entirely from distribution of the Program.\n' + '\n' + 'If any portion of this section is held invalid or unenforceable ' + 'under any particular circumstance, the balance of the section is ' + 'intended to apply and the section as a whole is intended to ' + 'apply in other circumstances.\n' + '\n' + 'It is not the purpose of this section to induce you to infringe ' + 'any patents or other property right claims or to contest ' + 'validity of any such claims; this section has the sole purpose ' + 'of protecting the integrity of the free software distribution ' + 'system, which is implemented by public license practices. Many ' + 'people have made generous contributions to the wide range of ' + 'software distributed through that system in reliance on ' + 'consistent application of that system; it is up to the ' + 'author/donor to decide if he or she is willing to distribute ' + 'software through any other system and a licensee cannot impose ' + 'that choice.\n' + '\n' + 'This section is intended to make thoroughly clear what is ' + 'believed to be a consequence of the rest of this License.\n' + '\n' + '8. If the distribution and/or use of the Program is restricted ' + 'in certain countries either by patents or by copyrighted ' + 'interfaces, the original copyright holder who places the Program ' + 'under this License may add an explicit geographical distribution ' + 'limitation excluding those countries, so that distribution is ' + 'permitted only in or among countries not thus excluded. In such ' + 'case, this License incorporates the limitation as if written in ' + 'the body of this License.\n' + '\n' + '9. The Free Software Foundation may publish revised and/or new ' + 'versions of the General Public License from time to time. Such ' + 'new versions will be similar in spirit to the present version, ' + 'but may differ in detail to address new problems or concerns.\n' + '\n' + 'Each version is given a distinguishing version number. If the ' + 'Program specifies a version number of this License which applies ' + 'to it and "any later version", you have the option of ' + 'following the terms and conditions either of that version or of ' + 'any later version published by the Free Software Foundation. If ' + 'the Program does not specify a version number of this License, ' + 'you may choose any version ever published by the Free Software ' + 'Foundation.\n' + '\n' + '10. If you wish to incorporate parts of the Program into other ' + 'free programs whose distribution conditions are different, write ' + 'to the author to ask for permission. For software which is ' + 'copyrighted by the Free Software Foundation, write to the Free ' + 'Software Foundation; we sometimes make exceptions for this. Our ' + 'decision will be guided by the two goals of preserving the free ' + 'status of all derivatives of our free software and of promoting ' + 'the sharing and reuse of software generally.\n' + '\n' + 'NO WARRANTY\n' + '\n' + '11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO ' + 'WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE ' + 'LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT ' + 'HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT ' + 'WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, ' + 'BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY ' + 'AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE ' + 'QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE ' + 'PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY ' + 'SERVICING, REPAIR OR CORRECTION.\n' + '\n' + '12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO ' + 'IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY ' + 'MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE ' + 'LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, ' + 'INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR ' + 'INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS ' + 'OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY ' + 'YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ' + 'ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ' + 'ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.\n' + '\n' + 'END OF TERMS AND CONDITIONS\n' + '\n' + 'How to Apply These Terms to Your New Programs\n' + '\n' + 'If you develop a new program, and you want it to be of the ' + 'greatest possible use to the public, the best way to achieve ' + 'this is to make it free software which everyone can redistribute ' + 'and change under these terms.\n' + '\n' + 'To do so, attach the following notices to the program. It is ' + 'safest to attach them to the start of each source file to most ' + 'effectively convey the exclusion of warranty; and each file ' + 'should have at least the "copyright" line and a pointer to where ' + 'the full notice is found.\n' + '\n' + '<one line to give the program\'s name and a brief idea of what ' + 'it does.>\n' + 'Copyright (C) <year> <name of author>\n' + '\n' + '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; either version 2 of ' + 'the License, or (at your option) any later version.\n' + '\n' + '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.\n' + '\n' + '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., 51 Franklin Street, Fifth Floor, ' + 'Boston, MA 02110-1301 USA.\n' + '\n' + 'Also add information on how to contact you by electronic and ' + 'paper mail.\n' + '\n' + 'If the program is interactive, make it output a short notice ' + 'like this when it starts in an interactive mode:\n' + '\n' + 'Gnomovision version 69, Copyright (C) year name of author\n' + 'Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type ' + '"show w".\n' + 'This is free software, and you are welcome to redistribute it ' + 'under certain conditions; type "show c" for details.\n' + '\n' + 'The hypothetical commands "show w" and "show c" should show ' + 'the appropriate parts of the General Public License. Of course, ' + 'the commands you use may be called something other than "show ' + 'w" and "show c"; they could even be mouse-clicks or menu items--' + 'whatever suits your program.\n' + '\n' + 'You should also get your employer (if you work as a programmer) ' + 'or your school, if any, to sign a "copyright disclaimer" for the ' + 'program, if necessary. Here is a sample; alter the names:\n' + '\n' + 'Yoyodyne, Inc., hereby disclaims all copyright interest in the ' + 'program "Gnomovision" (which makes passes at compilers) written ' + 'by James Hacker.\n' + '\n' + '<signature of Ty Coon>, 1 April 1989\n' + 'Ty Coon, President of Vice\n' + '\n' + 'This General Public License does not permit incorporating your ' + 'program into proprietary programs. If your program is a ' + 'subroutine library, you may consider it more useful to permit ' + 'linking proprietary applications with the library. If this is ' + 'what you want to do, use the GNU Lesser General Public License ' + 'instead of this License.') self.license_text_edit.setPlainText('%s\n\n%s\n\n%s\n\n\n%s' % (copyright_note, licence, disclaimer, gpl_text)) self.about_notebook.setTabText(self.about_notebook.indexOf(self.license_tab), - translate('OpenLP.AboutForm', 'License')) + translate('OpenLP.AboutForm', 'License')) self.volunteer_button.setText(translate('OpenLP.AboutForm', 'Volunteer')) diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index cb0de776f..b2c8cd14b 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -263,7 +263,7 @@ class AdvancedTab(SettingsTab): """ Setup the interface translation strings. """ - self.tabTitleVisible = UiStrings().Advanced + self.tab_title_visible = UiStrings().Advanced self.ui_group_box.setTitle(translate('OpenLP.AdvancedTab', 'UI Settings')) self.data_directory_group_box.setTitle(translate('OpenLP.AdvancedTab', 'Data Location')) self.recent_label.setText(translate('OpenLP.AdvancedTab', 'Number of recent files to display:')) @@ -319,7 +319,7 @@ class AdvancedTab(SettingsTab): translate('OpenLP.AdvancedTab', '<strong>WARNING:</strong> New data directory location contains ' 'OpenLP data files. These files WILL be replaced during a copy.')) self.display_workaround_group_box.setTitle(translate('OpenLP.AdvancedTab', 'Display Workarounds')) - self.x11_bypass_check_box.setText(translate('OpenLP.AdvancedTab','Bypass X11 Window Manager')) + self.x11_bypass_check_box.setText(translate('OpenLP.AdvancedTab', 'Bypass X11 Window Manager')) self.alternate_rows_check_box.setText(translate('OpenLP.AdvancedTab', 'Use alternating row colours in lists')) # Slide Limits self.slide_group_box.setTitle(translate('OpenLP.GeneralTab', 'Service Item Slide Limits')) @@ -375,7 +375,8 @@ class AdvancedTab(SettingsTab): self.current_data_path = AppLocation.get_data_path() if not os.path.exists(self.current_data_path): log.error('Data path not found %s' % self.current_data_path) - answer = QtGui.QMessageBox.critical(self, translate('OpenLP.AdvancedTab', 'Data Directory Error'), + answer = QtGui.QMessageBox.critical( + self, translate('OpenLP.AdvancedTab', 'Data Directory Error'), translate('OpenLP.AdvancedTab', 'OpenLP data directory was not found\n\n%s\n\n' 'This data directory was previously changed from the OpenLP ' 'default location. If the new location was on removable ' @@ -537,8 +538,9 @@ class AdvancedTab(SettingsTab): # Make sure they want to change the data. answer = QtGui.QMessageBox.question(self, translate('OpenLP.AdvancedTab', 'Confirm Data Directory Change'), translate('OpenLP.AdvancedTab', 'Are you sure you want to change the ' - 'location of the OpenLP data directory to:\n\n%s\n\nThe data directory ' - 'will be changed when OpenLP is closed.').replace('%s', new_data_path), + 'location of the OpenLP data directory to:\n\n%s\n\nThe data ' + 'directory will be changed when OpenLP is closed.'). + replace('%s', new_data_path), QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No), QtGui.QMessageBox.No) @@ -561,8 +563,9 @@ class AdvancedTab(SettingsTab): # default. answer = QtGui.QMessageBox.question(self, translate('OpenLP.AdvancedTab', 'Reset Data Directory'), translate('OpenLP.AdvancedTab', 'Are you sure you want to change the ' - 'location of the OpenLP data directory to the default location?\n\nThis' - ' location will be used after OpenLP is closed.'), + 'location of the OpenLP data directory to the default ' + 'location?\n\nThis location will be used after OpenLP is ' + 'closed.'), QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No), QtGui.QMessageBox.No) @@ -588,7 +591,7 @@ class AdvancedTab(SettingsTab): else: self.new_data_directory_has_files_label.hide() - def check_data_overwrite(self, data_path ): + def check_data_overwrite(self, data_path): """ Check if there's already data in the target directory. """ @@ -602,8 +605,8 @@ class AdvancedTab(SettingsTab): translate('OpenLP.AdvancedTab', 'WARNING: \n\nThe location you have selected \n\n%s\n\n' 'appears to contain OpenLP data files. Do you wish to ' - 'replace these files with the current data files?').replace - ('%s', os.path.abspath(data_path,)), + 'replace these files with the current data files?'). + replace('%s', os.path.abspath(data_path,)), QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No), QtGui.QMessageBox.No) diff --git a/openlp/core/ui/exceptiondialog.py b/openlp/core/ui/exceptiondialog.py index 21496ccb1..4d7abe708 100644 --- a/openlp/core/ui/exceptiondialog.py +++ b/openlp/core/ui/exceptiondialog.py @@ -83,9 +83,8 @@ class Ui_ExceptionDialog(object): self.attach_tile_button = create_button(exception_dialog, 'attach_tile_button', icon=':/general/general_open.png', click=self.on_attach_file_button_clicked) - self.button_box = create_button_box(exception_dialog, 'button_box', - ['close'], [self.send_report_button, - self.save_report_button, self.attach_tile_button]) + self.button_box = create_button_box(exception_dialog, 'button_box', ['close'], + [self.send_report_button, self.save_report_button, self.attach_tile_button]) self.exception_layout.addWidget(self.button_box) self.retranslateUi(exception_dialog) diff --git a/openlp/core/ui/exceptionform.py b/openlp/core/ui/exceptionform.py index 72e78ad28..ae3bc9db0 100644 --- a/openlp/core/ui/exceptionform.py +++ b/openlp/core/ui/exceptionform.py @@ -157,7 +157,8 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog, RegistryProperties): '--- Exception Traceback ---\n%s\n' '--- System information ---\n%s\n' '--- Library Versions ---\n%s\n') - filename = QtGui.QFileDialog.getSaveFileName(self, + filename = QtGui.QFileDialog.getSaveFileName( + self, translate('OpenLP.ExceptionForm', 'Save Crash Report'), Settings().value(self.settings_section + '/last directory'), translate('OpenLP.ExceptionForm', 'Text files (*.txt *.log *.text)')) @@ -185,14 +186,13 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog, RegistryProperties): Opening systems default email client and inserting exception log and system information. """ body = translate('OpenLP.ExceptionForm', - '*OpenLP Bug Report*\n' - 'Version: %s\n\n' - '--- Details of the Exception. ---\n\n%s\n\n ' - '--- Exception Traceback ---\n%s\n' - '--- System information ---\n%s\n' - '--- Library Versions ---\n%s\n', - 'Please add the information that bug reports are favoured written ' - 'in English.') + '*OpenLP Bug Report*\n' + 'Version: %s\n\n' + '--- Details of the Exception. ---\n\n%s\n\n ' + '--- Exception Traceback ---\n%s\n' + '--- System information ---\n%s\n' + '--- Library Versions ---\n%s\n', + 'Please add the information that bug reports are favoured written in English.') content = self._create_report() source = '' exception = '' diff --git a/openlp/core/ui/filerenameform.py b/openlp/core/ui/filerenameform.py index 8e80fd102..0483ea1dd 100644 --- a/openlp/core/ui/filerenameform.py +++ b/openlp/core/ui/filerenameform.py @@ -57,4 +57,4 @@ class FileRenameForm(QtGui.QDialog, Ui_FileRenameDialog, RegistryProperties): else: self.setWindowTitle(translate('OpenLP.FileRenameForm', 'File Rename')) self.file_name_edit.setFocus() - return QtGui.QDialog.exec_(self) \ No newline at end of file + return QtGui.QDialog.exec_(self) diff --git a/openlp/core/ui/firsttimeform.py b/openlp/core/ui/firsttimeform.py index 56e43df77..aa89da6c0 100644 --- a/openlp/core/ui/firsttimeform.py +++ b/openlp/core/ui/firsttimeform.py @@ -468,4 +468,4 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard, RegistryProperties): Set the status of a plugin. """ status = PluginStatus.Active if field.checkState() == QtCore.Qt.Checked else PluginStatus.Inactive - Settings().setValue(tag, status) \ No newline at end of file + Settings().setValue(tag, status) diff --git a/openlp/core/ui/formattingtagcontroller.py b/openlp/core/ui/formattingtagcontroller.py index 7c4f7333d..353114643 100644 --- a/openlp/core/ui/formattingtagcontroller.py +++ b/openlp/core/ui/formattingtagcontroller.py @@ -174,4 +174,4 @@ class FormattingTagController(object): if end and end != end_html: return translate('OpenLP.FormattingTagForm', 'End tag %s does not match end tag for start tag %s' % (end, start_html)), None - return None, None \ No newline at end of file + return None, None diff --git a/openlp/core/ui/formattingtagdialog.py b/openlp/core/ui/formattingtagdialog.py index 6e7822d9e..387bca0a7 100644 --- a/openlp/core/ui/formattingtagdialog.py +++ b/openlp/core/ui/formattingtagdialog.py @@ -102,8 +102,7 @@ class Ui_FormattingTagDialog(object): self.edit_button_layout.addWidget(self.delete_button) self.edit_button_layout.addStretch() self.list_data_grid_layout.addLayout(self.edit_button_layout) - self.button_box = create_button_box(formatting_tag_dialog, 'button_box', - ['cancel', 'save', 'defaults']) + self.button_box = create_button_box(formatting_tag_dialog, 'button_box', ['cancel', 'save', 'defaults']) self.save_button = self.button_box.button(QtGui.QDialogButtonBox.Save) self.save_button.setObjectName('save_button') self.restore_button = self.button_box.button(QtGui.QDialogButtonBox.RestoreDefaults) diff --git a/openlp/core/ui/formattingtagform.py b/openlp/core/ui/formattingtagform.py index b1348b4e9..b7153429d 100644 --- a/openlp/core/ui/formattingtagform.py +++ b/openlp/core/ui/formattingtagform.py @@ -204,4 +204,3 @@ class FormattingTagForm(QtGui.QDialog, Ui_FormattingTagDialog, FormattingTagCont QtGui.QMessageBox.Ok) #self.tag_table_widget.selectRow(pre_row - 1) self.tag_table_widget.resizeRowsToContents() - diff --git a/openlp/core/ui/generaltab.py b/openlp/core/ui/generaltab.py index 642dfc538..3aa3f28c0 100644 --- a/openlp/core/ui/generaltab.py +++ b/openlp/core/ui/generaltab.py @@ -223,7 +223,8 @@ class GeneralTab(SettingsTab): self.save_check_service_check_box.setText(translate('OpenLP.GeneralTab', 'Prompt to save before starting a new service')) self.auto_unblank_check_box.setText(translate('OpenLP.GeneralTab', 'Unblank display when adding new live item')) - self.auto_preview_check_box.setText(translate('OpenLP.GeneralTab', 'Automatically preview next item in service')) + self.auto_preview_check_box.setText(translate('OpenLP.GeneralTab', + 'Automatically preview next item in service')) self.timeout_label.setText(translate('OpenLP.GeneralTab', 'Timed slide interval:')) self.timeout_spin_box.setSuffix(translate('OpenLP.GeneralTab', ' sec')) self.ccli_group_box.setTitle(translate('OpenLP.GeneralTab', 'CCLI Details')) diff --git a/openlp/core/ui/listpreviewwidget.py b/openlp/core/ui/listpreviewwidget.py index ec007843d..7dbcfc2bd 100644 --- a/openlp/core/ui/listpreviewwidget.py +++ b/openlp/core/ui/listpreviewwidget.py @@ -160,4 +160,4 @@ class ListPreviewWidget(QtGui.QTableWidget, RegistryProperties): """ Returns the number of slides this widget holds. """ - return super(ListPreviewWidget, self).rowCount() \ No newline at end of file + return super(ListPreviewWidget, self).rowCount() diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index eced865ad..b9423046e 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -601,4 +601,3 @@ class AudioPlayer(OpenLPMixin, QtCore.QObject): :param signal: The signal to be fired """ QtCore.QObject.connect(self.media_object, signal, slot) - diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 3526e551f..703307e18 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -887,7 +887,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow, RegistryProperties): # application terminates normally. We need to exit without saving configuration. QtGui.QMessageBox.information(self, translate('OpenLP.MainWindow', 'Import settings'), translate('OpenLP.MainWindow', 'OpenLP will now close. Imported settings will ' - 'be applied the next time you start OpenLP.'), + 'be applied the next time you start OpenLP.'), QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok)) self.settings_imported = True self.clean_up() @@ -1042,8 +1042,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow, RegistryProperties): ret = QtGui.QMessageBox.question(self, translate('OpenLP.MainWindow', 'Close OpenLP'), translate('OpenLP.MainWindow', 'Are you sure you want to close ' 'OpenLP?'), - QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui - .QMessageBox.No), + QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | + QtGui.QMessageBox.No), QtGui.QMessageBox.Yes) if ret == QtGui.QMessageBox.Yes: self.clean_up() @@ -1234,16 +1234,15 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow, RegistryProperties): self.recent_files_menu.clear() for file_id, filename in enumerate(recent_files_to_display): log.debug('Recent file name: %s', filename) - action = create_action(self, '', - text='&%d %s' % (file_id + 1, + action = create_action(self, '', text='&%d %s' % (file_id + 1, os.path.splitext(os.path.basename(str(filename)))[0]), data=filename, triggers=self.service_manager_contents.on_recent_service_clicked) self.recent_files_menu.addAction(action) clear_recent_files_action = create_action(self, '', text=translate('OpenLP.MainWindow', 'Clear List', 'Clear List of ' - 'recent files'), + 'recent files'), statustip=translate('OpenLP.MainWindow', 'Clear the list of recent ' - 'files.'), + 'files.'), enabled=bool(self.recent_files), triggers=self.clear_recent_file_menu) add_actions(self.recent_files_menu, (None, clear_recent_files_action)) @@ -1352,8 +1351,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow, RegistryProperties): self.application.set_normal_cursor() log.exception('Data copy failed %s' % str(why)) QtGui.QMessageBox.critical(self, translate('OpenLP.MainWindow', 'New Data Directory Error'), - translate('OpenLP.MainWindow', - 'OpenLP Data directory copy failed\n\n%s').replace('%s', str(why)), + translate('OpenLP.MainWindow', 'OpenLP Data directory copy failed\n\n%s'). + replace('%s', str(why)), QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok)) return False else: @@ -1365,5 +1364,3 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow, RegistryProperties): if self.new_data_path == AppLocation.get_directory(AppLocation.DataDir): settings.remove('advanced/data path') self.application.set_normal_cursor() - - diff --git a/openlp/core/ui/media/mediacontroller.py b/openlp/core/ui/media/mediacontroller.py index 54cc6cdf8..d846af0e4 100644 --- a/openlp/core/ui/media/mediacontroller.py +++ b/openlp/core/ui/media/mediacontroller.py @@ -383,7 +383,7 @@ class MediaController(RegistryMixin, OpenLPMixin, RegistryProperties): if not is_valid: # Media could not be loaded correctly critical_error_message_box(translate('MediaPlugin.MediaItem', 'Unsupported File'), - translate('MediaPlugin.MediaItem', 'Unsupported File')) + translate('MediaPlugin.MediaItem', 'Unsupported File')) return False # dont care about actual theme, set a black background if controller.is_live and not controller.media_info.is_background: @@ -402,7 +402,7 @@ class MediaController(RegistryMixin, OpenLPMixin, RegistryProperties): if autoplay: if not self.media_play(controller): critical_error_message_box(translate('MediaPlugin.MediaItem', 'Unsupported File'), - translate('MediaPlugin.MediaItem', 'Unsupported File')) + translate('MediaPlugin.MediaItem', 'Unsupported File')) return False self.set_controls_visible(controller, True) log.debug('use %s controller' % self.current_media_players[controller.controller_type]) @@ -644,9 +644,9 @@ class MediaController(RegistryMixin, OpenLPMixin, RegistryProperties): return display = self._define_display(self.live_controller) if self.live_controller.controller_type in self.current_media_players and \ - self.current_media_players[self.live_controller.controller_type].state == MediaState.Playing: - self.current_media_players[self.live_controller.controller_type].pause(display) - self.current_media_players[self.live_controller.controller_type].set_visible(display, False) + self.current_media_players[self.live_controller.controller_type].state == MediaState.Playing: + self.current_media_players[self.live_controller.controller_type].pause(display) + self.current_media_players[self.live_controller.controller_type].set_visible(display, False) def media_blank(self, msg): """ @@ -701,4 +701,4 @@ class MediaController(RegistryMixin, OpenLPMixin, RegistryProperties): """ if controller.is_live: return controller.display - return controller.preview_display \ No newline at end of file + return controller.preview_display diff --git a/openlp/core/ui/media/mediaplayer.py b/openlp/core/ui/media/mediaplayer.py index 49b699034..3246d58c4 100644 --- a/openlp/core/ui/media/mediaplayer.py +++ b/openlp/core/ui/media/mediaplayer.py @@ -150,4 +150,4 @@ class MediaPlayer(RegistryProperties): """ Returns Information about the player """ - return '' \ No newline at end of file + return '' diff --git a/openlp/core/ui/media/phononplayer.py b/openlp/core/ui/media/phononplayer.py index d08628004..5e94dbd0e 100644 --- a/openlp/core/ui/media/phononplayer.py +++ b/openlp/core/ui/media/phononplayer.py @@ -105,7 +105,7 @@ class PhononPlayer(MediaPlayer): if ext not in mime_type_list: mime_type_list.append(ext) log.info('MediaPlugin: %s additional extensions: %s' % - (mimetype, ' '.join(self.additional_extensions[mimetype]))) + (mimetype, ' '.join(self.additional_extensions[mimetype]))) def setup(self, display): """ diff --git a/openlp/core/ui/media/vlcplayer.py b/openlp/core/ui/media/vlcplayer.py index 7c892a87c..c80bb6218 100644 --- a/openlp/core/ui/media/vlcplayer.py +++ b/openlp/core/ui/media/vlcplayer.py @@ -291,4 +291,4 @@ class VlcPlayer(MediaPlayer): '<br/> <strong>' + translate('Media.player', 'Audio') + '</strong><br/>' + str(AUDIO_EXT) + '<br/><strong>' + translate('Media.player', 'Video') + '</strong><br/>' + - str(VIDEO_EXT) + '<br/>') \ No newline at end of file + str(VIDEO_EXT) + '<br/>') diff --git a/openlp/core/ui/pluginform.py b/openlp/core/ui/pluginform.py index 9e6ac9663..91b98b97a 100644 --- a/openlp/core/ui/pluginform.py +++ b/openlp/core/ui/pluginform.py @@ -154,4 +154,4 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog, RegistryProperties): elif self.active_plugin.status == PluginStatus.Disabled: status_text = translate('OpenLP.PluginForm', '%s (Disabled)') self.plugin_list_widget.currentItem().setText( - status_text % self.active_plugin.name_strings['singular']) \ No newline at end of file + status_text % self.active_plugin.name_strings['singular']) diff --git a/openlp/core/ui/printserviceform.py b/openlp/core/ui/printserviceform.py index 753bb2a04..489eefa78 100644 --- a/openlp/core/ui/printserviceform.py +++ b/openlp/core/ui/printserviceform.py @@ -394,4 +394,4 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog, RegistryProperties) return for item in self.service_manager.service_items: # Trigger Audit requests - Registry().register_function('print_service_started', [item['service_item']]) \ No newline at end of file + Registry().register_function('print_service_started', [item['service_item']]) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index e7994b261..c2b36551a 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -689,8 +689,8 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ServiceManage if self._file_name.endswith('oszl') or self.service_has_all_original_files: file_name = QtGui.QFileDialog.getSaveFileName(self.main_window, UiStrings().SaveService, path, translate('OpenLP.ServiceManager', - 'OpenLP Service Files (*.osz);; OpenLP Service Files - lite ' - '(*.oszl)')) + 'OpenLP Service Files (*.osz);; OpenLP Service ' + 'Files - lite (*.oszl)')) else: file_name = QtGui.QFileDialog.getSaveFileName(self.main_window, UiStrings().SaveService, path, translate('OpenLP.ServiceManager', @@ -783,7 +783,8 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ServiceManage self.log_exception('Service file is cannot be extracted as zip: %s' % file_name) QtGui.QMessageBox.information(self, translate('OpenLP.ServiceManager', 'Corrupt File'), translate('OpenLP.ServiceManager', - 'This file is either corrupt or it is not an OpenLP 2 service file.')) + 'This file is either corrupt or it is not an OpenLP 2 service ' + 'file.')) self.application.set_normal_cursor() return finally: @@ -1253,8 +1254,7 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ServiceManage tree_widget_item.setText(0, service_item_from_item.get_display_title()) tips = [] if service_item_from_item.temporary_edit: - tips.append('<strong>%s:</strong> <em>%s</em>' % - (translate('OpenLP.ServiceManager', 'Edit'), + tips.append('<strong>%s:</strong> <em>%s</em>' % (translate('OpenLP.ServiceManager', 'Edit'), (translate('OpenLP.ServiceManager', 'Service copy only')))) if service_item_from_item.theme and service_item_from_item.theme != -1: tips.append('<strong>%s:</strong> <em>%s</em>' % @@ -1492,9 +1492,9 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ServiceManage def find_service_item(self): """ - Finds the first selected ServiceItem in the list and returns the position of the service_item_from_item and its selected - child item. For example, if the third child item (in the Slidecontroller known as slide) in the second service - item is selected this will return:: + Finds the first selected ServiceItem in the list and returns the position of the service_item_from_item and its + selected child item. For example, if the third child item (in the Slidecontroller known as slide) in the + second service item is selected this will return:: (1, 2) """ @@ -1632,4 +1632,4 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ServiceManage Print a Service Order Sheet. """ setting_dialog = PrintServiceForm() - setting_dialog.exec_() \ No newline at end of file + setting_dialog.exec_() diff --git a/openlp/core/ui/servicenoteform.py b/openlp/core/ui/servicenoteform.py index ee24cf7cf..c91380a5d 100644 --- a/openlp/core/ui/servicenoteform.py +++ b/openlp/core/ui/servicenoteform.py @@ -74,4 +74,4 @@ class ServiceNoteForm(QtGui.QDialog, RegistryProperties): """ Translate the UI on the fly """ - self.setWindowTitle(translate('OpenLP.ServiceNoteForm', 'Service Item Notes')) \ No newline at end of file + self.setWindowTitle(translate('OpenLP.ServiceNoteForm', 'Service Item Notes')) diff --git a/openlp/core/ui/settingsform.py b/openlp/core/ui/settingsform.py index 68b0b3b41..5aba66ef2 100644 --- a/openlp/core/ui/settingsform.py +++ b/openlp/core/ui/settingsform.py @@ -151,4 +151,4 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog, RegistryProperties): :param function: The function to be called """ if not function in self.processes: - self.processes.append(function) \ No newline at end of file + self.processes.append(function) diff --git a/openlp/core/ui/shortcutlistform.py b/openlp/core/ui/shortcutlistform.py index a8e4c6ba1..4b64c3b54 100644 --- a/openlp/core/ui/shortcutlistform.py +++ b/openlp/core/ui/shortcutlistform.py @@ -285,7 +285,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog, RegistryProperties) if QtGui.QMessageBox.question(self, translate('OpenLP.ShortcutListDialog', 'Restore Default Shortcuts'), translate('OpenLP.ShortcutListDialog', 'Do you want to restore all ' 'shortcuts to their defaults?'), - QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | + QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)) == QtGui.QMessageBox.No: return self._adjust_button(self.primary_push_button, False, text='') diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 80835b97f..eb1f13fa6 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -170,14 +170,14 @@ class SlideController(DisplayController, RegistryProperties): size_toolbar_policy.setHeightForWidth(self.toolbar.sizePolicy().hasHeightForWidth()) self.toolbar.setSizePolicy(size_toolbar_policy) self.previous_item = create_action(self, 'previousItem_' + self.type_prefix, - text=translate('OpenLP.SlideController', 'Previous Slide'), + text=translate('OpenLP.SlideController', 'Previous Slide'), icon=':/slides/slide_previous.png', tooltip=translate('OpenLP.SlideController', 'Move to previous.'), can_shortcuts=True, context=QtCore.Qt.WidgetWithChildrenShortcut, category=self.category, triggers=self.on_slide_selected_previous) self.toolbar.addAction(self.previous_item) self.next_item = create_action(self, 'nextItem_' + self.type_prefix, - text=translate('OpenLP.SlideController', 'Next Slide'), + text=translate('OpenLP.SlideController', 'Next Slide'), icon=':/slides/slide_next.png', tooltip=translate('OpenLP.SlideController', 'Move to next.'), can_shortcuts=True, context=QtCore.Qt.WidgetWithChildrenShortcut, @@ -195,17 +195,17 @@ class SlideController(DisplayController, RegistryProperties): self.hide_menu.setMenu(QtGui.QMenu(translate('OpenLP.SlideController', 'Hide'), self.toolbar)) self.toolbar.add_toolbar_widget(self.hide_menu) self.blank_screen = create_action(self, 'blankScreen', - text=translate('OpenLP.SlideController', 'Blank Screen'), + text=translate('OpenLP.SlideController', 'Blank Screen'), icon=':/slides/slide_blank.png', - checked=False, can_shortcuts=True, category=self.category, + checked=False, can_shortcuts=True, category=self.category, triggers=self.on_blank_display) self.theme_screen = create_action(self, 'themeScreen', - text=translate('OpenLP.SlideController', 'Blank to Theme'), + text=translate('OpenLP.SlideController', 'Blank to Theme'), icon=':/slides/slide_theme.png', checked=False, can_shortcuts=True, category=self.category, triggers=self.on_theme_display) self.desktop_screen = create_action(self, 'desktopScreen', - text=translate('OpenLP.SlideController', 'Show Desktop'), + text=translate('OpenLP.SlideController', 'Show Desktop'), icon=':/slides/slide_desktop.png', checked=False, can_shortcuts=True, category=self.category, triggers=self.on_hide_display) @@ -255,15 +255,16 @@ class SlideController(DisplayController, RegistryProperties): self.toolbar.add_toolbar_widget(self.delay_spin_box) else: self.toolbar.add_toolbar_action('goLive', icon=':/general/general_live.png', - tooltip=translate('OpenLP.SlideController', 'Move to live.'), + tooltip=translate('OpenLP.SlideController', 'Move to live.'), triggers=self.on_go_live) self.toolbar.add_toolbar_action('addToService', icon=':/general/general_add.png', - tooltip=translate('OpenLP.SlideController', 'Add to Service.'), + tooltip=translate('OpenLP.SlideController', 'Add to Service.'), triggers=self.on_preview_add_to_service) self.toolbar.addSeparator() self.toolbar.add_toolbar_action('editSong', icon=':/general/general_edit.png', - tooltip=translate('OpenLP.SlideController', 'Edit and reload song preview.') - , triggers=self.on_edit_song) + tooltip=translate('OpenLP.SlideController', + 'Edit and reload song preview.'), + triggers=self.on_edit_song) self.controller_layout.addWidget(self.toolbar) # Build the Media Toolbar self.media_controller.register_controller(self) @@ -355,7 +356,7 @@ class SlideController(DisplayController, RegistryProperties): {'key': 'O', 'configurable': True, 'text': translate('OpenLP.SlideController', 'Go to "Other"')} ] shortcuts.extend([{'key': str(number)} for number in range(10)]) - self.controller.addActions([create_action(self, 'shortcutAction_%s' % s['key'], + self.controller.addActions([create_action(self, 'shortcutAction_%s' % s['key'], text=s.get('text'), can_shortcuts=True, context=QtCore.Qt.WidgetWithChildrenShortcut, @@ -394,9 +395,9 @@ class SlideController(DisplayController, RegistryProperties): """ Called, when a shortcut has been activated to jump to a chorus, verse, etc. - **Note**: This implementation is based on shortcuts. But it rather works like "key sequenes". You have to + **Note**: This implementation is based on shortcuts. But it rather works like "key sequenes". You have to press one key after the other and **not** at the same time. - For example to jump to "V3" you have to press "V" and afterwards but within a time frame of 350ms + For example to jump to "V3" you have to press "V" and afterwards but within a time frame of 350ms you have to press "3". """ try: @@ -456,17 +457,17 @@ class SlideController(DisplayController, RegistryProperties): """ self.previous_service = create_action(parent, 'previousService', text=translate('OpenLP.SlideController', 'Previous Service'), - can_shortcuts=True, context=QtCore.Qt.WidgetWithChildrenShortcut, + can_shortcuts=True, context=QtCore.Qt.WidgetWithChildrenShortcut, category=self.category, triggers=self.service_previous) self.next_service = create_action(parent, 'nextService', text=translate('OpenLP.SlideController', 'Next Service'), - can_shortcuts=True, context=QtCore.Qt.WidgetWithChildrenShortcut, + can_shortcuts=True, context=QtCore.Qt.WidgetWithChildrenShortcut, category=self.category, triggers=self.service_next) self.escape_item = create_action(parent, 'escapeItem', text=translate('OpenLP.SlideController', 'Escape Item'), - can_shortcuts=True, context=QtCore.Qt.WidgetWithChildrenShortcut, + can_shortcuts=True, context=QtCore.Qt.WidgetWithChildrenShortcut, category=self.category, triggers=self.live_escape) @@ -1325,7 +1326,7 @@ class SlideController(DisplayController, RegistryProperties): """ Update how much time is remaining - :param time: the time remainings + :param time: the time remaining """ seconds = self.display.audio_player.media_object.remainingTime() // 1000 minutes = seconds // 60 diff --git a/openlp/core/ui/starttimeform.py b/openlp/core/ui/starttimeform.py index 4ee9e565c..d005d167b 100644 --- a/openlp/core/ui/starttimeform.py +++ b/openlp/core/ui/starttimeform.py @@ -74,12 +74,12 @@ class StartTimeForm(QtGui.QDialog, Ui_StartTimeDialog, RegistryProperties): self.minute_finish_spin_box.value() * 60 + self.second_finish_spin_box.value() if end > self.item['service_item'].media_length: critical_error_message_box(title=translate('OpenLP.StartTime_form', 'Time Validation Error'), - message=translate('OpenLP.StartTime_form', + message=translate('OpenLP.StartTime_form', 'Finish time is set after the end of the media item')) return elif start > end: critical_error_message_box(title=translate('OpenLP.StartTime_form', 'Time Validation Error'), - message=translate('OpenLP.StartTime_form', + message=translate('OpenLP.StartTime_form', 'Start time is after the finish time of the media item')) return self.item['service_item'].start_time = start @@ -94,4 +94,4 @@ class StartTimeForm(QtGui.QDialog, Ui_StartTimeDialog, RegistryProperties): seconds -= 3600 * hours minutes = seconds // 60 seconds -= 60 * minutes - return hours, minutes, seconds \ No newline at end of file + return hours, minutes, seconds diff --git a/openlp/core/ui/themeform.py b/openlp/core/ui/themeform.py index 7cb53e47b..fbfc1035c 100644 --- a/openlp/core/ui/themeform.py +++ b/openlp/core/ui/themeform.py @@ -180,7 +180,7 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard, RegistryProperties): self.theme.background_type == background_image and is_not_image_file(self.theme.background_filename): QtGui.QMessageBox.critical(self, translate('OpenLP.ThemeWizard', 'Background Image Empty'), translate('OpenLP.ThemeWizard', '_you have not selected a ' - 'background image. Please select one before continuing.')) + 'background image. Please select one before continuing.')) return False else: return True @@ -540,4 +540,4 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard, RegistryProperties): new_color = QtGui.QColorDialog.getColor(QtGui.QColor(field), self) if new_color.isValid(): field = new_color.name() - return field \ No newline at end of file + return field diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 98c2198c7..fdd2ea592 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -517,7 +517,7 @@ class ThemeManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ThemeManager, R """ ret = QtGui.QMessageBox.question(self, translate('OpenLP.ThemeManager', 'Theme Already Exists'), translate('OpenLP.ThemeManager', - 'Theme %s already exists. Do you want to replace it?') + 'Theme %s already exists. Do you want to replace it?') .replace('%s', theme_name), QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No), @@ -753,4 +753,4 @@ class ThemeManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ThemeManager, R % (theme, plugin.name)) return False return True - return False \ No newline at end of file + return False diff --git a/openlp/core/ui/themewizard.py b/openlp/core/ui/themewizard.py index 5cfc86d07..77ccb0663 100644 --- a/openlp/core/ui/themewizard.py +++ b/openlp/core/ui/themewizard.py @@ -385,10 +385,10 @@ class Ui_ThemeWizard(object): QtCore.SLOT('setDisabled(bool)')) QtCore.QObject.connect(self.footer_position_check_box, QtCore.SIGNAL('toggled(bool)'), self.footer_y_spin_box, QtCore.SLOT('setDisabled(bool)')) - QtCore.QObject.connect(self.footer_position_check_box, QtCore.SIGNAL('toggled(bool)'), self.footer_width_spin_box, - QtCore.SLOT('setDisabled(bool)')) - QtCore.QObject.connect(self.footer_position_check_box, QtCore.SIGNAL('toggled(bool)'), self.footer_height_spin_box, - QtCore.SLOT('setDisabled(bool)')) + QtCore.QObject.connect(self.footer_position_check_box, QtCore.SIGNAL('toggled(bool)'), + self.footer_width_spin_box, QtCore.SLOT('setDisabled(bool)')) + QtCore.QObject.connect(self.footer_position_check_box, QtCore.SIGNAL('toggled(bool)'), + self.footer_height_spin_box, QtCore.SLOT('setDisabled(bool)')) def retranslateUi(self, themeWizard): """ @@ -409,15 +409,18 @@ class Ui_ThemeWizard(object): self.background_combo_box.setItemText(BackgroundType.Gradient, translate('OpenLP.ThemeWizard', 'Gradient')) self.background_combo_box.setItemText(BackgroundType.Image, UiStrings().Image) - self.background_combo_box.setItemText(BackgroundType.Transparent, translate('OpenLP.ThemeWizard', 'Transparent')) + self.background_combo_box.setItemText(BackgroundType.Transparent, + translate('OpenLP.ThemeWizard', 'Transparent')) self.color_label.setText(translate('OpenLP.ThemeWizard', 'color:')) self.gradient_start_label.setText(translate('OpenLP.ThemeWizard', 'Starting color:')) self.gradient_end_label.setText(translate('OpenLP.ThemeWizard', 'Ending color:')) self.gradient_type_label.setText(translate('OpenLP.ThemeWizard', 'Gradient:')) self.gradient_combo_box.setItemText(BackgroundGradientType.Horizontal, translate('OpenLP.ThemeWizard', 'Horizontal')) - self.gradient_combo_box.setItemText(BackgroundGradientType.Vertical, translate('OpenLP.ThemeWizard', 'Vertical')) - self.gradient_combo_box.setItemText(BackgroundGradientType.Circular, translate('OpenLP.ThemeWizard', 'Circular')) + self.gradient_combo_box.setItemText(BackgroundGradientType.Vertical, + translate('OpenLP.ThemeWizard', 'Vertical')) + self.gradient_combo_box.setItemText(BackgroundGradientType.Circular, + translate('OpenLP.ThemeWizard', 'Circular')) self.gradient_combo_box.setItemText(BackgroundGradientType.LeftTop, translate('OpenLP.ThemeWizard', 'Top Left - Bottom Right')) self.gradient_combo_box.setItemText(BackgroundGradientType.LeftBottom, @@ -486,6 +489,6 @@ class Ui_ThemeWizard(object): self.preview_page.setSubTitle(translate('OpenLP.ThemeWizard', 'Preview the theme and save it.')) self.theme_name_label.setText(translate('OpenLP.ThemeWizard', 'Theme name:')) # Align all QFormLayouts towards each other. - label_width = max(self.background_label.minimumSizeHint().width(), + label_width = max(self.background_label.minimumSizeHint().width(), self.horizontal_label.minimumSizeHint().width()) self.spacer.changeSize(label_width, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) diff --git a/openlp/core/ui/wizard.py b/openlp/core/ui/wizard.py index 4d9b4ebdf..05951d14a 100644 --- a/openlp/core/ui/wizard.py +++ b/openlp/core/ui/wizard.py @@ -303,4 +303,4 @@ class OpenLPWizard(QtGui.QWizard, RegistryProperties): QtGui.QFileDialog.ShowDirsOnly) if folder: editbox.setText(folder) - Settings().setValue(self.plugin.settings_section + '/' + setting_name, folder) \ No newline at end of file + Settings().setValue(self.plugin.settings_section + '/' + setting_name, folder) diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index d9e060aed..746c50d71 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -72,13 +72,18 @@ USER_AGENTS = { 'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.71 Safari/537.36' ], 'darwin': [ - 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.43 Safari/537.31', - 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.57 Safari/536.11', - 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.47 Safari/536.11', + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.31 (KHTML, like Gecko) ' + 'Chrome/26.0.1410.43 Safari/537.31', + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/536.11 (KHTML, like Gecko) ' + 'Chrome/20.0.1132.57 Safari/536.11', + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/536.11 (KHTML, like Gecko) ' + 'Chrome/20.0.1132.47 Safari/536.11', ], 'linux2': [ - 'Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.22 (KHTML, like Gecko) Ubuntu Chromium/25.0.1364.160 Chrome/25.0.1364.160 Safari/537.22', - 'Mozilla/5.0 (X11; CrOS armv7l 2913.260.0) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.99 Safari/537.11', + 'Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.22 (KHTML, like Gecko) Ubuntu Chromium/25.0.1364.160 ' + 'Chrome/25.0.1364.160 Safari/537.22', + 'Mozilla/5.0 (X11; CrOS armv7l 2913.260.0) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.99 ' + 'Safari/537.11', 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.27 (KHTML, like Gecko) Chrome/26.0.1389.0 Safari/537.27' ], 'default': [ @@ -144,9 +149,9 @@ def get_application_version(): # If they are equal, then this tree is tarball with the source for the release. We do not want the revision # number in the full version. if tree_revision == tag_revision: - full_version = tag_version + full_version = tag_version else: - full_version = '%s-bzr%s' % (tag_version, tree_revision) + full_version = '%s-bzr%s' % (tag_version, tree_revision) else: # We're not running the development version, let's use the file. filepath = AppLocation.get_directory(AppLocation.VersionDir) diff --git a/openlp/core/utils/actions.py b/openlp/core/utils/actions.py index 6201dff52..29f2d279b 100644 --- a/openlp/core/utils/actions.py +++ b/openlp/core/utils/actions.py @@ -295,7 +295,7 @@ class ActionList(object): ActionList.shortcut_map[shortcuts[1]] = actions else: log.warn('Shortcut "%s" is removed from "%s" because another action already uses this shortcut.' % - (shortcuts[1], action.objectName())) + (shortcuts[1], action.objectName())) shortcuts.remove(shortcuts[1]) # Check the primary shortcut. existing_actions = ActionList.shortcut_map.get(shortcuts[0], []) @@ -306,7 +306,7 @@ class ActionList(object): ActionList.shortcut_map[shortcuts[0]] = actions else: log.warn('Shortcut "%s" is removed from "%s" because another action already uses this shortcut.' % - (shortcuts[0], action.objectName())) + (shortcuts[0], action.objectName())) shortcuts.remove(shortcuts[0]) action.setShortcuts([QtGui.QKeySequence(shortcut) for shortcut in shortcuts]) diff --git a/openlp/core/utils/languagemanager.py b/openlp/core/utils/languagemanager.py index 3e240778b..cd5ce7add 100644 --- a/openlp/core/utils/languagemanager.py +++ b/openlp/core/utils/languagemanager.py @@ -126,8 +126,9 @@ class LanguageManager(object): log.info('Language file: \'%s\' written to conf file' % language) if message: QtGui.QMessageBox.information(None, - translate('OpenLP.LanguageManager', 'Language'), - translate('OpenLP.LanguageManager', 'Please restart OpenLP to use your new language setting.')) + translate('OpenLP.LanguageManager', 'Language'), + translate('OpenLP.LanguageManager', 'Please restart OpenLP to use your new ' + 'language setting.')) @staticmethod def init_qm_list(): From 9dfc446ebd4bf54fa1280f6244fb45816478d312 Mon Sep 17 00:00:00 2001 From: Tim Bentley <tim.bentley@gmail.com> Date: Fri, 21 Mar 2014 18:23:35 +0000 Subject: [PATCH 06/51] More cleanups --- openlp/plugins/alerts/alertsplugin.py | 2 +- openlp/plugins/alerts/forms/alertform.py | 2 +- openlp/plugins/alerts/lib/alertsmanager.py | 2 +- openlp/plugins/bibles/bibleplugin.py | 4 +- .../plugins/bibles/forms/bibleimportform.py | 590 +++++++++--------- .../plugins/bibles/forms/bibleupgradeform.py | 156 ++--- openlp/plugins/bibles/forms/booknamedialog.py | 23 +- openlp/plugins/bibles/forms/booknameform.py | 13 +- .../plugins/bibles/forms/editbibledialog.py | 24 +- openlp/plugins/bibles/forms/editbibleform.py | 2 +- openlp/plugins/bibles/forms/languagedialog.py | 18 +- openlp/plugins/bibles/forms/languageform.py | 3 +- openlp/plugins/bibles/lib/__init__.py | 7 +- openlp/plugins/bibles/lib/biblestab.py | 3 +- openlp/plugins/bibles/lib/db.py | 27 +- openlp/plugins/bibles/lib/http.py | 6 +- openlp/plugins/bibles/lib/mediaitem.py | 6 +- openlp/plugins/images/forms/addgroupform.py | 3 +- openlp/plugins/images/lib/mediaitem.py | 6 +- openlp/plugins/media/lib/mediaitem.py | 8 +- .../songusage/forms/songusagedeleteform.py | 2 +- .../songusage/forms/songusagedetailform.py | 17 +- openlp/plugins/songusage/lib/db.py | 2 +- 23 files changed, 472 insertions(+), 454 deletions(-) diff --git a/openlp/plugins/alerts/alertsplugin.py b/openlp/plugins/alerts/alertsplugin.py index e9a24980e..cf3b7d0ce 100644 --- a/openlp/plugins/alerts/alertsplugin.py +++ b/openlp/plugins/alerts/alertsplugin.py @@ -246,4 +246,4 @@ class AlertsPlugin(Plugin): align = VerticalType.Names[self.settings_tab.location] frame.evaluateJavaScript('update_css("%s", "%s", "%s", "%s", "%s")' % (align, self.settings_tab.font_face, self.settings_tab.font_size, - self.settings_tab.font_color, self.settings_tab.background_color)) + self.settings_tab.font_color, self.settings_tab.background_color)) diff --git a/openlp/plugins/alerts/forms/alertform.py b/openlp/plugins/alerts/forms/alertform.py index f5e5ee31a..f988bec0f 100644 --- a/openlp/plugins/alerts/forms/alertform.py +++ b/openlp/plugins/alerts/forms/alertform.py @@ -46,7 +46,7 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog): self.manager = plugin.manager self.plugin = plugin self.item_id = None - super(AlertForm, self).__init__( Registry().get('main_window')) + super(AlertForm, self).__init__(Registry().get('main_window')) self.setupUi(self) self.display_button.clicked.connect(self.on_display_clicked) self.display_close_button.clicked.connect(self.on_display_close_clicked) diff --git a/openlp/plugins/alerts/lib/alertsmanager.py b/openlp/plugins/alerts/lib/alertsmanager.py index 675b5874e..061936446 100644 --- a/openlp/plugins/alerts/lib/alertsmanager.py +++ b/openlp/plugins/alerts/lib/alertsmanager.py @@ -97,4 +97,4 @@ class AlertsManager(OpenLPMixin, RegistryMixin, QtCore.QObject, RegistryProperti self.live_controller.display.alert('', alert_tab.location) self.killTimer(self.timer_id) self.timer_id = 0 - self.generate_alert() \ No newline at end of file + self.generate_alert() diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index fc7d76130..5a51be163 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -113,8 +113,8 @@ class BiblePlugin(Plugin): """ super(BiblePlugin, self).app_startup() if self.manager.old_bible_databases: - if QtGui.QMessageBox.information(self.main_window, - translate('OpenLP', 'Information'), + if QtGui.QMessageBox.information( + self.main_window, translate('OpenLP', 'Information'), translate('OpenLP', 'Bible format has changed.\nYou have to upgrade your existing Bibles.\n' 'Should OpenLP upgrade now?'), QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)) == \ diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index 8c7b62d10..ee5bee2d0 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -44,6 +44,7 @@ from openlp.plugins.bibles.lib.db import BiblesResourcesDB, clean_filename log = logging.getLogger(__name__) + class WebDownload(object): """ Provides an enumeration for the web bible types available to OpenLP. @@ -81,258 +82,257 @@ class BibleImportForm(OpenLPWizard): Set up the UI for the bible wizard. """ super(BibleImportForm, self).setupUi(image) - self.formatComboBox.currentIndexChanged.connect(self.onCurrentIndexChanged) + self.format_combo_box.currentIndexChanged.connect(self.on_current_index_changed) - def onCurrentIndexChanged(self, index): + def on_current_index_changed(self, index): """ Called when the format combo box's index changed. We have to check if the import is available and accordingly to disable or enable the next button. """ - self.selectStack.setCurrentIndex(index) + self.select_stack.setCurrentIndex(index) def custom_init(self): """ Perform any custom initialisation for bible importing. """ self.manager.set_process_dialog(self) - self.loadWebBibles() + self.load_Web_Bibles() self.restart() - self.selectStack.setCurrentIndex(0) + self.select_stack.setCurrentIndex(0) def custom_signals(self): """ Set up the signals used in the bible importer. """ - self.webSourceComboBox.currentIndexChanged.connect(self.onWebSourceComboBoxIndexChanged) - self.osisBrowseButton.clicked.connect(self.onOsisBrowseButtonClicked) - self.csvBooksButton.clicked.connect(self.onCsvBooksBrowseButtonClicked) - self.csvVersesButton.clicked.connect(self.onCsvVersesBrowseButtonClicked) - self.openSongBrowseButton.clicked.connect(self.onOpenSongBrowseButtonClicked) + self.web_source_combo_box.currentIndexChanged.connect(self.on_web_source_combo_box_index_changed) + self.osis_browse_button.clicked.connect(self.on_osis_browse_button_clicked) + self.csv_books_button.clicked.connect(self.on_csv_books_browse_button_clicked) + self.csv_verses_button.clicked.connect(self.on_csv_verses_browse_button_clicked) + self.open_song_browse_button.clicked.connect(self.on_open_song_browse_button_clicked) def add_custom_pages(self): """ Add the bible import specific wizard pages. """ # Select Page - self.selectPage = QtGui.QWizardPage() - self.selectPage.setObjectName('SelectPage') - self.selectPageLayout = QtGui.QVBoxLayout(self.selectPage) - self.selectPageLayout.setObjectName('SelectPageLayout') - self.formatLayout = QtGui.QFormLayout() - self.formatLayout.setObjectName('FormatLayout') - self.formatLabel = QtGui.QLabel(self.selectPage) - self.formatLabel.setObjectName('FormatLabel') - self.formatComboBox = QtGui.QComboBox(self.selectPage) - self.formatComboBox.addItems(['', '', '', '']) - self.formatComboBox.setObjectName('FormatComboBox') - self.formatLayout.addRow(self.formatLabel, self.formatComboBox) + self.select_page = QtGui.QWizardPage() + self.select_page.setObjectName('SelectPage') + self.select_page_layout = QtGui.QVBoxLayout(self.select_page) + self.select_page_layout.setObjectName('SelectPageLayout') + self.format_layout = QtGui.QFormLayout() + self.format_layout.setObjectName('FormatLayout') + self.format_label = QtGui.QLabel(self.select_page) + self.format_label.setObjectName('FormatLabel') + self.format_combo_box = QtGui.QComboBox(self.select_page) + self.format_combo_box.addItems(['', '', '', '']) + self.format_combo_box.setObjectName('FormatComboBox') + self.format_layout.addRow(self.format_label, self.format_combo_box) self.spacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Minimum) - self.formatLayout.setItem(1, QtGui.QFormLayout.LabelRole, self.spacer) - self.selectPageLayout.addLayout(self.formatLayout) - self.selectStack = QtGui.QStackedLayout() - self.selectStack.setObjectName('SelectStack') - self.osisWidget = QtGui.QWidget(self.selectPage) - self.osisWidget.setObjectName('OsisWidget') - self.osisLayout = QtGui.QFormLayout(self.osisWidget) - self.osisLayout.setMargin(0) - self.osisLayout.setObjectName('OsisLayout') - self.osisFileLabel = QtGui.QLabel(self.osisWidget) - self.osisFileLabel.setObjectName('OsisFileLabel') - self.osisFileLayout = QtGui.QHBoxLayout() - self.osisFileLayout.setObjectName('OsisFileLayout') - self.osisFileEdit = QtGui.QLineEdit(self.osisWidget) - self.osisFileEdit.setObjectName('OsisFileEdit') - self.osisFileLayout.addWidget(self.osisFileEdit) - self.osisBrowseButton = QtGui.QToolButton(self.osisWidget) - self.osisBrowseButton.setIcon(self.open_icon) - self.osisBrowseButton.setObjectName('OsisBrowseButton') - self.osisFileLayout.addWidget(self.osisBrowseButton) - self.osisLayout.addRow(self.osisFileLabel, self.osisFileLayout) - self.osisLayout.setItem(1, QtGui.QFormLayout.LabelRole, self.spacer) - self.selectStack.addWidget(self.osisWidget) - self.csvWidget = QtGui.QWidget(self.selectPage) - self.csvWidget.setObjectName('CsvWidget') - self.csvLayout = QtGui.QFormLayout(self.csvWidget) - self.csvLayout.setMargin(0) - self.csvLayout.setObjectName('CsvLayout') - self.csvBooksLabel = QtGui.QLabel(self.csvWidget) - self.csvBooksLabel.setObjectName('CsvBooksLabel') - self.csvBooksLayout = QtGui.QHBoxLayout() - self.csvBooksLayout.setObjectName('CsvBooksLayout') - self.csvBooksEdit = QtGui.QLineEdit(self.csvWidget) - self.csvBooksEdit.setObjectName('CsvBooksEdit') - self.csvBooksLayout.addWidget(self.csvBooksEdit) - self.csvBooksButton = QtGui.QToolButton(self.csvWidget) - self.csvBooksButton.setIcon(self.open_icon) - self.csvBooksButton.setObjectName('CsvBooksButton') - self.csvBooksLayout.addWidget(self.csvBooksButton) - self.csvLayout.addRow(self.csvBooksLabel, self.csvBooksLayout) - self.csvVersesLabel = QtGui.QLabel(self.csvWidget) - self.csvVersesLabel.setObjectName('CsvVersesLabel') - self.csvVersesLayout = QtGui.QHBoxLayout() - self.csvVersesLayout.setObjectName('CsvVersesLayout') - self.csvVersesEdit = QtGui.QLineEdit(self.csvWidget) - self.csvVersesEdit.setObjectName('CsvVersesEdit') - self.csvVersesLayout.addWidget(self.csvVersesEdit) - self.csvVersesButton = QtGui.QToolButton(self.csvWidget) - self.csvVersesButton.setIcon(self.open_icon) - self.csvVersesButton.setObjectName('CsvVersesButton') - self.csvVersesLayout.addWidget(self.csvVersesButton) - self.csvLayout.addRow(self.csvVersesLabel, self.csvVersesLayout) - self.csvLayout.setItem(3, QtGui.QFormLayout.LabelRole, self.spacer) - self.selectStack.addWidget(self.csvWidget) - self.openSongWidget = QtGui.QWidget(self.selectPage) - self.openSongWidget.setObjectName('OpenSongWidget') - self.openSongLayout = QtGui.QFormLayout(self.openSongWidget) - self.openSongLayout.setMargin(0) - self.openSongLayout.setObjectName('OpenSongLayout') - self.openSongFileLabel = QtGui.QLabel(self.openSongWidget) - self.openSongFileLabel.setObjectName('OpenSongFileLabel') - self.openSongFileLayout = QtGui.QHBoxLayout() - self.openSongFileLayout.setObjectName('OpenSongFileLayout') - self.openSongFileEdit = QtGui.QLineEdit(self.openSongWidget) - self.openSongFileEdit.setObjectName('OpenSongFileEdit') - self.openSongFileLayout.addWidget(self.openSongFileEdit) - self.openSongBrowseButton = QtGui.QToolButton(self.openSongWidget) - self.openSongBrowseButton.setIcon(self.open_icon) - self.openSongBrowseButton.setObjectName('OpenSongBrowseButton') - self.openSongFileLayout.addWidget(self.openSongBrowseButton) - self.openSongLayout.addRow(self.openSongFileLabel, self.openSongFileLayout) - self.openSongLayout.setItem(1, QtGui.QFormLayout.LabelRole, self.spacer) - self.selectStack.addWidget(self.openSongWidget) - self.webTabWidget = QtGui.QTabWidget(self.selectPage) - self.webTabWidget.setObjectName('WebTabWidget') - self.webBibleTab = QtGui.QWidget() - self.webBibleTab.setObjectName('WebBibleTab') - self.webBibleLayout = QtGui.QFormLayout(self.webBibleTab) - self.webBibleLayout.setObjectName('WebBibleLayout') - self.webSourceLabel = QtGui.QLabel(self.webBibleTab) - self.webSourceLabel.setObjectName('WebSourceLabel') - self.webBibleLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.webSourceLabel) - self.webSourceComboBox = QtGui.QComboBox(self.webBibleTab) - self.webSourceComboBox.setObjectName('WebSourceComboBox') - self.webSourceComboBox.addItems(['', '', '']) - self.webBibleLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.webSourceComboBox) - self.webTranslationLabel = QtGui.QLabel(self.webBibleTab) - self.webTranslationLabel.setObjectName('webTranslationLabel') - self.webBibleLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.webTranslationLabel) - self.webTranslationComboBox = QtGui.QComboBox(self.webBibleTab) - self.webTranslationComboBox.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToContents) - self.webTranslationComboBox.setObjectName('WebTranslationComboBox') - self.webBibleLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.webTranslationComboBox) - self.webTabWidget.addTab(self.webBibleTab, '') - self.webProxyTab = QtGui.QWidget() - self.webProxyTab.setObjectName('WebProxyTab') - self.webProxyLayout = QtGui.QFormLayout(self.webProxyTab) - self.webProxyLayout.setObjectName('WebProxyLayout') - self.webServerLabel = QtGui.QLabel(self.webProxyTab) - self.webServerLabel.setObjectName('WebServerLabel') - self.webProxyLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.webServerLabel) - self.webServerEdit = QtGui.QLineEdit(self.webProxyTab) - self.webServerEdit.setObjectName('WebServerEdit') - self.webProxyLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.webServerEdit) - self.webUserLabel = QtGui.QLabel(self.webProxyTab) - self.webUserLabel.setObjectName('WebUserLabel') - self.webProxyLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.webUserLabel) - self.webUserEdit = QtGui.QLineEdit(self.webProxyTab) - self.webUserEdit.setObjectName('WebUserEdit') - self.webProxyLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.webUserEdit) - self.webPasswordLabel = QtGui.QLabel(self.webProxyTab) - self.webPasswordLabel.setObjectName('WebPasswordLabel') - self.webProxyLayout.setWidget(2, QtGui.QFormLayout.LabelRole, self.webPasswordLabel) - self.webPasswordEdit = QtGui.QLineEdit(self.webProxyTab) - self.webPasswordEdit.setObjectName('WebPasswordEdit') - self.webProxyLayout.setWidget(2, QtGui.QFormLayout.FieldRole, self.webPasswordEdit) - self.webTabWidget.addTab(self.webProxyTab, '') - self.selectStack.addWidget(self.webTabWidget) - self.selectPageLayout.addLayout(self.selectStack) - self.addPage(self.selectPage) + self.format_layout.setItem(1, QtGui.QFormLayout.LabelRole, self.spacer) + self.select_page_layout.addLayout(self.format_layout) + self.select_stack = QtGui.QStackedLayout() + self.select_stack.setObjectName('SelectStack') + self.osis_widget = QtGui.QWidget(self.select_page) + self.osis_widget.setObjectName('OsisWidget') + self.osis_layout = QtGui.QFormLayout(self.osis_widget) + self.osis_layout.setMargin(0) + self.osis_layout.setObjectName('OsisLayout') + self.osis_file_label = QtGui.QLabel(self.osis_widget) + self.osis_file_label.setObjectName('OsisFileLabel') + self.osis_file_layout = QtGui.QHBoxLayout() + self.osis_file_layout.setObjectName('OsisFileLayout') + self.osis_file_edit = QtGui.QLineEdit(self.osis_widget) + self.osis_file_edit.setObjectName('OsisFileEdit') + self.osis_file_layout.addWidget(self.osis_file_edit) + self.osis_browse_button = QtGui.QToolButton(self.osis_widget) + self.osis_browse_button.setIcon(self.open_icon) + self.osis_browse_button.setObjectName('OsisBrowseButton') + self.osis_file_layout.addWidget(self.osis_browse_button) + self.osis_layout.addRow(self.osis_file_label, self.osis_file_layout) + self.osis_layout.setItem(1, QtGui.QFormLayout.LabelRole, self.spacer) + self.select_stack.addWidget(self.osis_widget) + self.csv_widget = QtGui.QWidget(self.select_page) + self.csv_widget.setObjectName('CsvWidget') + self.csv_layout = QtGui.QFormLayout(self.csv_widget) + self.csv_layout.setMargin(0) + self.csv_layout.setObjectName('CsvLayout') + self.csv_books_label = QtGui.QLabel(self.csv_widget) + self.csv_books_label.setObjectName('CsvBooksLabel') + self.csv_books_layout = QtGui.QHBoxLayout() + self.csv_books_layout.setObjectName('CsvBooksLayout') + self.csv_books_edit = QtGui.QLineEdit(self.csv_widget) + self.csv_books_edit.setObjectName('CsvBooksEdit') + self.csv_books_layout.addWidget(self.csv_books_edit) + self.csv_books_button = QtGui.QToolButton(self.csv_widget) + self.csv_books_button.setIcon(self.open_icon) + self.csv_books_button.setObjectName('CsvBooksButton') + self.csv_books_layout.addWidget(self.csv_books_button) + self.csv_layout.addRow(self.csv_books_label, self.csv_books_layout) + self.csv_verses_label = QtGui.QLabel(self.csv_widget) + self.csv_verses_label.setObjectName('CsvVersesLabel') + self.csv_verses_layout = QtGui.QHBoxLayout() + self.csv_verses_layout.setObjectName('CsvVersesLayout') + self.csv_verses_edit = QtGui.QLineEdit(self.csv_widget) + self.csv_verses_edit.setObjectName('CsvVersesEdit') + self.csv_verses_layout.addWidget(self.csv_verses_edit) + self.csv_verses_button = QtGui.QToolButton(self.csv_widget) + self.csv_verses_button.setIcon(self.open_icon) + self.csv_verses_button.setObjectName('CsvVersesButton') + self.csv_verses_layout.addWidget(self.csv_verses_button) + self.csv_layout.addRow(self.csv_verses_label, self.csv_verses_layout) + self.csv_layout.setItem(3, QtGui.QFormLayout.LabelRole, self.spacer) + self.select_stack.addWidget(self.csv_widget) + self.open_song_widget = QtGui.QWidget(self.select_page) + self.open_song_widget.setObjectName('OpenSongWidget') + self.open_song_layout = QtGui.QFormLayout(self.open_song_widget) + self.open_song_layout.setMargin(0) + self.open_song_layout.setObjectName('OpenSongLayout') + self.open_song_file_label = QtGui.QLabel(self.open_song_widget) + self.open_song_file_label.setObjectName('OpenSongFileLabel') + self.open_song_file_layout = QtGui.QHBoxLayout() + self.open_song_file_layout.setObjectName('OpenSongFileLayout') + self.open_song_file_edit = QtGui.QLineEdit(self.open_song_widget) + self.open_song_file_edit.setObjectName('OpenSongFileEdit') + self.open_song_file_layout.addWidget(self.open_song_file_edit) + self.open_song_browse_button = QtGui.QToolButton(self.open_song_widget) + self.open_song_browse_button.setIcon(self.open_icon) + self.open_song_browse_button.setObjectName('OpenSongBrowseButton') + self.open_song_file_layout.addWidget(self.open_song_browse_button) + self.open_song_layout.addRow(self.open_song_file_label, self.open_song_file_layout) + self.open_song_layout.setItem(1, QtGui.QFormLayout.LabelRole, self.spacer) + self.select_stack.addWidget(self.open_song_widget) + self.web_tab_widget = QtGui.QTabWidget(self.select_page) + self.web_tab_widget.setObjectName('WebTabWidget') + self.web_bible_tab = QtGui.QWidget() + self.web_bible_tab.setObjectName('WebBibleTab') + self.web_bible_layout = QtGui.QFormLayout(self.web_bible_tab) + self.web_bible_layout.setObjectName('WebBibleLayout') + self.web_source_label = QtGui.QLabel(self.web_bible_tab) + self.web_source_label.setObjectName('WebSourceLabel') + self.web_bible_layout.setWidget(0, QtGui.QFormLayout.LabelRole, self.web_source_label) + self.web_source_combo_box = QtGui.QComboBox(self.web_bible_tab) + self.web_source_combo_box.setObjectName('WebSourceComboBox') + self.web_source_combo_box.addItems(['', '', '']) + self.web_bible_layout.setWidget(0, QtGui.QFormLayout.FieldRole, self.web_source_combo_box) + self.web_translation_label = QtGui.QLabel(self.web_bible_tab) + self.web_translation_label.setObjectName('web_translation_label') + self.web_bible_layout.setWidget(1, QtGui.QFormLayout.LabelRole, self.web_translation_label) + self.web_translation_combo_box = QtGui.QComboBox(self.web_bible_tab) + self.web_translation_combo_box.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToContents) + self.web_translation_combo_box.setObjectName('WebTranslationComboBox') + self.web_bible_layout.setWidget(1, QtGui.QFormLayout.FieldRole, self.web_translation_combo_box) + self.web_tab_widget.addTab(self.web_bible_tab, '') + self.web_proxy_tab = QtGui.QWidget() + self.web_proxy_tab.setObjectName('WebProxyTab') + self.web_proxy_layout = QtGui.QFormLayout(self.web_proxy_tab) + self.web_proxy_layout.setObjectName('WebProxyLayout') + self.web_server_label = QtGui.QLabel(self.web_proxy_tab) + self.web_server_label.setObjectName('WebServerLabel') + self.web_proxy_layout.setWidget(0, QtGui.QFormLayout.LabelRole, self.web_server_label) + self.web_server_edit = QtGui.QLineEdit(self.web_proxy_tab) + self.web_server_edit.setObjectName('WebServerEdit') + self.web_proxy_layout.setWidget(0, QtGui.QFormLayout.FieldRole, self.web_server_edit) + self.web_user_label = QtGui.QLabel(self.web_proxy_tab) + self.web_user_label.setObjectName('WebUserLabel') + self.web_proxy_layout.setWidget(1, QtGui.QFormLayout.LabelRole, self.web_user_label) + self.web_user_edit = QtGui.QLineEdit(self.web_proxy_tab) + self.web_user_edit.setObjectName('WebUserEdit') + self.web_proxy_layout.setWidget(1, QtGui.QFormLayout.FieldRole, self.web_user_edit) + self.web_password_label = QtGui.QLabel(self.web_proxy_tab) + self.web_password_label.setObjectName('WebPasswordLabel') + self.web_proxy_layout.setWidget(2, QtGui.QFormLayout.LabelRole, self.web_password_label) + self.web_password_edit = QtGui.QLineEdit(self.web_proxy_tab) + self.web_password_edit.setObjectName('WebPasswordEdit') + self.web_proxy_layout.setWidget(2, QtGui.QFormLayout.FieldRole, self.web_password_edit) + self.web_tab_widget.addTab(self.web_proxy_tab, '') + self.select_stack.addWidget(self.web_tab_widget) + self.select_page_layout.addLayout(self.select_stack) + self.addPage(self.select_page) # License Page - self.licenseDetailsPage = QtGui.QWizardPage() - self.licenseDetailsPage.setObjectName('LicenseDetailsPage') - self.licenseDetailsLayout = QtGui.QFormLayout(self.licenseDetailsPage) - self.licenseDetailsLayout.setObjectName('LicenseDetailsLayout') - self.versionNameLabel = QtGui.QLabel(self.licenseDetailsPage) - self.versionNameLabel.setObjectName('VersionNameLabel') - self.licenseDetailsLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.versionNameLabel) - self.versionNameEdit = QtGui.QLineEdit(self.licenseDetailsPage) - self.versionNameEdit.setObjectName('VersionNameEdit') - self.licenseDetailsLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.versionNameEdit) - self.copyrightLabel = QtGui.QLabel(self.licenseDetailsPage) - self.copyrightLabel.setObjectName('CopyrightLabel') - self.licenseDetailsLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.copyrightLabel) - self.copyrightEdit = QtGui.QLineEdit(self.licenseDetailsPage) - self.copyrightEdit.setObjectName('CopyrightEdit') - self.licenseDetailsLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.copyrightEdit) - self.permissionsLabel = QtGui.QLabel(self.licenseDetailsPage) - self.permissionsLabel.setObjectName('PermissionsLabel') - self.licenseDetailsLayout.setWidget(2, QtGui.QFormLayout.LabelRole, - self.permissionsLabel) - self.permissionsEdit = QtGui.QLineEdit(self.licenseDetailsPage) - self.permissionsEdit.setObjectName('PermissionsEdit') - self.licenseDetailsLayout.setWidget(2, QtGui.QFormLayout.FieldRole, self.permissionsEdit) - self.addPage(self.licenseDetailsPage) + self.license_details_page = QtGui.QWizardPage() + self.license_details_page.setObjectName('LicenseDetailsPage') + self.license_details_layout = QtGui.QFormLayout(self.license_details_page) + self.license_details_layout.setObjectName('LicenseDetailsLayout') + self.version_name_label = QtGui.QLabel(self.license_details_page) + self.version_name_label.setObjectName('VersionNameLabel') + self.license_details_layout.setWidget(0, QtGui.QFormLayout.LabelRole, self.version_name_label) + self.version_name_edit = QtGui.QLineEdit(self.license_details_page) + self.version_name_edit.setObjectName('VersionNameEdit') + self.license_details_layout.setWidget(0, QtGui.QFormLayout.FieldRole, self.version_name_edit) + self.copyright_label = QtGui.QLabel(self.license_details_page) + self.copyright_label.setObjectName('CopyrightLabel') + self.license_details_layout.setWidget(1, QtGui.QFormLayout.LabelRole, self.copyright_label) + self.copyright_edit = QtGui.QLineEdit(self.license_details_page) + self.copyright_edit.setObjectName('CopyrightEdit') + self.license_details_layout.setWidget(1, QtGui.QFormLayout.FieldRole, self.copyright_edit) + self.permissions_label = QtGui.QLabel(self.license_details_page) + self.permissions_label.setObjectName('PermissionsLabel') + self.license_details_layout.setWidget(2, QtGui.QFormLayout.LabelRole, self.permissions_label) + self.permissions_edit = QtGui.QLineEdit(self.license_details_page) + self.permissions_edit.setObjectName('PermissionsEdit') + self.license_details_layout.setWidget(2, QtGui.QFormLayout.FieldRole, self.permissions_edit) + self.addPage(self.license_details_page) def retranslateUi(self): """ Allow for localisation of the bible import wizard. """ self.setWindowTitle(translate('BiblesPlugin.ImportWizardForm', 'Bible Import Wizard')) - self.title_label.setText(WizardStrings.HeaderStyle % - translate('OpenLP.Ui', 'Welcome to the Bible Import Wizard')) + self.title_label.setText(WizardStrings.HeaderStyle % translate('OpenLP.Ui', + 'Welcome to the Bible Import Wizard')) self.information_label.setText( translate('BiblesPlugin.ImportWizardForm', - 'This wizard will help you to import Bibles from a variety of ' - 'formats. Click the next button below to start the process by ' - 'selecting a format to import from.')) - self.selectPage.setTitle(WizardStrings.ImportSelect) - self.selectPage.setSubTitle(WizardStrings.ImportSelectLong) - self.formatLabel.setText(WizardStrings.FormatLabel) - self.formatComboBox.setItemText(BibleFormat.OSIS, WizardStrings.OSIS) - self.formatComboBox.setItemText(BibleFormat.CSV, WizardStrings.CSV) - self.formatComboBox.setItemText(BibleFormat.OpenSong, WizardStrings.OS) - self.formatComboBox.setItemText(BibleFormat.WebDownload, - translate('BiblesPlugin.ImportWizardForm', 'Web Download')) - self.osisFileLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Bible file:')) - self.csvBooksLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Books file:')) - self.csvVersesLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Verses file:')) - self.openSongFileLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Bible file:')) - self.webSourceLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Location:')) - self.webSourceComboBox.setItemText(WebDownload.Crosswalk, - translate('BiblesPlugin.ImportWizardForm', 'Crosswalk')) - self.webSourceComboBox.setItemText(WebDownload.BibleGateway, - translate('BiblesPlugin.ImportWizardForm', 'BibleGateway')) - self.webSourceComboBox.setItemText(WebDownload.Bibleserver, - translate('BiblesPlugin.ImportWizardForm', 'Bibleserver')) - self.webTranslationLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Bible:')) - self.webTabWidget.setTabText(self.webTabWidget.indexOf(self.webBibleTab), - translate('BiblesPlugin.ImportWizardForm', 'Download Options')) - self.webServerLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Server:')) - self.webUserLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Username:')) - self.webPasswordLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Password:')) - self.webTabWidget.setTabText(self.webTabWidget.indexOf(self.webProxyTab), - translate('BiblesPlugin.ImportWizardForm', - 'Proxy Server (Optional)')) - self.licenseDetailsPage.setTitle( + 'This wizard will help you to import Bibles from a variety of ' + 'formats. Click the next button below to start the process by ' + 'selecting a format to import from.')) + self.select_page.setTitle(WizardStrings.ImportSelect) + self.select_page.setSubTitle(WizardStrings.ImportSelectLong) + self.format_label.setText(WizardStrings.FormatLabel) + self.format_combo_box.setItemText(BibleFormat.OSIS, WizardStrings.OSIS) + self.format_combo_box.setItemText(BibleFormat.CSV, WizardStrings.CSV) + self.format_combo_box.setItemText(BibleFormat.OpenSong, WizardStrings.OS) + self.format_combo_box.setItemText(BibleFormat.WebDownload, translate('BiblesPlugin.ImportWizardForm', + 'Web Download')) + self.osis_file_label.setText(translate('BiblesPlugin.ImportWizardForm', 'Bible file:')) + self.csv_books_label.setText(translate('BiblesPlugin.ImportWizardForm', 'Books file:')) + self.csv_verses_label.setText(translate('BiblesPlugin.ImportWizardForm', 'Verses file:')) + self.open_song_file_label.setText(translate('BiblesPlugin.ImportWizardForm', 'Bible file:')) + self.web_source_label.setText(translate('BiblesPlugin.ImportWizardForm', 'Location:')) + self.web_source_combo_box.setItemText(WebDownload.Crosswalk, translate('BiblesPlugin.ImportWizardForm', + 'Crosswalk')) + self.web_source_combo_box.setItemText(WebDownload.BibleGateway, translate('BiblesPlugin.ImportWizardForm', + 'BibleGateway')) + self.web_source_combo_box.setItemText(WebDownload.Bibleserver, translate('BiblesPlugin.ImportWizardForm', + 'Bibleserver')) + self.web_translation_label.setText(translate('BiblesPlugin.ImportWizardForm', 'Bible:')) + self.web_tab_widget.setTabText(self.web_tab_widget.indexOf(self.web_bible_tab), + translate('BiblesPlugin.ImportWizardForm', 'Download Options')) + self.web_server_label.setText(translate('BiblesPlugin.ImportWizardForm', 'Server:')) + self.web_user_label.setText(translate('BiblesPlugin.ImportWizardForm', 'Username:')) + self.web_password_label.setText(translate('BiblesPlugin.ImportWizardForm', 'Password:')) + self.web_tab_widget.setTabText( + self.web_tab_widget.indexOf(self.web_proxy_tab), translate('BiblesPlugin.ImportWizardForm', + 'Proxy Server (Optional)')) + self.license_details_page.setTitle( translate('BiblesPlugin.ImportWizardForm', 'License Details')) - self.licenseDetailsPage.setSubTitle(translate('BiblesPlugin.ImportWizardForm', - 'Set up the Bible\'s license details.')) - self.versionNameLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Version name:')) - self.copyrightLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Copyright:')) - self.permissionsLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Permissions:')) + self.license_details_page.setSubTitle(translate('BiblesPlugin.ImportWizardForm', + 'Set up the Bible\'s license details.')) + self.version_name_label.setText(translate('BiblesPlugin.ImportWizardForm', 'Version name:')) + self.copyright_label.setText(translate('BiblesPlugin.ImportWizardForm', 'Copyright:')) + self.permissions_label.setText(translate('BiblesPlugin.ImportWizardForm', 'Permissions:')) self.progress_page.setTitle(WizardStrings.Importing) self.progress_page.setSubTitle(translate('BiblesPlugin.ImportWizardForm', - 'Please wait while your Bible is imported.')) + 'Please wait while your Bible is imported.')) self.progress_label.setText(WizardStrings.Ready) self.progress_bar.setFormat('%p%') # Align all QFormLayouts towards each other. - labelWidth = max(self.formatLabel.minimumSizeHint().width(), - self.osisFileLabel.minimumSizeHint().width(), - self.csvBooksLabel.minimumSizeHint().width(), - self.csvVersesLabel.minimumSizeHint().width(), - self.openSongFileLabel.minimumSizeHint().width()) - self.spacer.changeSize(labelWidth, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) + label_width = max(self.format_label.minimumSizeHint().width(), + self.osis_file_label.minimumSizeHint().width(), + self.csv_books_label.minimumSizeHint().width(), + self.csv_verses_label.minimumSizeHint().width(), + self.open_song_file_label.minimumSizeHint().width()) + self.spacer.changeSize(label_width, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) def validateCurrentPage(self): """ @@ -340,122 +340,130 @@ class BibleImportForm(OpenLPWizard): """ if self.currentPage() == self.welcome_page: return True - elif self.currentPage() == self.selectPage: + elif self.currentPage() == self.select_page: if self.field('source_format') == BibleFormat.OSIS: if not self.field('osis_location'): critical_error_message_box(UiStrings().NFSs, WizardStrings.YouSpecifyFile % WizardStrings.OSIS) - self.osisFileEdit.setFocus() + self.osis_file_edit.setFocus() return False elif self.field('source_format') == BibleFormat.CSV: if not self.field('csv_booksfile'): - critical_error_message_box(UiStrings().NFSs, translate('BiblesPlugin.ImportWizardForm', - 'You need to specify a file with books of the Bible to use in the import.')) - self.csvBooksEdit.setFocus() + critical_error_message_box( + UiStrings().NFSs, translate('BiblesPlugin.ImportWizardForm', + 'You need to specify a file with books of the Bible to use in the ' + 'import.')) + self.csv_books_edit.setFocus() return False elif not self.field('csv_versefile'): - critical_error_message_box(UiStrings().NFSs, - translate('BiblesPlugin.ImportWizardForm', - 'You need to specify a file of Bible verses to import.')) - self.csvVersesEdit.setFocus() + critical_error_message_box( + UiStrings().NFSs, + translate('BiblesPlugin.ImportWizardForm', 'You need to specify a file of Bible verses to ' + 'import.')) + self.csv_verses_edit.setFocus() return False elif self.field('source_format') == BibleFormat.OpenSong: if not self.field('opensong_file'): critical_error_message_box(UiStrings().NFSs, WizardStrings.YouSpecifyFile % WizardStrings.OS) - self.openSongFileEdit.setFocus() + self.open_song_file_edit.setFocus() return False elif self.field('source_format') == BibleFormat.WebDownload: - self.versionNameEdit.setText(self.webTranslationComboBox.currentText()) + self.version_name_edit.setText(self.web_translation_combo_box.currentText()) return True return True - elif self.currentPage() == self.licenseDetailsPage: + elif self.currentPage() == self.license_details_page: license_version = self.field('license_version') license_copyright = self.field('license_copyright') path = AppLocation.get_section_data_path('bibles') if not license_version: - critical_error_message_box(UiStrings().EmptyField, + critical_error_message_box( + UiStrings().EmptyField, translate('BiblesPlugin.ImportWizardForm', 'You need to specify a version name for your Bible.')) - self.versionNameEdit.setFocus() + self.version_name_edit.setFocus() return False elif not license_copyright: - critical_error_message_box(UiStrings().EmptyField, + critical_error_message_box( + UiStrings().EmptyField, translate('BiblesPlugin.ImportWizardForm', 'You need to set a copyright for your Bible. ' - 'Bibles in the Public Domain need to be marked as such.')) - self.copyrightEdit.setFocus() + 'Bibles in the Public Domain need to be marked as such.')) + self.copyright_edit.setFocus() return False elif self.manager.exists(license_version): - critical_error_message_box(translate('BiblesPlugin.ImportWizardForm', 'Bible Exists'), + critical_error_message_box( + translate('BiblesPlugin.ImportWizardForm', 'Bible Exists'), translate('BiblesPlugin.ImportWizardForm', - 'This Bible already exists. Please import a different Bible or first delete the existing one.')) - self.versionNameEdit.setFocus() + 'This Bible already exists. Please import a different Bible or first delete the ' + 'existing one.')) + self.version_name_edit.setFocus() return False - elif os.path.exists(os.path.join(path, clean_filename( - license_version))): + elif os.path.exists(os.path.join(path, clean_filename(license_version))): critical_error_message_box( translate('BiblesPlugin.ImportWizardForm', 'Bible Exists'), translate('BiblesPlugin.ImportWizardForm', 'This Bible already exists. Please import ' - 'a different Bible or first delete the existing one.')) - self.versionNameEdit.setFocus() + 'a different Bible or first delete the existing one.')) + self.version_name_edit.setFocus() return False return True if self.currentPage() == self.progress_page: return True - def onWebSourceComboBoxIndexChanged(self, index): + def on_web_source_combo_box_index_changed(self, index): """ - Setup the list of Bibles when you select a different source on the web - download page. + Setup the list of Bibles when you select a different source on the web download page. - ``index`` - The index of the combo box. + :param index: The index of the combo box. """ - self.webTranslationComboBox.clear() + self.web_translation_combo_box.clear() bibles = list(self.web_bible_list[index].keys()) bibles.sort(key=get_locale_key) - self.webTranslationComboBox.addItems(bibles) + self.web_translation_combo_box.addItems(bibles) - def onOsisBrowseButtonClicked(self): + def on_osis_browse_button_clicked(self): """ Show the file open dialog for the OSIS file. """ - self.get_file_name(WizardStrings.OpenTypeFile % WizardStrings.OSIS, self.osisFileEdit, 'last directory import') + self.get_file_name(WizardStrings.OpenTypeFile % WizardStrings.OSIS, self.osis_file_edit, + 'last directory import') - def onCsvBooksBrowseButtonClicked(self): + def on_csv_books_browse_button_clicked(self): """ Show the file open dialog for the books CSV file. """ - self.get_file_name(WizardStrings.OpenTypeFile % WizardStrings.CSV, self.csvBooksEdit, 'last directory import', - '%s (*.csv)' % translate('BiblesPlugin.ImportWizardForm', 'CSV File')) + self.get_file_name( + WizardStrings.OpenTypeFile % WizardStrings.CSV, self.csv_books_edit, 'last directory import', '%s (*.csv)' % + translate('BiblesPlugin.ImportWizardForm', 'CSV File')) - def onCsvVersesBrowseButtonClicked(self): + def on_csv_verses_browse_button_clicked(self): """ Show the file open dialog for the verses CSV file. """ - self.get_file_name(WizardStrings.OpenTypeFile % WizardStrings.CSV, self.csvVersesEdit, 'last directory import', - '%s (*.csv)' % translate('BiblesPlugin.ImportWizardForm', 'CSV File')) + self.get_file_name(WizardStrings.OpenTypeFile % WizardStrings.CSV, self.csv_verses_edit, + 'last directory import', '%s (*.csv)' % + translate('BiblesPlugin.ImportWizardForm', 'CSV File')) - def onOpenSongBrowseButtonClicked(self): + def on_open_song_browse_button_clicked(self): """ Show the file open dialog for the OpenSong file. """ - self.get_file_name(WizardStrings.OpenTypeFile % WizardStrings.OS, self.openSongFileEdit, 'last directory import') + self.get_file_name(WizardStrings.OpenTypeFile % WizardStrings.OS, self.open_song_file_edit, + 'last directory import') def register_fields(self): """ Register the bible import wizard fields. """ - self.selectPage.registerField('source_format', self.formatComboBox) - self.selectPage.registerField('osis_location', self.osisFileEdit) - self.selectPage.registerField('csv_booksfile', self.csvBooksEdit) - self.selectPage.registerField('csv_versefile', self.csvVersesEdit) - self.selectPage.registerField('opensong_file', self.openSongFileEdit) - self.selectPage.registerField('web_location', self.webSourceComboBox) - self.selectPage.registerField('web_biblename', self.webTranslationComboBox) - self.selectPage.registerField('proxy_server', self.webServerEdit) - self.selectPage.registerField('proxy_username', self.webUserEdit) - self.selectPage.registerField('proxy_password', self.webPasswordEdit) - self.licenseDetailsPage.registerField('license_version', self.versionNameEdit) - self.licenseDetailsPage.registerField('license_copyright', self.copyrightEdit) - self.licenseDetailsPage.registerField('license_permissions', self.permissionsEdit) + self.select_page.registerField('source_format', self.format_combo_box) + self.select_page.registerField('osis_location', self.osis_file_edit) + self.select_page.registerField('csv_booksfile', self.csv_books_edit) + self.select_page.registerField('csv_versefile', self.csv_verses_edit) + self.select_page.registerField('opensong_file', self.open_song_file_edit) + self.select_page.registerField('web_location', self.web_source_combo_box) + self.select_page.registerField('web_biblename', self.web_translation_combo_box) + self.select_page.registerField('proxy_server', self.web_server_edit) + self.select_page.registerField('proxy_username', self.web_user_edit) + self.select_page.registerField('proxy_password', self.web_password_edit) + self.license_details_page.registerField('license_version', self.version_name_edit) + self.license_details_page.registerField('license_copyright', self.copyright_edit) + self.license_details_page.registerField('license_permissions', self.permissions_edit) def setDefaults(self): """ @@ -472,33 +480,32 @@ class BibleImportForm(OpenLPWizard): self.setField('csv_versefile', '') self.setField('opensong_file', '') self.setField('web_location', WebDownload.Crosswalk) - self.setField('web_biblename', self.webTranslationComboBox.currentIndex()) + self.setField('web_biblename', self.web_translation_combo_box.currentIndex()) self.setField('proxy_server', settings.value('proxy address')) self.setField('proxy_username', settings.value('proxy username')) self.setField('proxy_password', settings.value('proxy password')) - self.setField('license_version', self.versionNameEdit.text()) - self.setField('license_copyright', self.copyrightEdit.text()) - self.setField('license_permissions', self.permissionsEdit.text()) - self.onWebSourceComboBoxIndexChanged(WebDownload.Crosswalk) + self.setField('license_version', self.version_name_edit.text()) + self.setField('license_copyright', self.copyright_edit.text()) + self.setField('license_permissions', self.permissions_edit.text()) + self.on_web_source_combo_box_index_changed(WebDownload.Crosswalk) settings.endGroup() - def loadWebBibles(self): + def load_Web_Bibles(self): """ Load the lists of Crosswalk, BibleGateway and Bibleserver bibles. """ # Load Crosswalk Bibles. - self.loadBibleResource(WebDownload.Crosswalk) + self.load_Bible_Resource(WebDownload.Crosswalk) # Load BibleGateway Bibles. - self.loadBibleResource(WebDownload.BibleGateway) + self.load_Bible_Resource(WebDownload.BibleGateway) # Load and Bibleserver Bibles. - self.loadBibleResource(WebDownload.Bibleserver) + self.load_Bible_Resource(WebDownload.Bibleserver) - def loadBibleResource(self, download_type): + def load_Bible_Resource(self, download_type): """ Loads a web bible from bible_resources.sqlite. - ``download_type`` - The WebDownload type e.g. bibleserver. + :param download_type: The WebDownload type e.g. bibleserver. """ self.web_bible_list[download_type] = {} bibles = BiblesResourcesDB.get_webbibles(WebDownload.Names[download_type]) @@ -530,28 +537,22 @@ class BibleImportForm(OpenLPWizard): importer = None if bible_type == BibleFormat.OSIS: # Import an OSIS bible. - importer = self.manager.import_bible(BibleFormat.OSIS, - name=license_version, - filename=self.field('osis_location') - ) + importer = self.manager.import_bible(BibleFormat.OSIS, name=license_version, + filename=self.field('osis_location')) elif bible_type == BibleFormat.CSV: # Import a CSV bible. - importer = self.manager.import_bible(BibleFormat.CSV, - name=license_version, - booksfile=self.field('csv_booksfile'), - versefile=self.field('csv_versefile') - ) + importer = self.manager.import_bible(BibleFormat.CSV, name=license_version, + booksfile=self.field('csv_booksfile'), + versefile=self.field('csv_versefile')) elif bible_type == BibleFormat.OpenSong: # Import an OpenSong bible. - importer = self.manager.import_bible(BibleFormat.OpenSong, - name=license_version, - filename=self.field('opensong_file') - ) + importer = self.manager.import_bible(BibleFormat.OpenSong, name=license_version, + filename=self.field('opensong_file')) elif bible_type == BibleFormat.WebDownload: # Import a bible from the web. self.progress_bar.setMaximum(1) download_location = self.field('web_location') - bible_version = self.webTranslationComboBox.currentText() + bible_version = self.web_translation_combo_box.currentText() bible = self.web_bible_list[download_location][bible_version] importer = self.manager.import_bible( BibleFormat.WebDownload, name=license_version, @@ -562,13 +563,12 @@ class BibleImportForm(OpenLPWizard): proxy_password=self.field('proxy_password') ) if importer.do_import(license_version): - self.manager.save_meta_data(license_version, license_version, - license_copyright, license_permissions) + self.manager.save_meta_data(license_version, license_version, license_copyright, license_permissions) self.manager.reload_bibles() if bible_type == BibleFormat.WebDownload: self.progress_label.setText( translate('BiblesPlugin.ImportWizardForm', 'Registered Bible. Please note, that verses will be ' - 'downloaded on\ndemand and thus an internet connection is required.')) + 'downloaded on\ndemand and thus an internet connection is required.')) else: self.progress_label.setText(WizardStrings.FinishedImport) else: diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index 2b574f778..9925b1ebc 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -96,34 +96,34 @@ class BibleUpgradeForm(OpenLPWizard): if not self.currentPage() == self.progress_page: self.done(QtGui.QDialog.Rejected) - def onCurrentIdChanged(self, pageId): + def onCurrentIdChanged(self, page_id): """ Perform necessary functions depending on which wizard page is active. """ - if self.page(pageId) == self.progress_page: + if self.page(page_id) == self.progress_page: self.pre_wizard() self.perform_wizard() self.post_wizard() - elif self.page(pageId) == self.selectPage and not self.files: + elif self.page(page_id) == self.selectPage and not self.files: self.next() - def onBackupBrowseButtonClicked(self): + def on_backup_browse_button_clicked(self): """ Show the file open dialog for the OSIS file. """ - filename = QtGui.QFileDialog.getExistingDirectory(self, - translate('BiblesPlugin.UpgradeWizardForm', 'Select a Backup Directory'), '') + filename = QtGui.QFileDialog.getExistingDirectory(self, translate('BiblesPlugin.UpgradeWizardForm', + 'Select a Backup Directory'), '') if filename: self.backupDirectoryEdit.setText(filename) - def onNoBackupCheckBoxToggled(self, checked): + def on_no_backup_check_box_toggled(self, checked): """ Enable or disable the backup directory widgets. """ self.backupDirectoryEdit.setEnabled(not checked) self.backupBrowseButton.setEnabled(not checked) - def backupOldBibles(self, backup_directory): + def backup_old_bibles(self, backup_directory): """ Backup old bible databases in a given folder. """ @@ -147,8 +147,8 @@ class BibleUpgradeForm(OpenLPWizard): """ Set up the signals used in the bible importer. """ - self.backupBrowseButton.clicked.connect(self.onBackupBrowseButtonClicked) - self.noBackupCheckBox.toggled.connect(self.onNoBackupCheckBoxToggled) + self.backupBrowseButton.clicked.connect(self.on_backup_browse_button_clicked) + self.noBackupCheckBox.toggled.connect(self.on_no_backup_check_box_toggled) def add_custom_pages(self): """ @@ -238,32 +238,34 @@ class BibleUpgradeForm(OpenLPWizard): Allow for localisation of the bible import wizard. """ self.setWindowTitle(translate('BiblesPlugin.UpgradeWizardForm', 'Bible Upgrade Wizard')) - self.title_label.setText(WizardStrings.HeaderStyle % - translate('OpenLP.Ui', 'Welcome to the Bible Upgrade Wizard')) - self.information_label.setText(translate('BiblesPlugin.UpgradeWizardForm', - 'This wizard will help you to upgrade your existing Bibles from a prior version of OpenLP 2. ' - 'Click the next button below to start the upgrade process.')) + self.title_label.setText(WizardStrings.HeaderStyle % translate('OpenLP.Ui', + 'Welcome to the Bible Upgrade Wizard')) + self.information_label.setText( + translate('BiblesPlugin.UpgradeWizardForm', + 'This wizard will help you to upgrade your existing Bibles from a prior version of OpenLP 2. ' + 'Click the next button below to start the upgrade process.')) self.backup_page.setTitle(translate('BiblesPlugin.UpgradeWizardForm', 'Select Backup Directory')) - self.backup_page.setSubTitle(translate('BiblesPlugin.UpgradeWizardForm', - 'Please select a backup directory for your Bibles')) - self.backupInfoLabel.setText(translate('BiblesPlugin.UpgradeWizardForm', - 'Previous releases of OpenLP 2.0 are unable to use upgraded Bibles.' - ' This will create a backup of your current Bibles so that you can ' - 'simply copy the files back to your OpenLP data directory if you ' - 'need to revert to a previous release of OpenLP. Instructions on ' - 'how to restore the files can be found in our <a href="' - 'http://wiki.openlp.org/faq">Frequently Asked Questions</a>.')) - self.selectLabel.setText(translate('BiblesPlugin.UpgradeWizardForm', - 'Please select a backup location for your Bibles.')) + self.backup_page.setSubTitle( + translate('BiblesPlugin.UpgradeWizardForm', 'Please select a backup directory for your Bibles')) + self.backupInfoLabel.setText( + translate('BiblesPlugin.UpgradeWizardForm', + 'Previous releases of OpenLP 2.0 are unable to use upgraded Bibles.' + ' This will create a backup of your current Bibles so that you can ' + 'simply copy the files back to your OpenLP data directory if you ' + 'need to revert to a previous release of OpenLP. Instructions on ' + 'how to restore the files can be found in our <a href="' + 'http://wiki.openlp.org/faq">Frequently Asked Questions</a>.')) + self.selectLabel.setText( + translate('BiblesPlugin.UpgradeWizardForm', 'Please select a backup location for your Bibles.')) self.backupDirectoryLabel.setText(translate('BiblesPlugin.UpgradeWizardForm', 'Backup Directory:')) self.noBackupCheckBox.setText( translate('BiblesPlugin.UpgradeWizardForm', 'There is no need to backup my Bibles')) self.selectPage.setTitle(translate('BiblesPlugin.UpgradeWizardForm', 'Select Bibles')) - self.selectPage.setSubTitle(translate('BiblesPlugin.UpgradeWizardForm', - 'Please select the Bibles to upgrade')) + self.selectPage.setSubTitle( + translate('BiblesPlugin.UpgradeWizardForm', 'Please select the Bibles to upgrade')) self.progress_page.setTitle(translate('BiblesPlugin.UpgradeWizardForm', 'Upgrading')) - self.progress_page.setSubTitle(translate('BiblesPlugin.UpgradeWizardForm', - 'Please wait while your Bibles are upgraded.')) + self.progress_page.setSubTitle( + translate('BiblesPlugin.UpgradeWizardForm', 'Please wait while your Bibles are upgraded.')) self.progress_label.setText(WizardStrings.Ready) self.progress_bar.setFormat('%p%') @@ -277,16 +279,18 @@ class BibleUpgradeForm(OpenLPWizard): if not self.noBackupCheckBox.checkState() == QtCore.Qt.Checked: backup_path = self.backupDirectoryEdit.text() if not backup_path: - critical_error_message_box(UiStrings().EmptyField, - translate('BiblesPlugin.UpgradeWizardForm', - 'You need to specify a backup directory for your Bibles.')) + critical_error_message_box( + UiStrings().EmptyField, + translate('BiblesPlugin.UpgradeWizardForm', 'You need to specify a backup directory for ' + 'your Bibles.')) self.backupDirectoryEdit.setFocus() return False else: - if not self.backupOldBibles(backup_path): - critical_error_message_box(UiStrings().Error, - translate('BiblesPlugin.UpgradeWizardForm', 'The backup was not successful.\nTo backup your ' - 'Bibles you need permission to write to the given directory.')) + if not self.backup_old_bibles(backup_path): + critical_error_message_box( + UiStrings().Error, + translate('BiblesPlugin.UpgradeWizardForm', 'The backup was not successful.\nTo backup ' + 'your Bibles you need permission to write to the given directory.')) return False return True elif self.currentPage() == self.selectPage: @@ -340,8 +344,8 @@ class BibleUpgradeForm(OpenLPWizard): self.includeWebBible = False proxy_server = None if not self.files: - self.progress_label.setText(translate('BiblesPlugin.UpgradeWizardForm', - 'There are no Bibles that need to be upgraded.')) + self.progress_label.setText( + translate('BiblesPlugin.UpgradeWizardForm', 'There are no Bibles that need to be upgraded.')) self.progress_bar.hide() return max_bibles = 0 @@ -363,11 +367,11 @@ class BibleUpgradeForm(OpenLPWizard): self.success[number] = False continue self.progress_bar.reset() - old_bible = OldBibleDB(self.media_item, path=self.temp_dir, - file=filename[0]) + old_bible = OldBibleDB(self.media_item, path=self.temp_dir, file=filename[0]) name = filename[1] - self.progress_label.setText(translate('BiblesPlugin.UpgradeWizardForm', - 'Upgrading Bible %s of %s: "%s"\nUpgrading ...') % (number + 1, max_bibles, name)) + self.progress_label.setText( + translate('BiblesPlugin.UpgradeWizardForm', + 'Upgrading Bible %s of %s: "%s"\nUpgrading ...') % (number + 1, max_bibles, name)) self.new_bibles[number] = BibleDB(self.media_item, path=self.path, name=name, file=filename[0]) self.new_bibles[number].register(self.plugin.upgrade_wizard) metadata = old_bible.get_metadata() @@ -404,7 +408,7 @@ class BibleUpgradeForm(OpenLPWizard): critical_error_message_box( translate('BiblesPlugin.UpgradeWizardForm', 'Download Error'), translate('BiblesPlugin.UpgradeWizardForm', - 'To upgrade your Web Bibles an Internet connection is required.')) + 'To upgrade your Web Bibles an Internet connection is required.')) self.increment_progress_bar(translate( 'BiblesPlugin.UpgradeWizardForm', 'Upgrading Bible %s of %s: "%s"\nFailed') % (number + 1, max_bibles, name), self.progress_bar.maximum() - self.progress_bar.value()) @@ -415,16 +419,16 @@ class BibleUpgradeForm(OpenLPWizard): meta_data['download_source'].lower()) if bible and bible['language_id']: language_id = bible['language_id'] - self.new_bibles[number].save_meta('language_id', - language_id) + self.new_bibles[number].save_meta('language_id', language_id) else: language_id = self.new_bibles[number].get_language(name) if not language_id: log.warn('Upgrading from "%s" failed' % filename[0]) self.new_bibles[number].session.close() del self.new_bibles[number] - self.increment_progress_bar(translate('BiblesPlugin.UpgradeWizardForm', - 'Upgrading Bible %s of %s: "%s"\nFailed') % (number + 1, max_bibles, name), + self.increment_progress_bar( + translate('BiblesPlugin.UpgradeWizardForm', + 'Upgrading Bible %s of %s: "%s"\nFailed') % (number + 1, max_bibles, name), self.progress_bar.maximum() - self.progress_bar.value()) self.success[number] = False continue @@ -433,8 +437,10 @@ class BibleUpgradeForm(OpenLPWizard): if self.stop_import_flag: self.success[number] = False break - self.increment_progress_bar(translate('BiblesPlugin.UpgradeWizardForm', - 'Upgrading Bible %s of %s: "%s"\nUpgrading %s ...') % (number + 1, max_bibles, name, book)) + self.increment_progress_bar( + translate('BiblesPlugin.UpgradeWizardForm', + 'Upgrading Bible %s of %s: "%s"\nUpgrading %s ...') % + (number + 1, max_bibles, name, book)) book_ref_id = self.new_bibles[number].\ get_book_ref_id_by_name(book, len(books), language_id) if not book_ref_id: @@ -445,8 +451,7 @@ class BibleUpgradeForm(OpenLPWizard): self.success[number] = False break book_details = BiblesResourcesDB.get_book_by_id(book_ref_id) - db_book = self.new_bibles[number].create_book(book, - book_ref_id, book_details['testament_id']) + db_book = self.new_bibles[number].create_book(book, book_ref_id, book_details['testament_id']) # Try to import already downloaded verses. oldbook = old_bible.get_book(book) if oldbook: @@ -458,9 +463,8 @@ class BibleUpgradeForm(OpenLPWizard): if self.stop_import_flag: self.success[number] = False break - self.new_bibles[number].create_verse(db_book.id, - int(verse['chapter']), - int(verse['verse']), str(verse['text'])) + self.new_bibles[number].create_verse(db_book.id, int(verse['chapter']), + int(verse['verse']), str(verse['text'])) self.application.process_events() self.new_bibles[number].session.commit() else: @@ -471,8 +475,9 @@ class BibleUpgradeForm(OpenLPWizard): log.warn('Upgrading books from "%s" failed' % name) self.new_bibles[number].session.close() del self.new_bibles[number] - self.increment_progress_bar(translate('BiblesPlugin.UpgradeWizardForm', - 'Upgrading Bible %s of %s: "%s"\nFailed') % (number + 1, max_bibles, name), + self.increment_progress_bar( + translate('BiblesPlugin.UpgradeWizardForm', + 'Upgrading Bible %s of %s: "%s"\nFailed') % (number + 1, max_bibles, name), self.progress_bar.maximum() - self.progress_bar.value()) self.success[number] = False continue @@ -482,8 +487,9 @@ class BibleUpgradeForm(OpenLPWizard): if self.stop_import_flag: self.success[number] = False break - self.increment_progress_bar(translate('BiblesPlugin.UpgradeWizardForm', - 'Upgrading Bible %s of %s: "%s"\nUpgrading %s ...') % + self.increment_progress_bar( + translate('BiblesPlugin.UpgradeWizardForm', + 'Upgrading Bible %s of %s: "%s"\nUpgrading %s ...') % (number + 1, max_bibles, name, book['name'])) book_ref_id = self.new_bibles[number].get_book_ref_id_by_name(book['name'], len(books), language_id) if not book_ref_id: @@ -493,8 +499,8 @@ class BibleUpgradeForm(OpenLPWizard): self.success[number] = False break book_details = BiblesResourcesDB.get_book_by_id(book_ref_id) - db_book = self.new_bibles[number].create_book(book['name'], - book_ref_id, book_details['testament_id']) + db_book = self.new_bibles[number].create_book(book['name'], book_ref_id, + book_details['testament_id']) verses = old_bible.get_verses(book['id']) if not verses: log.warn('No verses found to import for book "%s"', book['name']) @@ -504,20 +510,21 @@ class BibleUpgradeForm(OpenLPWizard): if self.stop_import_flag: self.success[number] = False break - self.new_bibles[number].create_verse(db_book.id, - int(verse['chapter']), - int(verse['verse']), str(verse['text'])) + self.new_bibles[number].create_verse(db_book.id, int(verse['chapter']), int(verse['verse']), + str(verse['text'])) self.application.process_events() self.new_bibles[number].session.commit() if not self.success.get(number, True): - self.increment_progress_bar(translate('BiblesPlugin.UpgradeWizardForm', - 'Upgrading Bible %s of %s: "%s"\nFailed') % (number + 1, max_bibles, name), + self.increment_progress_bar( + translate('BiblesPlugin.UpgradeWizardForm', + 'Upgrading Bible %s of %s: "%s"\nFailed') % (number + 1, max_bibles, name), self.progress_bar.maximum() - self.progress_bar.value()) else: self.success[number] = True self.new_bibles[number].save_meta('name', name) - self.increment_progress_bar(translate('BiblesPlugin.UpgradeWizardForm', - 'Upgrading Bible %s of %s: "%s"\nComplete') % (number + 1, max_bibles, name)) + self.increment_progress_bar( + translate('BiblesPlugin.UpgradeWizardForm', + 'Upgrading Bible %s of %s: "%s"\nComplete') % (number + 1, max_bibles, name)) if number in self.new_bibles: self.new_bibles[number].session.close() # Close the last bible's connection if possible. @@ -545,12 +552,15 @@ class BibleUpgradeForm(OpenLPWizard): failed_import_text = '' if successful_import > 0: if self.includeWebBible: - self.progress_label.setText(translate('BiblesPlugin.UpgradeWizardForm', - 'Upgrading Bible(s): %s successful%s\nPlease note that verses from Web Bibles will be downloaded ' - 'on demand and so an Internet connection is required.') % (successful_import, failed_import_text)) + self.progress_label.setText( + translate('BiblesPlugin.UpgradeWizardForm', + 'Upgrading Bible(s): %s successful%s\nPlease note that verses from Web Bibles will be ' + 'downloaded on demand and so an Internet connection is required.') % + (successful_import, failed_import_text)) else: - self.progress_label.setText(translate('BiblesPlugin.UpgradeWizardForm', - 'Upgrading Bible(s): %s successful%s') % (successful_import, failed_import_text)) + self.progress_label.setText( + translate('BiblesPlugin.UpgradeWizardForm', 'Upgrading Bible(s): %s successful%s') % ( + successful_import, failed_import_text)) else: self.progress_label.setText(translate('BiblesPlugin.UpgradeWizardForm', 'Upgrade failed.')) # Remove temp directory. diff --git a/openlp/plugins/bibles/forms/booknamedialog.py b/openlp/plugins/bibles/forms/booknamedialog.py index 66eae6b09..5903391c3 100644 --- a/openlp/plugins/bibles/forms/booknamedialog.py +++ b/openlp/plugins/bibles/forms/booknamedialog.py @@ -32,6 +32,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.common import translate from openlp.core.lib.ui import create_button_box + class Ui_BookNameDialog(object): def setupUi(self, book_name_dialog): book_name_dialog.setObjectName('book_name_dialog') @@ -48,15 +49,15 @@ class Ui_BookNameDialog(object): self.corresponding_layout.setColumnStretch(1, 1) self.corresponding_layout.setSpacing(8) self.corresponding_layout.setObjectName('corresponding_layout') - self.currentLabel = QtGui.QLabel(book_name_dialog) - self.currentLabel.setObjectName('currentLabel') - self.corresponding_layout.addWidget(self.currentLabel, 0, 0, 1, 1) + self.current_label = QtGui.QLabel(book_name_dialog) + self.current_label.setObjectName('current_label') + self.corresponding_layout.addWidget(self.current_label, 0, 0, 1, 1) self.current_book_label = QtGui.QLabel(book_name_dialog) self.current_book_label.setObjectName('current_book_label') self.corresponding_layout.addWidget(self.current_book_label, 0, 1, 1, 1) - self.correspondingLabel = QtGui.QLabel(book_name_dialog) - self.correspondingLabel.setObjectName('correspondingLabel') - self.corresponding_layout.addWidget(self.correspondingLabel, 1, 0, 1, 1) + self.corresponding_label = QtGui.QLabel(book_name_dialog) + self.corresponding_label.setObjectName('corresponding_label') + self.corresponding_layout.addWidget(self.corresponding_label, 1, 0, 1, 1) self.corresponding_combo_box = QtGui.QComboBox(book_name_dialog) self.corresponding_combo_box.setObjectName('corresponding_combo_box') self.corresponding_layout.addWidget(self.corresponding_combo_box, 1, 1, 1, 1) @@ -87,11 +88,11 @@ class Ui_BookNameDialog(object): def retranslateUi(self, book_name_dialog): book_name_dialog.setWindowTitle(translate('BiblesPlugin.BookNameDialog', 'Select Book Name')) - self.info_label.setText(translate('BiblesPlugin.BookNameDialog', - 'The following book name cannot be matched up internally. ' - 'Please select the corresponding name from the list.')) - self.currentLabel.setText(translate('BiblesPlugin.BookNameDialog', 'Current name:')) - self.correspondingLabel.setText(translate('BiblesPlugin.BookNameDialog', 'Corresponding name:')) + self.info_label.setText( + translate('BiblesPlugin.BookNameDialog', 'The following book name cannot be matched up internally. ' + 'Please select the corresponding name from the list.')) + self.current_label.setText(translate('BiblesPlugin.BookNameDialog', 'Current name:')) + self.corresponding_label.setText(translate('BiblesPlugin.BookNameDialog', 'Corresponding name:')) self.options_group_box.setTitle(translate('BiblesPlugin.BookNameDialog', 'Show Books From')) self.old_testament_check_box.setText(translate('BiblesPlugin.BookNameDialog', 'Old Testament')) self.new_testament_check_box.setText(translate('BiblesPlugin.BookNameDialog', 'New Testament')) diff --git a/openlp/plugins/bibles/forms/booknameform.py b/openlp/plugins/bibles/forms/booknameform.py index 063a6618c..7d1242b7c 100644 --- a/openlp/plugins/bibles/forms/booknameform.py +++ b/openlp/plugins/bibles/forms/booknameform.py @@ -52,7 +52,7 @@ class BookNameForm(QDialog, Ui_BookNameDialog): """ log.info('BookNameForm loaded') - def __init__(self, parent = None): + def __init__(self, parent=None): """ Constructor """ @@ -66,11 +66,11 @@ class BookNameForm(QDialog, Ui_BookNameDialog): """ Set up the signals used in the booknameform. """ - self.old_testament_check_box.stateChanged.connect(self.onCheckBoxIndexChanged) - self.new_testament_check_box.stateChanged.connect(self.onCheckBoxIndexChanged) - self.apocrypha_check_box.stateChanged.connect(self.onCheckBoxIndexChanged) + self.old_testament_check_box.stateChanged.connect(self.on_check_box_index_changed) + self.new_testament_check_box.stateChanged.connect(self.on_check_box_index_changed) + self.apocrypha_check_box.stateChanged.connect(self.on_check_box_index_changed) - def onCheckBoxIndexChanged(self, index): + def on_check_box_index_changed(self, index): """ Reload Combobox if CheckBox state has changed """ @@ -119,7 +119,8 @@ class BookNameForm(QDialog, Ui_BookNameDialog): cor_book = self.corresponding_combo_box.currentText() for character in '\\.^$*+?{}[]()': cor_book = cor_book.replace(character, '\\' + character) - books = [key for key in list(self.book_names.keys()) if re.match(cor_book, str(self.book_names[key]), re.UNICODE)] + books = [key for key in list(self.book_names.keys()) if re.match(cor_book, str(self.book_names[key]), + re.UNICODE)] books = [_f for _f in map(BiblesResourcesDB.get_book, books) if _f] if books: self.book_id = books[0]['id'] diff --git a/openlp/plugins/bibles/forms/editbibledialog.py b/openlp/plugins/bibles/forms/editbibledialog.py index 48649daad..1fbaa2f1e 100644 --- a/openlp/plugins/bibles/forms/editbibledialog.py +++ b/openlp/plugins/bibles/forms/editbibledialog.py @@ -107,7 +107,7 @@ class Ui_EditBibleDialog(object): self.book_name_widget_layout = QtGui.QFormLayout(self.book_name_widget) self.book_name_widget_layout.setObjectName('book_name_widget_layout') self.book_name_label = {} - self.book_name_edit= {} + self.book_name_edit = {} for book in BiblesResourcesDB.get_books(): self.book_name_label[book['abbreviation']] = QtGui.QLabel(self.book_name_widget) self.book_name_label[book['abbreviation']].setObjectName('book_name_label[%s]' % book['abbreviation']) @@ -131,24 +131,28 @@ class Ui_EditBibleDialog(object): self.book_names = BibleStrings().BookNames edit_bible_dialog.setWindowTitle(translate('BiblesPlugin.EditBibleForm', 'Bible Editor')) # Meta tab - self.bible_tab_widget.setTabText( self.bible_tab_widget.indexOf(self.meta_tab), - translate('SongsPlugin.EditBibleForm', 'Meta Data')) + self.bible_tab_widget.setTabText( + self.bible_tab_widget.indexOf(self.meta_tab), translate('SongsPlugin.EditBibleForm', 'Meta Data')) self.license_details_group_box.setTitle(translate('BiblesPlugin.EditBibleForm', 'License Details')) self.version_name_label.setText(translate('BiblesPlugin.EditBibleForm', 'Version name:')) self.copyright_label.setText(translate('BiblesPlugin.EditBibleForm', 'Copyright:')) self.permissions_label.setText(translate('BiblesPlugin.EditBibleForm', 'Permissions:')) self.language_selection_group_box.setTitle(translate('BiblesPlugin.EditBibleForm', 'Default Bible Language')) - self.language_selection_label.setText(translate('BiblesPlugin.EditBibleForm', - 'Book name language in search field, search results and on display:')) + self.language_selection_label.setText( + translate('BiblesPlugin.EditBibleForm', 'Book name language in search field, search results and ' + 'on display:')) self.language_selection_combo_box.setItemText(0, translate('BiblesPlugin.EditBibleForm', 'Global Settings')) - self.language_selection_combo_box.setItemText(LanguageSelection.Bible + 1, + self.language_selection_combo_box.setItemText( + LanguageSelection.Bible + 1, translate('BiblesPlugin.EditBibleForm', 'Bible Language')) - self.language_selection_combo_box.setItemText(LanguageSelection.Application + 1, - translate('BiblesPlugin.EditBibleForm', 'Application Language')) - self.language_selection_combo_box.setItemText(LanguageSelection.English + 1, + self.language_selection_combo_box.setItemText( + LanguageSelection.Application + 1, translate('BiblesPlugin.EditBibleForm', 'Application Language')) + self.language_selection_combo_box.setItemText( + LanguageSelection.English + 1, translate('BiblesPlugin.EditBibleForm', 'English')) # Book name tab - self.bible_tab_widget.setTabText(self.bible_tab_widget.indexOf(self.book_name_tab), + self.bible_tab_widget.setTabText( + self.bible_tab_widget.indexOf(self.book_name_tab), translate('SongsPlugin.EditBibleForm', 'Custom Book Names')) for book in BiblesResourcesDB.get_books(): self.book_name_label[book['abbreviation']].setText('%s:' % str(self.book_names[book['abbreviation']])) diff --git a/openlp/plugins/bibles/forms/editbibleform.py b/openlp/plugins/bibles/forms/editbibleform.py index f2d97cc08..2d10fedfa 100644 --- a/openlp/plugins/bibles/forms/editbibleform.py +++ b/openlp/plugins/bibles/forms/editbibleform.py @@ -176,7 +176,7 @@ class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog, RegistryProperties): critical_error_message_box( UiStrings().EmptyField, translate('BiblesPlugin.BibleEditForm', 'You need to specify a book name for "%s".') % - self.book_names[abbreviation]) + self.book_names[abbreviation]) return False elif not book_regex.match(new_book_name): self.book_name_edit[abbreviation].setFocus() diff --git a/openlp/plugins/bibles/forms/languagedialog.py b/openlp/plugins/bibles/forms/languagedialog.py index a75df8ded..10382ea13 100644 --- a/openlp/plugins/bibles/forms/languagedialog.py +++ b/openlp/plugins/bibles/forms/languagedialog.py @@ -32,6 +32,7 @@ from PyQt4 import QtGui from openlp.core.common import translate from openlp.core.lib.ui import create_button_box + class Ui_LanguageDialog(object): def setupUi(self, language_dialog): language_dialog.setObjectName('language_dialog') @@ -54,11 +55,11 @@ class Ui_LanguageDialog(object): self.language_label.setObjectName('language_label') self.language_h_box_layout.addWidget(self.language_label) self.language_combo_box = QtGui.QComboBox(language_dialog) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.language_combo_box.sizePolicy().hasHeightForWidth()) - self.language_combo_box.setSizePolicy(sizePolicy) + size_policy = QtGui.QSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.Fixed) + size_policy.setHorizontalStretch(0) + size_policy.setVerticalStretch(0) + size_policy.setHeightForWidth(self.language_combo_box.sizePolicy().hasHeightForWidth()) + self.language_combo_box.setSizePolicy(size_policy) self.language_combo_box.setObjectName('language_combo_box') self.language_h_box_layout.addWidget(self.language_combo_box) self.language_layout.addLayout(self.language_h_box_layout) @@ -70,7 +71,8 @@ class Ui_LanguageDialog(object): def retranslateUi(self, language_dialog): language_dialog.setWindowTitle(translate('BiblesPlugin.LanguageDialog', 'Select Language')) self.bible_label.setText(translate('BiblesPlugin.LanguageDialog', '')) - self.info_label.setText(translate('BiblesPlugin.LanguageDialog', - 'OpenLP is unable to determine the language of this translation of the Bible. Please select the language ' - 'from the list below.')) + self.info_label.setText( + translate('BiblesPlugin.LanguageDialog', + 'OpenLP is unable to determine the language of this translation of the Bible. Please select ' + 'the language from the list below.')) self.language_label.setText(translate('BiblesPlugin.LanguageDialog', 'Language:')) diff --git a/openlp/plugins/bibles/forms/languageform.py b/openlp/plugins/bibles/forms/languageform.py index 317132a57..f2c450494 100644 --- a/openlp/plugins/bibles/forms/languageform.py +++ b/openlp/plugins/bibles/forms/languageform.py @@ -36,8 +36,7 @@ from PyQt4.QtGui import QDialog from openlp.core.common import translate from openlp.core.lib.ui import critical_error_message_box -from openlp.plugins.bibles.forms.languagedialog import \ - Ui_LanguageDialog +from openlp.plugins.bibles.forms.languagedialog import Ui_LanguageDialog from openlp.plugins.bibles.lib.db import BiblesResourcesDB diff --git a/openlp/plugins/bibles/lib/__init__.py b/openlp/plugins/bibles/lib/__init__.py index 39bee992f..50a0e2a63 100644 --- a/openlp/plugins/bibles/lib/__init__.py +++ b/openlp/plugins/bibles/lib/__init__.py @@ -218,9 +218,10 @@ def update_reference_separators(): REFERENCE_MATCHES['range'] = re.compile('^\s*%s\s*$' % range_regex, re.UNICODE) REFERENCE_MATCHES['range_separator'] = re.compile(REFERENCE_SEPARATORS['sep_l'], re.UNICODE) # full reference match: <book>(<range>(,(?!$)|(?=$)))+ - REFERENCE_MATCHES['full'] = re.compile('^\s*(?!\s)(?P<book>[\d]*[^\d]+)(?<!\s)\s*' - '(?P<ranges>(?:%(range_regex)s(?:%(sep_l)s(?!\s*$)|(?=\s*$)))+)\s*$' \ - % dict(list(REFERENCE_SEPARATORS.items()) + [('range_regex', range_regex)]), re.UNICODE) + REFERENCE_MATCHES['full'] = \ + re.compile('^\s*(?!\s)(?P<book>[\d]*[^\d]+)(?<!\s)\s*' + '(?P<ranges>(?:%(range_regex)s(?:%(sep_l)s(?!\s*$)|(?=\s*$)))+)\s*$' + % dict(list(REFERENCE_SEPARATORS.items()) + [('range_regex', range_regex)]), re.UNICODE) def get_reference_separator(separator_type): diff --git a/openlp/plugins/bibles/lib/biblestab.py b/openlp/plugins/bibles/lib/biblestab.py index 8e5c50178..8f16bf830 100644 --- a/openlp/plugins/bibles/lib/biblestab.py +++ b/openlp/plugins/bibles/lib/biblestab.py @@ -422,7 +422,7 @@ class BiblesTab(SettingsTab): color.setAlpha(128) palette.setColor(QtGui.QPalette.Active, QtGui.QPalette.Text, color) return palette - + def check_is_verse_number_visible(self): """ Enables / Disables verse settings dependent on is_verse_number_visible @@ -430,4 +430,3 @@ class BiblesTab(SettingsTab): self.new_chapters_check_box.setEnabled(self.is_verse_number_visible) self.display_style_label.setEnabled(self.is_verse_number_visible) self.display_style_combo_box.setEnabled(self.is_verse_number_visible) - diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index a41545377..743bb01c6 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -80,23 +80,20 @@ def init_schema(url): meta_table = Table('metadata', metadata, Column('key', types.Unicode(255), primary_key=True, index=True), - Column('value', types.Unicode(255)), - ) + Column('value', types.Unicode(255)),) book_table = Table('book', metadata, Column('id', types.Integer, primary_key=True), Column('book_reference_id', types.Integer, index=True), Column('testament_reference_id', types.Integer), - Column('name', types.Unicode(50), index=True), - ) + Column('name', types.Unicode(50), index=True),) verse_table = Table('verse', metadata, Column('id', types.Integer, primary_key=True, index=True), Column('book_id', types.Integer, ForeignKey( 'book.id'), index=True), Column('chapter', types.Integer, index=True), Column('verse', types.Integer, index=True), - Column('text', types.UnicodeText, index=True), - ) + Column('text', types.UnicodeText, index=True),) try: class_mapper(BibleMeta) @@ -225,7 +222,8 @@ class BibleDB(QtCore.QObject, Manager, RegistryProperties): :param book_id: The id of the book being appended. :param chapter: The chapter number. - :param text_list: A dict of the verses to be inserted. The key is the verse number, and the value is the verse text. + :param text_list: A dict of the verses to be inserted. The key is the verse number, and the value is the + verse text. """ log.debug('BibleDBcreate_chapter("%s", "%s")', book_id, chapter) # Text list has book and chapter as first two elements of the array. @@ -437,7 +435,7 @@ class BibleDB(QtCore.QObject, Manager, RegistryProperties): """ log.debug('BibleDB.get_chapter_count("%s")', book.name) count = self.session.query(func.max(Verse.chapter)).join(Book).filter( - Book.book_reference_id==book.book_reference_id).scalar() + Book.book_reference_id == book.book_reference_id).scalar() if not count: return 0 return count @@ -718,8 +716,8 @@ class BiblesResourcesDB(QtCore.QObject, Manager): if not isinstance(source, str): source = str(source) source = BiblesResourcesDB.get_download_source(source) - bibles = BiblesResourcesDB.run_sql('SELECT id, name, abbreviation, ' - 'language_id, download_source_id FROM webbibles WHERE download_source_id = ?', (source['id'],)) + bibles = BiblesResourcesDB.run_sql('SELECT id, name, abbreviation, language_id, download_source_id ' + 'FROM webbibles WHERE download_source_id = ?', (source['id'],)) if bibles: return [{ 'id': bible[0], @@ -824,10 +822,9 @@ class BiblesResourcesDB(QtCore.QObject, Manager): log.debug('BiblesResourcesDB.get_testament_reference()') testaments = BiblesResourcesDB.run_sql('SELECT id, name FROM testament_reference ORDER BY id') return [ - { - 'id': testament[0], - 'name': str(testament[1]) - } + {'id': testament[0], + 'name': str(testament[1]) + } for testament in testaments ] @@ -934,7 +931,7 @@ class OldBibleDB(QtCore.QObject, Manager): QtCore.QObject.__init__(self) if 'path' not in kwargs: raise KeyError('Missing keyword argument "path".') - if 'file' not in kwargs: + if 'file' not in kwargs: raise KeyError('Missing keyword argument "file".') if 'path' in kwargs: self.path = kwargs['path'] diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index 3400c9a56..340d8ef92 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -32,7 +32,9 @@ The :mod:`http` module enables OpenLP to retrieve scripture from bible websites. import logging import re import socket -import urllib.request, urllib.parse, urllib.error +import urllib.request +import urllib.parse +import urllib.error from html.parser import HTMLParseError from bs4 import BeautifulSoup, NavigableString, Tag @@ -487,7 +489,7 @@ class HTTPBible(BibleDB, RegistryProperties): (self.download_source, self.download_name)) return False self.wizard.progress_bar.setMaximum(len(books) + 2) - self.wizard.increment_progress_bar(translate( 'BiblesPlugin.HTTPBible', 'Registering Language...')) + self.wizard.increment_progress_bar(translate('BiblesPlugin.HTTPBible', 'Registering Language...')) bible = BiblesResourcesDB.get_webbible(self.download_name, self.download_source.lower()) if bible['language_id']: language_id = bible['language_id'] diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 4b8b8bc83..10fef8e31 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -664,7 +664,7 @@ class BibleMediaItem(MediaManagerItem): db_book = bibles[second_bible].get_book_by_book_ref_id(verse.book.book_reference_id) if not db_book: log.debug('Passage "%s %d:%d" not found in Second Bible' % - (verse.book.name, verse.chapter, verse.verse)) + (verse.book.name, verse.chapter, verse.verse)) passage_not_found = True count += 1 continue @@ -910,8 +910,8 @@ class BibleMediaItem(MediaManagerItem): elif old_verse + 1 != verse and old_chapter == chapter: # We are still in the same chapter, but a verse has been skipped. return True - elif old_chapter + 1 == chapter and (verse != 1 or - old_verse != self.plugin.manager.get_verse_count(old_bible, old_book, old_chapter)): + elif old_chapter + 1 == chapter and (verse != 1 or old_verse != + self.plugin.manager.get_verse_count(old_bible, old_book, old_chapter)): # We are in the following chapter, but the last verse was not the # last verse of the chapter or the current verse is not the # first one of the chapter. diff --git a/openlp/plugins/images/forms/addgroupform.py b/openlp/plugins/images/forms/addgroupform.py index d5f26f308..414a8e4b9 100644 --- a/openlp/plugins/images/forms/addgroupform.py +++ b/openlp/plugins/images/forms/addgroupform.py @@ -50,7 +50,8 @@ class AddGroupForm(QtGui.QDialog, Ui_AddGroupDialog): Show the form. :param clear: Set to False if the text input box should not be cleared when showing the dialog (default: True). - :param show_top_level_group: Set to True when "-- Top level group --" should be showed as first item (default: False). + :param show_top_level_group: Set to True when "-- Top level group --" should be showed as first item + (default: False). :param selected_group: The ID of the group that should be selected by default when showing the dialog. """ if clear: diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index 5b88bfb36..b2eb5b816 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -327,7 +327,8 @@ class ImageMediaItem(MediaManagerItem): :param images: A List of Image Filenames objects that will be used to reload the mediamanager list. :param initial_load: When set to False, the busy cursor and progressbar will be shown while loading images. - :param open_group: ImageGroups object of the group that must be expanded after reloading the list in the interface. + :param open_group: ImageGroups object of the group that must be expanded after reloading the list in the + interface. """ if not initial_load: self.application.set_busy_cursor() @@ -462,7 +463,8 @@ class ImageMediaItem(MediaManagerItem): :param images_list: A List of strings containing image filenames :param group_id: The ID of the group to save the images in - :param reload_list: This boolean is set to True when the list in the interface should be reloaded after saving the new images + :param reload_list: This boolean is set to True when the list in the interface should be reloaded after saving + the new images """ for filename in images_list: if not isinstance(filename, str): diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index 01a28f9ca..56d3a49f4 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -34,7 +34,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.common import Registry, RegistryProperties, AppLocation, Settings, check_directory_exists, UiStrings,\ translate -from openlp.core.lib import ItemCapabilities, MediaManagerItem,MediaType, ServiceItem, ServiceItemContext, \ +from openlp.core.lib import ItemCapabilities, MediaManagerItem, MediaType, ServiceItem, ServiceItemContext, \ build_icon, check_item_selected from openlp.core.lib.ui import critical_error_message_box, create_horizontal_adjusting_combo_box from openlp.core.ui import DisplayController, Display, DisplayControllerType @@ -161,7 +161,7 @@ class MediaMediaItem(MediaManagerItem, RegistryProperties): Called to replace Live background with the media selected. """ if check_item_selected(self.list_view, - translate('MediaPlugin.MediaItem', + translate('MediaPlugin.MediaItem', 'You must select a media file to replace the background with.')): item = self.list_view.currentItem() filename = item.data(QtCore.Qt.UserRole) @@ -170,12 +170,12 @@ class MediaMediaItem(MediaManagerItem, RegistryProperties): service_item.title = 'webkit' service_item.processor = 'webkit' (path, name) = os.path.split(filename) - service_item.add_from_command(path, name,CLAPPERBOARD) + service_item.add_from_command(path, name, CLAPPERBOARD) if self.media_controller.video(DisplayControllerType.Live, service_item, video_behind_text=True): self.reset_action.setVisible(True) else: critical_error_message_box(UiStrings().LiveBGError, - translate('MediaPlugin.MediaItem', + translate('MediaPlugin.MediaItem', 'There was no display item to amend.')) else: critical_error_message_box(UiStrings().LiveBGError, diff --git a/openlp/plugins/songusage/forms/songusagedeleteform.py b/openlp/plugins/songusage/forms/songusagedeleteform.py index f7c05e0e6..64bd56768 100644 --- a/openlp/plugins/songusage/forms/songusagedeleteform.py +++ b/openlp/plugins/songusage/forms/songusagedeleteform.py @@ -70,4 +70,4 @@ class SongUsageDeleteForm(QtGui.QDialog, Ui_SongUsageDeleteDialog, RegistryPrope ) self.accept() else: - self.reject() \ No newline at end of file + self.reject() diff --git a/openlp/plugins/songusage/forms/songusagedetailform.py b/openlp/plugins/songusage/forms/songusagedetailform.py index eb5963228..e8111c058 100644 --- a/openlp/plugins/songusage/forms/songusagedetailform.py +++ b/openlp/plugins/songusage/forms/songusagedetailform.py @@ -87,15 +87,14 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog, RegistryPrope ) return check_directory_exists(path) - file_name = translate('SongUsagePlugin.SongUsageDetailForm', 'usage_detail_%s_%s.txt') % ( - self.from_date_calendar.selectedDate().toString('ddMMyyyy'), - self.to_date_calendar.selectedDate().toString('ddMMyyyy')) + file_name = translate('SongUsagePlugin.SongUsageDetailForm', 'usage_detail_%s_%s.txt') % \ + (self.from_date_calendar.selectedDate().toString('ddMMyyyy'), + self.to_date_calendar.selectedDate().toString('ddMMyyyy')) Settings().setValue(self.plugin.settings_section + '/from date', self.from_date_calendar.selectedDate()) Settings().setValue(self.plugin.settings_section + '/to date', self.to_date_calendar.selectedDate()) usage = self.plugin.manager.get_all_objects( - SongUsageItem, and_( - SongUsageItem.usagedate >= self.from_date_calendar.selectedDate().toPyDate(), - SongUsageItem.usagedate < self.to_date_calendar.selectedDate().toPyDate()), + SongUsageItem, and_(SongUsageItem.usagedate >= self.from_date_calendar.selectedDate().toPyDate(), + SongUsageItem.usagedate < self.to_date_calendar.selectedDate().toPyDate()), [SongUsageItem.usagedate, SongUsageItem.usagetime]) report_file_name = os.path.join(path, file_name) file_handle = None @@ -103,9 +102,9 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog, RegistryPrope file_handle = open(report_file_name, 'w') for instance in usage: record = '\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",' \ - '\"%s\",\"%s\"\n' % (instance.usagedate, - instance.usagetime, instance.title, instance.copyright, - instance.ccl_number, instance.authors, instance.plugin_name, instance.source) + '\"%s\",\"%s\"\n' % \ + (instance.usagedate, instance.usagetime, instance.title, instance.copyright, + instance.ccl_number, instance.authors, instance.plugin_name, instance.source) file_handle.write(record.encode('utf-8')) self.main_window.information_message( translate('SongUsagePlugin.SongUsageDetailForm', 'Report Creation'), diff --git a/openlp/plugins/songusage/lib/db.py b/openlp/plugins/songusage/lib/db.py index b7b9c6801..9d9fff460 100644 --- a/openlp/plugins/songusage/lib/db.py +++ b/openlp/plugins/songusage/lib/db.py @@ -62,7 +62,7 @@ def init_schema(url): Column('ccl_number', types.Unicode(65)), Column('plugin_name', types.Unicode(20)), Column('source', types.Unicode(10)) - ) + ) mapper(SongUsageItem, songusage_table) From bbe4169c24b2e518c23a2c4c3ad342e39d138b58 Mon Sep 17 00:00:00 2001 From: Tim Bentley <tim.bentley@gmail.com> Date: Fri, 21 Mar 2014 21:38:08 +0000 Subject: [PATCH 07/51] Fix all formatting errors --- .../custom/forms/editcustomslidedialog.py | 3 +- openlp/plugins/custom/lib/mediaitem.py | 22 +++--- .../presentations/lib/impresscontroller.py | 8 +- .../presentations/lib/pdfcontroller.py | 6 +- .../presentations/lib/pptviewlib/ppttest.py | 10 +-- openlp/plugins/remotes/lib/httpserver.py | 3 - openlp/plugins/remotes/lib/remotetab.py | 7 +- openlp/plugins/remotes/remoteplugin.py | 16 ++-- .../songs/forms/duplicatesongremovalform.py | 6 +- openlp/plugins/songs/forms/editsongform.py | 8 +- .../plugins/songs/forms/mediafilesdialog.py | 1 - openlp/plugins/songs/forms/mediafilesform.py | 1 - openlp/plugins/songs/forms/songimportform.py | 8 +- .../songs/forms/songmaintenancedialog.py | 4 +- .../songs/forms/songmaintenanceform.py | 2 +- .../plugins/songs/forms/songreviewwidget.py | 2 +- openlp/plugins/songs/lib/__init__.py | 1 - openlp/plugins/songs/lib/cclifileimport.py | 4 +- openlp/plugins/songs/lib/db.py | 34 +++++---- openlp/plugins/songs/lib/dreambeamimport.py | 5 +- .../plugins/songs/lib/foilpresenterimport.py | 15 ++-- openlp/plugins/songs/lib/mediaitem.py | 6 +- openlp/plugins/songs/lib/olpimport.py | 6 +- openlp/plugins/songs/lib/openlyricsexport.py | 5 +- openlp/plugins/songs/lib/powersongimport.py | 4 +- openlp/plugins/songs/lib/sofimport.py | 11 ++- openlp/plugins/songs/lib/songcompare.py | 2 +- openlp/plugins/songs/lib/songimport.py | 2 +- .../plugins/songs/lib/songshowplusimport.py | 4 +- openlp/plugins/songs/lib/sundayplusimport.py | 3 +- openlp/plugins/songs/lib/test/test.opensong | 72 ------------------ .../plugins/songs/lib/test/test.opensong.zip | Bin 855 -> 0 bytes openlp/plugins/songs/lib/test/test2.opensong | 45 ----------- openlp/plugins/songs/lib/test/test3.opensong | 10 --- .../songs/lib/test/test_import_file.py | 50 ------------ .../songs/lib/test/test_importing_lots.py | 61 --------------- openlp/plugins/songs/lib/ui.py | 4 +- openlp/plugins/songs/lib/upgrade.py | 1 - .../songs/lib/worshipcenterproimport.py | 6 +- openlp/plugins/songs/lib/xml.py | 3 +- openlp/plugins/songs/lib/zionworximport.py | 2 +- openlp/plugins/songs/songsplugin.py | 2 +- 42 files changed, 111 insertions(+), 354 deletions(-) delete mode 100644 openlp/plugins/songs/lib/test/test.opensong delete mode 100644 openlp/plugins/songs/lib/test/test.opensong.zip delete mode 100644 openlp/plugins/songs/lib/test/test2.opensong delete mode 100644 openlp/plugins/songs/lib/test/test3.opensong delete mode 100644 openlp/plugins/songs/lib/test/test_import_file.py delete mode 100644 openlp/plugins/songs/lib/test/test_importing_lots.py diff --git a/openlp/plugins/custom/forms/editcustomslidedialog.py b/openlp/plugins/custom/forms/editcustomslidedialog.py index a94bdd109..3b74566fc 100644 --- a/openlp/plugins/custom/forms/editcustomslidedialog.py +++ b/openlp/plugins/custom/forms/editcustomslidedialog.py @@ -33,6 +33,7 @@ from openlp.core.common import UiStrings, translate from openlp.core.lib import SpellTextEdit from openlp.core.lib.ui import create_button, create_button_box + class Ui_CustomSlideEditDialog(object): def setupUi(self, custom_slide_edit_dialog): custom_slide_edit_dialog.setObjectName('custom_slide_edit_dialog') @@ -45,7 +46,7 @@ class Ui_CustomSlideEditDialog(object): self.insert_button = create_button(custom_slide_edit_dialog, 'insertButton', icon=':/general/general_add.png') self.button_box = create_button_box(custom_slide_edit_dialog, 'button_box', ['cancel', 'save'], - [self.split_button, self.insert_button]) + [self.split_button, self.insert_button]) self.dialog_layout.addWidget(self.button_box) self.retranslateUi(custom_slide_edit_dialog) diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index cfea319e6..9ecfac779 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -33,8 +33,8 @@ from PyQt4 import QtCore, QtGui from sqlalchemy.sql import or_, func, and_ from openlp.core.common import Registry, Settings, UiStrings, translate -from openlp.core.lib import MediaManagerItem, ItemCapabilities, ServiceItemContext, PluginStatus,\ - check_item_selected +from openlp.core.lib import MediaManagerItem, ItemCapabilities, ServiceItemContext, PluginStatus, \ + check_item_selected from openlp.plugins.custom.forms.editcustomform import EditCustomForm from openlp.plugins.custom.lib import CustomXMLParser, CustomXMLBuilder from openlp.plugins.custom.lib.db import CustomSlide @@ -105,12 +105,10 @@ class CustomMediaItem(MediaManagerItem): """ Initialise the UI so it can provide Searches """ - self.search_text_edit.set_search_types([(CustomSearch.Titles, ':/songs/song_search_title.png', - translate('SongsPlugin.MediaItem', 'Titles'), - translate('SongsPlugin.MediaItem', 'Search Titles...')), - (CustomSearch.Themes, ':/slides/slide_theme.png', UiStrings().Themes, - UiStrings().SearchThemes) - ]) + self.search_text_edit.set_search_types( + [(CustomSearch.Titles, ':/songs/song_search_title.png', translate('SongsPlugin.MediaItem', 'Titles'), + translate('SongsPlugin.MediaItem', 'Search Titles...')), + (CustomSearch.Themes, ':/slides/slide_theme.png', UiStrings().Themes, UiStrings().SearchThemes)]) self.search_text_edit.set_current_search_type(Settings().value('%s/last search type' % self.settings_section)) self.load_list(self.plugin.db_manager.get_all_objects(CustomSlide, order_by_ref=CustomSlide.title)) self.config_update() @@ -191,10 +189,9 @@ class CustomMediaItem(MediaManagerItem): if QtGui.QMessageBox.question(self, UiStrings().ConfirmDelete, translate('CustomPlugin.MediaItem', 'Are you sure you want to delete the %n selected custom slide(s)?', - '', - QtCore.QCoreApplication.CodecForTr, len(items)), - QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes - | QtGui.QMessageBox.No), + '', QtCore.QCoreApplication.CodecForTr, len(items)), + QtGui.QMessageBox.StandardButtons( + QtGui.QMessageBox.Yes | QtGui.QMessageBox.No), QtGui.QMessageBox.Yes) == QtGui.QMessageBox.No: return row_list = [item.row() for item in self.list_view.selectedIndexes()] @@ -348,4 +345,3 @@ class CustomMediaItem(MediaManagerItem): func.lower(CustomSlide.text).like(search)), order_by_ref=CustomSlide.title) return [[custom.id, custom.title] for custom in search_results] - diff --git a/openlp/plugins/presentations/lib/impresscontroller.py b/openlp/plugins/presentations/lib/impresscontroller.py index 356a6cceb..c55873c5f 100644 --- a/openlp/plugins/presentations/lib/impresscontroller.py +++ b/openlp/plugins/presentations/lib/impresscontroller.py @@ -29,7 +29,8 @@ # OOo API documentation: # http://api.openoffice.org/docs/common/ref/com/sun/star/presentation/XSlideShowController.html -# http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/ProUNO/Basic/Getting_Information_about_UNO_Objects#Inspecting_interfaces_during_debugging +# http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/ProUNO/Basic +# /Getting_Information_about_UNO_Objects#Inspecting_interfaces_during_debugging # http://docs.go-oo.org/sd/html/classsd_1_1SlideShow.html # http://www.oooforum.org/forum/viewtopic.phtml?t=5252 # http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/Working_with_Presentations @@ -45,6 +46,7 @@ if os.name == 'nt': from win32com.client import Dispatch import pywintypes # Declare an empty exception to match the exception imported from UNO + class ErrorCodeIOException(Exception): pass else: @@ -204,7 +206,7 @@ class ImpressDocument(PresentationDocument): Class which holds information and controls a single presentation. """ - def __init__ (self, controller, presentation): + def __init__(self, controller, presentation): """ Constructor, store information about the file and initialise. """ @@ -353,7 +355,7 @@ class ImpressDocument(PresentationDocument): log.debug('unblank screen OpenOffice') return self.control.resume() - def blank_screen (self): + def blank_screen(self): """ Blanks the screen. """ diff --git a/openlp/plugins/presentations/lib/pdfcontroller.py b/openlp/plugins/presentations/lib/pdfcontroller.py index 2dade90a1..597b7d78b 100644 --- a/openlp/plugins/presentations/lib/pdfcontroller.py +++ b/openlp/plugins/presentations/lib/pdfcontroller.py @@ -132,7 +132,8 @@ class PdfController(PresentationController): DEVNULL = open(os.devnull, 'wb') # First try to find mupdf try: - self.mudrawbin = check_output(['which', 'mudraw'], stderr=DEVNULL).decode(encoding='UTF-8').rstrip('\n') + self.mudrawbin = check_output(['which', 'mudraw'], + stderr=DEVNULL).decode(encoding='UTF-8').rstrip('\n') except CalledProcessError: self.mudrawbin = '' # if mupdf isn't installed, fallback to ghostscript @@ -192,7 +193,8 @@ class PdfDocument(PresentationDocument): :return: The resolution dpi to be used. """ # Use a postscript script to get size of the pdf. It is assumed that all pages have same size - gs_resolution_script = AppLocation.get_directory(AppLocation.PluginsDir) + '/presentations/lib/ghostscript_get_resolution.ps' + gs_resolution_script = AppLocation.get_directory( + AppLocation.PluginsDir) + '/presentations/lib/ghostscript_get_resolution.ps' # Run the script on the pdf to get the size runlog = [] try: diff --git a/openlp/plugins/presentations/lib/pptviewlib/ppttest.py b/openlp/plugins/presentations/lib/pptviewlib/ppttest.py index 6c48f9ee0..49a820670 100644 --- a/openlp/plugins/presentations/lib/pptviewlib/ppttest.py +++ b/openlp/plugins/presentations/lib/pptviewlib/ppttest.py @@ -32,6 +32,7 @@ from PyQt4 import QtGui, QtCore from ctypes import * from ctypes.wintypes import RECT + class PPTViewer(QtGui.QWidget): """ Standalone Test Harness for the pptviewlib library @@ -169,16 +170,16 @@ class PPTViewer(QtGui.QWidget): app.processEvents() def openClick(self): - oldid = self.pptid; + oldid = self.pptid rect = RECT(int(self.xEdit.text()), int(self.yEdit.text()), - int(self.widthEdit.text()), int(self.heightEdit.text())) + int(self.widthEdit.text()), int(self.heightEdit.text())) filename = str(self.pptEdit.text().replace('/', '\\')) folder = str(self.folderEdit.text().replace('/', '\\')) print(filename, folder) self.pptid = self.pptdll.OpenPPT(filename, None, rect, folder) print('id: ' + str(self.pptid)) if oldid >= 0: - self.pptdll.ClosePPT(oldid); + self.pptdll.ClosePPT(oldid) slides = self.pptdll.GetSlideCount(self.pptid) print('slidecount: ' + str(slides)) self.total.setNum(self.pptdll.GetSlideCount(self.pptid)) @@ -201,8 +202,7 @@ class PPTViewer(QtGui.QWidget): app.processEvents() def openDialog(self): - self.pptEdit.setText(QtGui.QFileDialog.getOpenFileName(self, - 'Open file')) + self.pptEdit.setText(QtGui.QFileDialog.getOpenFileName(self, 'Open file')) if __name__ == '__main__': pptdll = cdll.LoadLibrary(r'pptviewlib.dll') diff --git a/openlp/plugins/remotes/lib/httpserver.py b/openlp/plugins/remotes/lib/httpserver.py index b57bd29d3..fa578184b 100644 --- a/openlp/plugins/remotes/lib/httpserver.py +++ b/openlp/plugins/remotes/lib/httpserver.py @@ -144,6 +144,3 @@ class HTTPSServer(HTTPServer): server_side=True) self.server_bind() self.server_activate() - - - diff --git a/openlp/plugins/remotes/lib/remotetab.py b/openlp/plugins/remotes/lib/remotetab.py index 540b8d212..d6b96cc1c 100644 --- a/openlp/plugins/remotes/lib/remotetab.py +++ b/openlp/plugins/remotes/lib/remotetab.py @@ -225,7 +225,8 @@ class RemoteTab(SettingsTab): continue for address in interface.addressEntries(): ip = address.ip() - if ip.protocol() == QtNetwork.QAbstractSocket.IPv4Protocol and ip != QtNetwork.QHostAddress.LocalHost: + if ip.protocol() == QtNetwork.QAbstractSocket.IPv4Protocol and \ + ip != QtNetwork.QHostAddress.LocalHost: return ip.toString() return ip_address @@ -262,9 +263,9 @@ class RemoteTab(SettingsTab): Settings().value(self.settings_section + '/port') != self.port_spin_box.value() or \ Settings().value(self.settings_section + '/https port') != self.https_port_spin_box.value() or \ Settings().value(self.settings_section + '/https enabled') != \ - self.https_settings_group_box.isChecked() or \ + self.https_settings_group_box.isChecked() or \ Settings().value(self.settings_section + '/authentication enabled') != \ - self.user_login_group_box.isChecked(): + self.user_login_group_box.isChecked(): self.settings_form.register_post_process('remotes_config_updated') Settings().setValue(self.settings_section + '/port', self.port_spin_box.value()) Settings().setValue(self.settings_section + '/https port', self.https_port_spin_box.value()) diff --git a/openlp/plugins/remotes/remoteplugin.py b/openlp/plugins/remotes/remoteplugin.py index 3517c4f9c..393f08dd9 100644 --- a/openlp/plugins/remotes/remoteplugin.py +++ b/openlp/plugins/remotes/remoteplugin.py @@ -36,14 +36,14 @@ from openlp.plugins.remotes.lib import RemoteTab, OpenLPServer log = logging.getLogger(__name__) __default_settings__ = { - 'remotes/twelve hour': True, - 'remotes/port': 4316, - 'remotes/https port': 4317, - 'remotes/https enabled': False, - 'remotes/user id': 'openlp', - 'remotes/password': 'password', - 'remotes/authentication enabled': False, - 'remotes/ip address': '0.0.0.0' + 'remotes/twelve hour': True, + 'remotes/port': 4316, + 'remotes/https port': 4317, + 'remotes/https enabled': False, + 'remotes/user id': 'openlp', + 'remotes/password': 'password', + 'remotes/authentication enabled': False, + 'remotes/ip address': '0.0.0.0' } diff --git a/openlp/plugins/songs/forms/duplicatesongremovalform.py b/openlp/plugins/songs/forms/duplicatesongremovalform.py index fc5e9a809..22299cde5 100644 --- a/openlp/plugins/songs/forms/duplicatesongremovalform.py +++ b/openlp/plugins/songs/forms/duplicatesongremovalform.py @@ -64,8 +64,8 @@ class DuplicateSongRemovalForm(OpenLPWizard, RegistryProperties): # Used to interrupt ongoing searches when cancel is clicked. self.break_search = False super(DuplicateSongRemovalForm, self).__init__( - Registry().get('main_window'), plugin, 'duplicateSongRemovalWizard', ':/wizards/wizard_duplicateremoval.bmp' - , False) + Registry().get('main_window'), plugin, 'duplicateSongRemovalWizard', + ':/wizards/wizard_duplicateremoval.bmp', False) self.setMinimumWidth(730) def custom_signals(self): @@ -327,4 +327,4 @@ class DuplicateSongRemovalForm(OpenLPWizard, RegistryProperties): self.button(QtGui.QWizard.FinishButton).show() self.button(QtGui.QWizard.FinishButton).setEnabled(True) self.button(QtGui.QWizard.NextButton).hide() - self.button(QtGui.QWizard.CancelButton).hide() \ No newline at end of file + self.button(QtGui.QWizard.CancelButton).hide() diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 06639fe18..8b1e3a897 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -185,11 +185,11 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog, RegistryProperties): if len(invalid_verses) > 1: msg = translate('SongsPlugin.EditSongForm', 'There are no verses corresponding to "%(invalid)s".' 'Valid entries are %(valid)s.\nPlease enter the verses separated by spaces.') % \ - {'invalid': ', '.join(invalid_verses), 'valid' : valid} + {'invalid': ', '.join(invalid_verses), 'valid': valid} else: msg = translate('SongsPlugin.EditSongForm', 'There is no verse corresponding to "%(invalid)s".' 'Valid entries are %(valid)s.\nPlease enter the verses separated by spaces.') % \ - {'invalid': invalid_verses[0], 'valid' : valid} + {'invalid': invalid_verses[0], 'valid': valid} critical_error_message_box(title=translate('SongsPlugin.EditSongForm', 'Invalid Verse Order'), message=msg) return len(invalid_verses) == 0 @@ -257,7 +257,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog, RegistryProperties): self.song.lyrics = str(sxml.extract_xml(), 'utf-8') for verse in multiple: self.song.verse_order = re.sub('([' + verse.upper() + verse.lower() + '])(\W|$)', - r'\g<1>1\2', self.song.verse_order) + r'\g<1>1\2', self.song.verse_order) except: log.exception('Problem processing song Lyrics \n%s', sxml.dump_xml()) raise @@ -955,4 +955,4 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog, RegistryProperties): log.exception('Could not remove directory: %s', save_path) clean_song(self.manager, self.song) self.manager.save_object(self.song) - self.media_item.auto_select_id = self.song.id \ No newline at end of file + self.media_item.auto_select_id = self.song.id diff --git a/openlp/plugins/songs/forms/mediafilesdialog.py b/openlp/plugins/songs/forms/mediafilesdialog.py index 09fbd96f5..a0392e3db 100644 --- a/openlp/plugins/songs/forms/mediafilesdialog.py +++ b/openlp/plugins/songs/forms/mediafilesdialog.py @@ -71,4 +71,3 @@ class Ui_MediaFilesDialog(object): self.select_label.setText(translate('SongsPlugin.MediaFilesForm', 'Select one or more audio files from the list below, and click OK to import them ' 'into this song.')) - diff --git a/openlp/plugins/songs/forms/mediafilesform.py b/openlp/plugins/songs/forms/mediafilesform.py index 660a9f72d..ec689ddb6 100644 --- a/openlp/plugins/songs/forms/mediafilesform.py +++ b/openlp/plugins/songs/forms/mediafilesform.py @@ -56,4 +56,3 @@ class MediaFilesForm(QtGui.QDialog, Ui_MediaFilesDialog): def get_selected_files(self): return [item.data(QtCore.Qt.UserRole) for item in self.file_list_widget.selectedItems()] - diff --git a/openlp/plugins/songs/forms/songimportform.py b/openlp/plugins/songs/forms/songimportform.py index e87c9f645..27f0d9343 100644 --- a/openlp/plugins/songs/forms/songimportform.py +++ b/openlp/plugins/songs/forms/songimportform.py @@ -99,7 +99,8 @@ class SongImportForm(OpenLPWizard, RegistryProperties): self.format_widgets[song_format]['removeButton'].clicked.connect(self.on_remove_button_clicked) else: self.format_widgets[song_format]['browseButton'].clicked.connect(self.on_browse_button_clicked) - self.format_widgets[song_format]['file_path_edit'].textChanged.connect(self.on_filepath_edit_text_changed) + self.format_widgets[song_format]['file_path_edit'].textChanged.\ + connect(self.on_filepath_edit_text_changed) def add_custom_pages(self): """ @@ -163,7 +164,8 @@ class SongImportForm(OpenLPWizard, RegistryProperties): f_label = 'Filename:' if select_mode == SongFormatSelect.SingleFolder: f_label = 'Folder:' - self.format_widgets[format_list]['filepathLabel'].setText(translate('SongsPlugin.ImportWizardForm', f_label)) + self.format_widgets[format_list]['filepathLabel'].setText( + translate('SongsPlugin.ImportWizardForm', f_label)) for format_list in self.disablable_formats: self.format_widgets[format_list]['disabled_label'].setText(SongFormat.get(format_list, 'disabledLabelText')) self.progress_page.setTitle(WizardStrings.Importing) @@ -244,7 +246,7 @@ class SongImportForm(OpenLPWizard, RegistryProperties): if file_names: listbox.addItems(file_names) Settings().setValue(self.plugin.settings_section + '/last directory import', - os.path.split(str(file_names[0]))[0]) + os.path.split(str(file_names[0]))[0]) def get_list_of_files(self, list_box): """ diff --git a/openlp/plugins/songs/forms/songmaintenancedialog.py b/openlp/plugins/songs/forms/songmaintenancedialog.py index 200b4b1ff..84e3535d3 100644 --- a/openlp/plugins/songs/forms/songmaintenancedialog.py +++ b/openlp/plugins/songs/forms/songmaintenancedialog.py @@ -162,6 +162,6 @@ class Ui_SongMaintenanceDialog(object): self.edit_book_button.setText(UiStrings().Edit) self.delete_book_button.setText(UiStrings().Delete) type_list_width = max(self.fontMetrics().width(SongStrings.Authors), - self.fontMetrics().width(SongStrings.Topics), - self.fontMetrics().width(SongStrings.SongBooks)) + self.fontMetrics().width(SongStrings.Topics), + self.fontMetrics().width(SongStrings.SongBooks)) self.type_list_widget.setFixedWidth(type_list_width + self.type_list_widget.iconSize().width() + 32) diff --git a/openlp/plugins/songs/forms/songmaintenanceform.py b/openlp/plugins/songs/forms/songmaintenanceform.py index 8f92e9cae..4e9bdad93 100644 --- a/openlp/plugins/songs/forms/songmaintenanceform.py +++ b/openlp/plugins/songs/forms/songmaintenanceform.py @@ -531,4 +531,4 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog, RegistryPrope edit_button.setEnabled(False) else: delete_button.setEnabled(True) - edit_button.setEnabled(True) \ No newline at end of file + edit_button.setEnabled(True) diff --git a/openlp/plugins/songs/forms/songreviewwidget.py b/openlp/plugins/songs/forms/songreviewwidget.py index 839174009..02d7b8774 100644 --- a/openlp/plugins/songs/forms/songreviewwidget.py +++ b/openlp/plugins/songs/forms/songreviewwidget.py @@ -191,7 +191,7 @@ class SongReviewWidget(QtGui.QWidget): self.song_remove_button.setObjectName('song_remove_button') self.song_remove_button.setIcon(build_icon(':/songs/song_delete.png')) self.song_remove_button.setSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) - self.song_vertical_layout.addWidget(self.song_remove_button, alignment = QtCore.Qt.AlignHCenter) + self.song_vertical_layout.addWidget(self.song_remove_button, alignment=QtCore.Qt.AlignHCenter) def retranslateUi(self): self.song_remove_button.setText('Remove') diff --git a/openlp/plugins/songs/lib/__init__.py b/openlp/plugins/songs/lib/__init__.py index 1c9141b16..dc198d4b7 100644 --- a/openlp/plugins/songs/lib/__init__.py +++ b/openlp/plugins/songs/lib/__init__.py @@ -549,4 +549,3 @@ def delete_song(song_id, song_plugin): except OSError: log.exception('Could not remove directory: %s', save_path) song_plugin.manager.delete_object(Song, song_id) - diff --git a/openlp/plugins/songs/lib/cclifileimport.py b/openlp/plugins/songs/lib/cclifileimport.py index 54779a194..0866a1cc7 100644 --- a/openlp/plugins/songs/lib/cclifileimport.py +++ b/openlp/plugins/songs/lib/cclifileimport.py @@ -89,8 +89,8 @@ class CCLIFileImport(SongImport): if not self.do_import_txt_file(lines): self.log_error(filename) else: - self.log_error(filename, - translate('SongsPlugin.CCLIFileImport', 'The file does not have a valid extension.')) + self.log_error(filename, translate('SongsPlugin.CCLIFileImport', 'The file does not have a valid ' + 'extension.')) log.info('Extension %s is not valid', filename) if self.stop_import_flag: return diff --git a/openlp/plugins/songs/lib/db.py b/openlp/plugins/songs/lib/db.py index ad5bee1a1..c3965e2ed 100644 --- a/openlp/plugins/songs/lib/db.py +++ b/openlp/plugins/songs/lib/db.py @@ -172,7 +172,8 @@ def init_schema(url): session, metadata = init_db(url) # Definition of the "authors" table - authors_table = Table('authors', metadata, + authors_table = Table( + 'authors', metadata, Column('id', types.Integer(), primary_key=True), Column('first_name', types.Unicode(128)), Column('last_name', types.Unicode(128)), @@ -180,7 +181,8 @@ def init_schema(url): ) # Definition of the "media_files" table - media_files_table = Table('media_files', metadata, + media_files_table = Table( + 'media_files', metadata, Column('id', types.Integer(), primary_key=True), Column('song_id', types.Integer(), ForeignKey('songs.id'), default=None), Column('file_name', types.Unicode(255), nullable=False), @@ -189,14 +191,16 @@ def init_schema(url): ) # Definition of the "song_books" table - song_books_table = Table('song_books', metadata, + song_books_table = Table( + 'song_books', metadata, Column('id', types.Integer(), primary_key=True), Column('name', types.Unicode(128), nullable=False), Column('publisher', types.Unicode(128)) ) # Definition of the "songs" table - songs_table = Table('songs', metadata, + songs_table = Table( + 'songs', metadata, Column('id', types.Integer(), primary_key=True), Column('song_book_id', types.Integer(), ForeignKey('song_books.id'), default=None), Column('title', types.Unicode(255), nullable=False), @@ -216,19 +220,22 @@ def init_schema(url): ) # Definition of the "topics" table - topics_table = Table('topics', metadata, + topics_table = Table( + 'topics', metadata, Column('id', types.Integer(), primary_key=True), Column('name', types.Unicode(128), index=True, nullable=False) ) # Definition of the "authors_songs" table - authors_songs_table = Table('authors_songs', metadata, + authors_songs_table = Table( + 'authors_songs', metadata, Column('author_id', types.Integer(), ForeignKey('authors.id'), primary_key=True), Column('song_id', types.Integer(), ForeignKey('songs.id'), primary_key=True) ) # Definition of the "songs_topics" table - songs_topics_table = Table('songs_topics', metadata, + songs_topics_table = Table( + 'songs_topics', metadata, Column('song_id', types.Integer(), ForeignKey('songs.id'), primary_key=True), Column('topic_id', types.Integer(), ForeignKey('topics.id'), primary_key=True) ) @@ -236,13 +243,12 @@ def init_schema(url): mapper(Author, authors_table) mapper(Book, song_books_table) mapper(MediaFile, media_files_table) - mapper(Song, songs_table, - properties={ - 'authors': relation(Author, backref='songs', secondary=authors_songs_table, lazy=False), - 'book': relation(Book, backref='songs'), - 'media_files': relation(MediaFile, backref='songs', order_by=media_files_table.c.weight), - 'topics': relation(Topic, backref='songs', secondary=songs_topics_table) - }) + mapper(Song, songs_table, properties={ + 'authors': relation(Author, backref='songs', secondary=authors_songs_table, lazy=False), + 'book': relation(Book, backref='songs'), + 'media_files': relation(MediaFile, backref='songs', order_by=media_files_table.c.weight), + 'topics': relation(Topic, backref='songs', secondary=songs_topics_table) + }) mapper(Topic, topics_table) metadata.create_all(checkfirst=True) diff --git a/openlp/plugins/songs/lib/dreambeamimport.py b/openlp/plugins/songs/lib/dreambeamimport.py index 18da6d8e3..375867aac 100644 --- a/openlp/plugins/songs/lib/dreambeamimport.py +++ b/openlp/plugins/songs/lib/dreambeamimport.py @@ -120,7 +120,7 @@ class DreamBeamImport(SongImport): author_copyright = song_xml.Author.text if hasattr(song_xml, 'SongLyrics'): for lyrics_item in song_xml.SongLyrics.iterchildren(): - verse_type = lyrics_item.get('Type') + verse_type = lyrics_item.get('Type') verse_number = lyrics_item.get('Number') verse_text = str(lyrics_item.text) self.add_verse(verse_text, ('%s%s' % (verse_type[:1], verse_number))) @@ -145,8 +145,7 @@ class DreamBeamImport(SongImport): author_copyright = song_xml.Text2.Text.text if author_copyright: author_copyright = str(author_copyright) - if author_copyright.find( - str(SongStrings.CopyrightSymbol)) >= 0: + if author_copyright.find(str(SongStrings.CopyrightSymbol)) >= 0: self.add_copyright(author_copyright) else: self.parse_author(author_copyright) diff --git a/openlp/plugins/songs/lib/foilpresenterimport.py b/openlp/plugins/songs/lib/foilpresenterimport.py index 3b6d4e9a8..6f8bd6978 100644 --- a/openlp/plugins/songs/lib/foilpresenterimport.py +++ b/openlp/plugins/songs/lib/foilpresenterimport.py @@ -298,10 +298,10 @@ class FoilPresenter(object): temp = copyright.partition('Rechte') copyright = temp[0] markers = ['Text +u\.?n?d? +Melodie[\w\,\. ]*:', - 'Text +u\.?n?d? +Musik', 'T & M', 'Melodie und Satz', - 'Text[\w\,\. ]*:', 'Melodie', 'Musik', 'Satz', - 'Weise', '[dD]eutsch', '[dD]t[\.\:]', 'Englisch', - '[oO]riginal', 'Bearbeitung', '[R|r]efrain'] + 'Text +u\.?n?d? +Musik', 'T & M', 'Melodie und Satz', + 'Text[\w\,\. ]*:', 'Melodie', 'Musik', 'Satz', + 'Weise', '[dD]eutsch', '[dD]t[\.\:]', 'Englisch', + '[oO]riginal', 'Bearbeitung', '[R|r]efrain'] for marker in markers: copyright = re.compile(marker).sub('<marker>', copyright, re.U) copyright = re.compile('(?<=<marker>) *:').sub('', copyright) @@ -324,12 +324,9 @@ class FoilPresenter(object): for tempx in temp: author_temp.append(tempx) for author in author_temp: - regex = '^[\/,;\-\s\.]+|[\/,;\-\s\.]+$|'\ - '\s*[0-9]{4}\s*[\-\/]?\s*([0-9]{4})?[\/,;\-\s\.]*$' + regex = '^[\/,;\-\s\.]+|[\/,;\-\s\.]+$|\s*[0-9]{4}\s*[\-\/]?\s*([0-9]{4})?[\/,;\-\s\.]*$' author = re.compile(regex).sub('', author) - author = re.compile( - '[0-9]{1,2}\.\s?J(ahr)?h\.|um\s*$|vor\s*$').sub('', - author) + author = re.compile('[0-9]{1,2}\.\s?J(ahr)?h\.|um\s*$|vor\s*$').sub('', author) author = re.compile('[N|n]ach.*$').sub('', author) author = author.strip() if re.search('\w+\.?\s+\w{3,}\s+[a|u]nd\s|\w+\.?\s+\w{3,}\s+&\s', author, re.U): diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 27571c0ca..ad981135f 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -493,9 +493,9 @@ class SongMediaItem(MediaManagerItem): # FIXME: This file seems to be an old one (prior to 1.9.5), which means, that the search title # (data_string[u'title']) is probably wrong. We add "@" to search title and hope that we do not add any # duplicate. This should work for songs without alternate title. - search_results = self.plugin.manager.get_all_objects(Song, - Song.search_title == (re.compile(r'\W+', re.UNICODE).sub(' ', - item.data_string['title'].strip()) + '@').strip().lower(), Song.search_title.asc()) + temp = (re.compile(r'\W+', re.UNICODE).sub(' ', item.data_string['title'].strip()) + '@').strip().lower() + search_results = \ + self.plugin.manager.get_all_objects(Song, Song.search_title == temp, Song.search_title.asc()) else: search_results = self.plugin.manager.get_all_objects( Song, Song.search_title == item.data_string['title'], Song.search_title.asc()) diff --git a/openlp/plugins/songs/lib/olpimport.py b/openlp/plugins/songs/lib/olpimport.py index 171859432..335ba606a 100644 --- a/openlp/plugins/songs/lib/olpimport.py +++ b/openlp/plugins/songs/lib/olpimport.py @@ -128,11 +128,9 @@ class OpenLPSongImport(SongImport): except UnmappedClassError: mapper(OldMediaFile, source_media_files_table) song_props = { - 'authors': relation(OldAuthor, backref='songs', - secondary=source_authors_songs_table), + 'authors': relation(OldAuthor, backref='songs', secondary=source_authors_songs_table), 'book': relation(OldBook, backref='songs'), - 'topics': relation(OldTopic, backref='songs', - secondary=source_songs_topics_table) + 'topics': relation(OldTopic, backref='songs', secondary=source_songs_topics_table) } if has_media_files: if isinstance(source_media_files_songs_table, Table): diff --git a/openlp/plugins/songs/lib/openlyricsexport.py b/openlp/plugins/songs/lib/openlyricsexport.py index 735ef3afe..72210e89f 100644 --- a/openlp/plugins/songs/lib/openlyricsexport.py +++ b/openlp/plugins/songs/lib/openlyricsexport.py @@ -68,8 +68,8 @@ class OpenLyricsExport(RegistryProperties): self.application.process_events() if self.parent.stop_export_flag: return False - self.parent.increment_progress_bar(translate('SongsPlugin.OpenLyricsExport', 'Exporting "%s"...') % - song.title) + self.parent.increment_progress_bar( + translate('SongsPlugin.OpenLyricsExport', 'Exporting "%s"...') % song.title) xml = open_lyrics.song_to_xml(song) tree = etree.ElementTree(etree.fromstring(xml.encode())) filename = '%s (%s)' % (song.title, ', '.join([author.display_name for author in song.authors])) @@ -81,4 +81,3 @@ class OpenLyricsExport(RegistryProperties): tree.write(open(os.path.join(self.save_path, filename), 'wb'), encoding='utf-8', xml_declaration=True, pretty_print=True) return True - diff --git a/openlp/plugins/songs/lib/powersongimport.py b/openlp/plugins/songs/lib/powersongimport.py index 7c5b9e02e..cd568bc2c 100644 --- a/openlp/plugins/songs/lib/powersongimport.py +++ b/openlp/plugins/songs/lib/powersongimport.py @@ -122,7 +122,7 @@ class PowerSongImport(SongImport): parse_error = True self.log_error(os.path.basename(file), str( translate('SongsPlugin.PowerSongImport', 'Invalid %s file. Unexpected byte value.')) % - ps_string) + ps_string) break else: if label == 'TITLE': @@ -145,7 +145,7 @@ class PowerSongImport(SongImport): if not found_copyright: self.log_error(self.title, str( translate('SongsPlugin.PowerSongImport', 'Invalid %s file. Missing "COPYRIGHTLINE" header.')) % - ps_string) + ps_string) continue # Check that file had at least one verse if not self.verses: diff --git a/openlp/plugins/songs/lib/sofimport.py b/openlp/plugins/songs/lib/sofimport.py index a41472201..e44034648 100644 --- a/openlp/plugins/songs/lib/sofimport.py +++ b/openlp/plugins/songs/lib/sofimport.py @@ -287,8 +287,7 @@ class SofImport(OooImport): :param text: The verse text """ - if self.italics != self.is_chorus and ((len(self.verses) > 0) or - (self.current__verse.count('\n') > 1)): + if self.italics != self.is_chorus and ((len(self.verses) > 0) or (self.current__verse.count('\n') > 1)): self.finish_verse() if self.italics: self.is_chorus = True @@ -348,10 +347,10 @@ class SofImport(OooImport): for i in range(1, len(text_arr)): # Do not translate these. Fixed strings in SOF song file if text_arr[i] in ('JESUS', 'CHRIST', 'KING', 'ALMIGHTY', 'REDEEMER', 'SHEPHERD', 'SON', 'GOD', 'LORD', - 'FATHER', 'HOLY', 'SPIRIT', 'LAMB', 'YOU', 'YOUR', 'I', 'I\'VE', 'I\'M', 'I\'LL', - 'SAVIOUR', 'O', 'YOU\'RE', 'HE', 'HIS', 'HIM', 'ZION', 'EMMANUEL', 'MAJESTY', 'JESUS\'', - 'JIREH', 'JUDAH', 'LION', 'LORD\'S', 'ABRAHAM', 'GOD\'S', 'FATHER\'S', 'ELIJAH' 'MARTHA', - 'CHRISTMAS', 'ALPHA', 'OMEGA'): + 'FATHER', 'HOLY', 'SPIRIT', 'LAMB', 'YOU', 'YOUR', 'I', 'I\'VE', 'I\'M', 'I\'LL', + 'SAVIOUR', 'O', 'YOU\'RE', 'HE', 'HIS', 'HIM', 'ZION', 'EMMANUEL', 'MAJESTY', 'JESUS\'', + 'JIREH', 'JUDAH', 'LION', 'LORD\'S', 'ABRAHAM', 'GOD\'S', 'FATHER\'S', + 'ELIJAH' 'MARTHA', 'CHRISTMAS', 'ALPHA', 'OMEGA'): text_arr[i] = text_arr[i].capitalize() else: text_arr[i] = text_arr[i].lower() diff --git a/openlp/plugins/songs/lib/songcompare.py b/openlp/plugins/songs/lib/songcompare.py index 99a04beb2..195923b46 100644 --- a/openlp/plugins/songs/lib/songcompare.py +++ b/openlp/plugins/songs/lib/songcompare.py @@ -113,7 +113,7 @@ def _remove_typos(diff): if len(diff) >= 3: for index in range(len(diff) - 3, -1, -1): if _op_length(diff[index]) >= MIN_FRAGMENT_SIZE and diff[index + 1][0] != "equal" and \ - _op_length(diff[index + 1]) <= MAX_TYPO_SIZE and _op_length(diff[index + 2]) >= MIN_FRAGMENT_SIZE: + _op_length(diff[index + 1]) <= MAX_TYPO_SIZE and _op_length(diff[index + 2]) >= MIN_FRAGMENT_SIZE: del diff[index + 1] # Remove typo at the end of the string. if len(diff) >= 2: diff --git a/openlp/plugins/songs/lib/songimport.py b/openlp/plugins/songs/lib/songimport.py index bb56f3498..a5fbb99e0 100644 --- a/openlp/plugins/songs/lib/songimport.py +++ b/openlp/plugins/songs/lib/songimport.py @@ -364,7 +364,7 @@ class SongImport(QtCore.QObject): """ if not hasattr(self, 'save_path'): self.save_path = os.path.join(AppLocation.get_section_data_path(self.import_wizard.plugin.name), - 'audio', str(song_id)) + 'audio', str(song_id)) check_directory_exists(self.save_path) if not filename.startswith(self.save_path): old_file, filename = filename, os.path.join(self.save_path, os.path.split(filename)[1]) diff --git a/openlp/plugins/songs/lib/songshowplusimport.py b/openlp/plugins/songs/lib/songshowplusimport.py index 50a8698c3..485a8f047 100644 --- a/openlp/plugins/songs/lib/songshowplusimport.py +++ b/openlp/plugins/songs/lib/songshowplusimport.py @@ -140,7 +140,7 @@ class SongShowPlusImport(SongImport): elif block_key == AUTHOR: authors = self.decode(data).split(" / ") for author in authors: - if author.find(",") !=-1: + if author.find(",") != -1: author_parts = author.split(", ") author = author_parts[1] + " " + author_parts[0] self.parse_author(author) @@ -220,4 +220,4 @@ class SongShowPlusImport(SongImport): try: return str(data, chardet.detect(data)['encoding']) except: - return str(data, retrieve_windows_encoding()) \ No newline at end of file + return str(data, retrieve_windows_encoding()) diff --git a/openlp/plugins/songs/lib/sundayplusimport.py b/openlp/plugins/songs/lib/sundayplusimport.py index f63d625c5..f22f8b058 100644 --- a/openlp/plugins/songs/lib/sundayplusimport.py +++ b/openlp/plugins/songs/lib/sundayplusimport.py @@ -138,7 +138,7 @@ class SundayPlusImport(SongImport): elif name == 'Copyright': self.copyright = self.decode(self.unescape(value)) elif name[0:4] == 'CELL': - self.parse(value, cell = name[4:]) + self.parse(value, cell=name[4:]) # We are in a verse group. else: if name == 'MARKER_NAME': @@ -207,4 +207,3 @@ class SundayPlusImport(SongImport): text = text.replace('^^', '"') text = text.replace('^', '\'') return text.strip() - diff --git a/openlp/plugins/songs/lib/test/test.opensong b/openlp/plugins/songs/lib/test/test.opensong deleted file mode 100644 index c75951492..000000000 --- a/openlp/plugins/songs/lib/test/test.opensong +++ /dev/null @@ -1,72 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<song> - <title>Martins Test - MartiÑ & Martin2 Thómpson - 2010 Martin Thompson - 1 - V1 C V2 C2 3a B1 V1 T U Rap1 Rap2 Rap3 - Blah - - - - - - - - TestTheme - TestAltTheme - - - [3a] -. G A B - V3 Line 1 -. G A B - V3 Line 2 - -. A B C -1 v1 Line 1___ -2 v2 Line 1___ -. A B C7 -1 V1 Line 2 -2 V2 Line 2 - -[b1] - Bridge 1 ---- --!! - Bridge 1 line 2 - -[C] - . A B - Chorus 1 - -[C2] -. A B - Chorus 2 - -[T] - T Line 1 - -[Rap] -1 Rap 1 Line 1 -2 Rap 2 Line 1 -1 Rap 1 Line 2 -2 Rap 2 Line 2 - -[rap3] - Rap 3 Line 1 - Rap 3 Line 2 - - -[X] - Unreferenced verse line 1 - - diff --git a/openlp/plugins/songs/lib/test/test.opensong.zip b/openlp/plugins/songs/lib/test/test.opensong.zip deleted file mode 100644 index 62588c8904a2e8e15013fbf5bd9297c92e5cdb8d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 855 zcmWIWW@Zs#U|`^2u$=MIW@{?H(sCvShD3G-23`gkhLY6c621I_)V$*Sy!6lzP6lSa z6muUCF0J5ZU}Sm0%)kI9u7-N&-8K-o`&vY}?Cp!k3wQ$}9di%7Saf&kJ(flX&n+%3 zLadXD9^YG({!*}LBcJEVqDkwxwq&F_JlRtz!*{>u#g}IrMGF$Vif^vm8OBZZC%{)jj+Rk`$AbXjrE?mg1CnpW!g9WK7StNN(PYaY`X_1n4= znRm08alV$&iYN~ejn(|xV7E- z3A5|zeeUsk6~}E3`s>b-CtEV3qe)48g zCf~ukpX@eF`sMoBgtKY4lH2{LkE^z=JDMb@qo!}y>glY#BYfU8{;iW{Xk|3_&UwGo#B6ECxo=v#j>$L1W##>uuU;5 - - Martins 2nd Test - Martin Thompson - 2010 Martin Thompson - 2 - - Blah - - - - - - - - - - - ;Comment -[V] -. A B C -1 v1 Line 1___ -2 v2 Line 1___ -. A B C7 -1 V1 Line 2 -2 V2 Line 2 - -[b1] - Bridge 1 - Bridge 1 line 2 -[C1] - Chorus 1 - -[C2] - Chorus 2 - - diff --git a/openlp/plugins/songs/lib/test/test3.opensong b/openlp/plugins/songs/lib/test/test3.opensong deleted file mode 100644 index 388ab53c7..000000000 --- a/openlp/plugins/songs/lib/test/test3.opensong +++ /dev/null @@ -1,10 +0,0 @@ - - - Test single verse - Martin Thompson - 2010 - 123456 - Worship: Declaration - Line 1 -Line 2 - diff --git a/openlp/plugins/songs/lib/test/test_import_file.py b/openlp/plugins/songs/lib/test/test_import_file.py deleted file mode 100644 index 137d8a7e2..000000000 --- a/openlp/plugins/songs/lib/test/test_import_file.py +++ /dev/null @@ -1,50 +0,0 @@ -# -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 - -############################################################################### -# OpenLP - Open Source Lyrics Projection # -# --------------------------------------------------------------------------- # -# Copyright (c) 2008-2014 Raoul Snyman # -# Portions copyright (c) 2008-2014 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 # -############################################################################### -import sys - -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_import_file.log' -logging.basicConfig(filename=LOG_FILENAME,level=logging.INFO) - -from test_opensongimport import wizard_stub - -def test(filenames): - manager = Manager('songs', init_schema) - o = OpenSongImport(manager, filenames=filenames) - o.import_wizard = wizard_stub() - o.commit = False - o.do_import() - o.print_song() - -if __name__ == "__main__": - test(sys.argv[1:]) diff --git a/openlp/plugins/songs/lib/test/test_importing_lots.py b/openlp/plugins/songs/lib/test/test_importing_lots.py deleted file mode 100644 index c7293ae0e..000000000 --- a/openlp/plugins/songs/lib/test/test_importing_lots.py +++ /dev/null @@ -1,61 +0,0 @@ -# -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 - -############################################################################### -# OpenLP - Open Source Lyrics Projection # -# --------------------------------------------------------------------------- # -# Copyright (c) 2008-2014 Raoul Snyman # -# Portions copyright (c) 2008-2014 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.plugins.songs.lib.db import init_schema -from openlp.core.lib.db import Manager -import os -import codecs - -import logging -LOG_FILENAME = 'import.log' -logging.basicConfig(filename=LOG_FILENAME,level=logging.INFO) - -from test_opensongimport import wizard_stub - -# Useful test function for importing a variety of different files -# Uncomment below depending on what problem trying to make occur! - -def opensong_import_lots(): - ziploc = '/home/mjt/openlp/OpenSong_Data/' - files = [] - files = [os.path.join(ziploc, 'RaoulSongs', 'Songs', 'Jesus Freak')] - # files.extend(glob(ziploc+u'Songs.zip')) - # files.extend(glob(ziploc+u'RaoulSongs.zip')) - # files.extend(glob(ziploc+u'SOF.zip')) - # files.extend(glob(ziploc+u'spanish_songs_for_opensong.zip')) - # files.extend(glob(ziploc+u'opensong_*.zip')) - errfile = codecs.open('import_lots_errors.txt', 'w', 'utf8') - manager = Manager('songs', init_schema) - o = OpenSongImport(manager, filenames=files) - o.import_wizard=wizard_stub() - o.do_import() - -if __name__ == "__main__": - opensong_import_lots() diff --git a/openlp/plugins/songs/lib/ui.py b/openlp/plugins/songs/lib/ui.py index a2fe38c74..14f4777c9 100644 --- a/openlp/plugins/songs/lib/ui.py +++ b/openlp/plugins/songs/lib/ui.py @@ -40,11 +40,11 @@ class SongStrings(object): # These strings should need a good reason to be retranslated elsewhere. Author = translate('OpenLP.Ui', 'Author', 'Singular') Authors = translate('OpenLP.Ui', 'Authors', 'Plural') - AuthorUnknown = 'Author Unknown' # Used to populate the database. + AuthorUnknown = 'Author Unknown' # Used to populate the database. CopyrightSymbol = translate('OpenLP.Ui', '\xa9', 'Copyright symbol.') SongBook = translate('OpenLP.Ui', 'Song Book', 'Singular') SongBooks = translate('OpenLP.Ui', 'Song Books', 'Plural') - SongIncomplete = translate('OpenLP.Ui','Title and/or verses not found') + SongIncomplete = translate('OpenLP.Ui', 'Title and/or verses not found') SongMaintenance = translate('OpenLP.Ui', 'Song Maintenance') Topic = translate('OpenLP.Ui', 'Topic', 'Singular') Topics = translate('OpenLP.Ui', 'Topics', 'Plural') diff --git a/openlp/plugins/songs/lib/upgrade.py b/openlp/plugins/songs/lib/upgrade.py index ee01fb8b0..fdb0f17ef 100644 --- a/openlp/plugins/songs/lib/upgrade.py +++ b/openlp/plugins/songs/lib/upgrade.py @@ -82,4 +82,3 @@ def upgrade_3(session, metadata): op.add_column('songs', Column('temporary', types.Boolean(create_constraint=False), server_default=false())) else: op.add_column('songs', Column('temporary', types.Boolean(), server_default=false())) - diff --git a/openlp/plugins/songs/lib/worshipcenterproimport.py b/openlp/plugins/songs/lib/worshipcenterproimport.py index 80b1b5fe3..b24d2ae83 100644 --- a/openlp/plugins/songs/lib/worshipcenterproimport.py +++ b/openlp/plugins/songs/lib/worshipcenterproimport.py @@ -56,12 +56,12 @@ class WorshipCenterProImport(SongImport): Receive a single file to import. """ try: - conn = pyodbc.connect('DRIVER={Microsoft Access Driver (*.mdb)};DBQ=%s' % self.import_source) + conn = pyodbc.connect('DRIVER={Microsoft Access Driver (*.mdb)};DBQ=%s' % self.import_source) except (pyodbc.DatabaseError, pyodbc.IntegrityError, pyodbc.InternalError, pyodbc.OperationalError) as e: log.warn('Unable to connect the WorshipCenter Pro database %s. %s', self.import_source, str(e)) # Unfortunately no specific exception type - self.log_error(self.import_source, - translate('SongsPlugin.WorshipCenterProImport', 'Unable to connect the WorshipCenter Pro database.')) + self.log_error(self.import_source, translate('SongsPlugin.WorshipCenterProImport', + 'Unable to connect the WorshipCenter Pro database.')) return cursor = conn.cursor() cursor.execute('SELECT ID, Field, Value FROM __SONGDATA') diff --git a/openlp/plugins/songs/lib/xml.py b/openlp/plugins/songs/lib/xml.py index 95ae4fc33..667afebdd 100644 --- a/openlp/plugins/songs/lib/xml.py +++ b/openlp/plugins/songs/lib/xml.py @@ -340,7 +340,8 @@ class OpenLyrics(object): The first unicode string are the start tags (for the next slide). The second unicode string are the end tags. - :param text: The text to test. The text must **not** contain html tags, only OpenLP formatting tags are allowed:: + :param text: The text to test. The text must **not** contain html tags, only OpenLP formatting tags + are allowed:: {st}{r}Text text text """ diff --git a/openlp/plugins/songs/lib/zionworximport.py b/openlp/plugins/songs/lib/zionworximport.py index ab6bcb27d..dfdc2373d 100644 --- a/openlp/plugins/songs/lib/zionworximport.py +++ b/openlp/plugins/songs/lib/zionworximport.py @@ -39,7 +39,7 @@ from openlp.plugins.songs.lib.songimport import SongImport log = logging.getLogger(__name__) # Used to strip control chars (except 10=LF, 13=CR) -CONTROL_CHARS_MAP = dict.fromkeys(list(range(10)) + [11, 12] + list(range(14,32)) + [127]) +CONTROL_CHARS_MAP = dict.fromkeys(list(range(10)) + [11, 12] + list(range(14, 32)) + [127]) class ZionWorxImport(SongImport): diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py index 32d3ddbe6..1c000338c 100644 --- a/openlp/plugins/songs/songsplugin.py +++ b/openlp/plugins/songs/songsplugin.py @@ -342,7 +342,7 @@ class SongsPlugin(Plugin): """ Remove temporary songs from the database """ - songs = self.manager.get_all_objects(Song, Song.temporary == True) + songs = self.manager.get_all_objects(Song, Song.temporary is True) for song in songs: self.manager.delete_object(Song, song.id) From ad1970f27e8eeaa54f9fcbeab66e6da297172f1d Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 22 Mar 2014 10:53:55 +0100 Subject: [PATCH 08/51] fixed spelling --- 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 3526e551f..e1f1dc51f 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -652,7 +652,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow, RegistryProperties): translate('OpenLP.MainWindow', 'Are you sure you want to re-run the First ' 'Time Wizard?\n\nRe-running this wizard may make changes to your ' 'current OpenLP configuration and possibly add songs to your ' - '#existing songs list and change your default theme.'), + 'existing songs list and change your default theme.'), QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No), QtGui.QMessageBox.No) From d5b421aa70acf2ad617382c7f784531f5219678c Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 22 Mar 2014 20:18:27 +0100 Subject: [PATCH 09/51] updated vlc.py --- openlp/core/ui/media/vendor/vlc.py | 88 +++++++++++++++--------------- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/openlp/core/ui/media/vendor/vlc.py b/openlp/core/ui/media/vendor/vlc.py index 8646450b1..df139ae36 100644 --- a/openlp/core/ui/media/vendor/vlc.py +++ b/openlp/core/ui/media/vendor/vlc.py @@ -52,9 +52,9 @@ build_date = "Tue Jul 2 10:35:53 2013" if sys.version_info[0] > 2: str = str - str = str + unicode = str bytes = bytes - str = (str, bytes) + basestring = (str, bytes) PYTHON3 = True def str_to_bytes(s): """Translate string or bytes to bytes. @@ -73,14 +73,14 @@ if sys.version_info[0] > 2: return b else: str = str - str = str + unicode = unicode bytes = str - str = str + basestring = basestring PYTHON3 = False def str_to_bytes(s): """Translate string or bytes to bytes. """ - if isinstance(s, str): + if isinstance(s, unicode): return s.encode(sys.getfilesystemencoding()) else: return s @@ -89,7 +89,7 @@ else: """Translate bytes to unicode string. """ if isinstance(b, str): - return str(b, sys.getfilesystemencoding()) + return unicode(b, sys.getfilesystemencoding()) else: return b @@ -110,7 +110,7 @@ def find_lib(): p = find_library('libvlc.dll') if p is None: try: # some registry settings - import winreg as w # leaner than win32api, win32con + import _winreg as w # leaner than win32api, win32con for r in w.HKEY_LOCAL_MACHINE, w.HKEY_CURRENT_USER: try: r = w.OpenKey(r, 'Software\\VideoLAN\\VLC') @@ -168,7 +168,7 @@ class VLCException(Exception): pass try: - _Ints = (int, int) + _Ints = (int, long) except NameError: # no long in Python 3+ _Ints = int _Seqs = (list, tuple) @@ -823,7 +823,7 @@ class CallbackDecorators(object): Callback = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p) Callback.__doc__ = '''Callback function notification \param p_event the event triggering the callback - ''' + ''' LogCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_int, Log_ptr, ctypes.c_char_p, ctypes.c_void_p) LogCb.__doc__ = '''Callback prototype for LibVLC log message handler. \param data data pointer as given to L{libvlc_log_set}() @@ -834,7 +834,7 @@ class CallbackDecorators(object): \note Log message handlers must be thread-safe. \warning The message context pointer, the format string parameters and the variable arguments are only valid until the callback returns. - ''' + ''' VideoLockCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ListPOINTER(ctypes.c_void_p)) VideoLockCb.__doc__ = '''Callback prototype to allocate and lock a picture buffer. Whenever a new video frame needs to be decoded, the lock callback is @@ -846,7 +846,7 @@ planes must be aligned on 32-bytes boundaries. of void pointers, this callback must initialize the array) [OUT] \return a private pointer for the display and unlock callbacks to identify the picture buffers - ''' + ''' VideoUnlockCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p, ListPOINTER(ctypes.c_void_p)) VideoUnlockCb.__doc__ = '''Callback prototype to unlock a picture buffer. When the video frame decoding is complete, the unlock callback is invoked. @@ -859,7 +859,7 @@ but before the picture is displayed. callback [IN] \param planes pixel planes as defined by the @ref libvlc_video_lock_cb callback (this parameter is only for convenience) [IN] - ''' + ''' VideoDisplayCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p) VideoDisplayCb.__doc__ = '''Callback prototype to display a picture. When the video frame needs to be shown, as determined by the media playback @@ -867,7 +867,7 @@ clock, the display callback is invoked. \param opaque private pointer as passed to L{libvlc_video_set_callbacks}() [IN] \param picture private pointer returned from the @ref libvlc_video_lock_cb callback [IN] - ''' + ''' VideoFormatCb = ctypes.CFUNCTYPE(ctypes.POINTER(ctypes.c_uint), ListPOINTER(ctypes.c_void_p), ctypes.c_char_p, ctypes.POINTER(ctypes.c_uint), ctypes.POINTER(ctypes.c_uint), ctypes.POINTER(ctypes.c_uint), ctypes.POINTER(ctypes.c_uint)) VideoFormatCb.__doc__ = '''Callback prototype to configure picture buffers format. This callback gets the format of the video as output by the video decoder @@ -891,47 +891,47 @@ the pixel height. Furthermore, we recommend that pitches and lines be multiple of 32 to not break assumption that might be made by various optimizations in the video decoders, video filters and/or video converters. - ''' + ''' VideoCleanupCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p) VideoCleanupCb.__doc__ = '''Callback prototype to configure picture buffers format. \param opaque private pointer as passed to L{libvlc_video_set_callbacks}() (and possibly modified by @ref libvlc_video_format_cb) [IN] - ''' + ''' AudioPlayCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p, ctypes.c_uint, ctypes.c_int64) AudioPlayCb.__doc__ = '''Callback prototype for audio playback. \param data data pointer as passed to L{libvlc_audio_set_callbacks}() [IN] \param samples pointer to the first audio sample to play back [IN] \param count number of audio samples to play back \param pts expected play time stamp (see libvlc_delay()) - ''' + ''' AudioPauseCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_int64) AudioPauseCb.__doc__ = '''Callback prototype for audio pause. \note The pause callback is never called if the audio is already paused. \param data data pointer as passed to L{libvlc_audio_set_callbacks}() [IN] \param pts time stamp of the pause request (should be elapsed already) - ''' + ''' AudioResumeCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_int64) AudioResumeCb.__doc__ = '''Callback prototype for audio resumption (i.e. restart from pause). \note The resume callback is never called if the audio is not paused. \param data data pointer as passed to L{libvlc_audio_set_callbacks}() [IN] \param pts time stamp of the resumption request (should be elapsed already) - ''' + ''' AudioFlushCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_int64) AudioFlushCb.__doc__ = '''Callback prototype for audio buffer flush (i.e. discard all pending buffers and stop playback as soon as possible). \param data data pointer as passed to L{libvlc_audio_set_callbacks}() [IN] - ''' + ''' AudioDrainCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p) AudioDrainCb.__doc__ = '''Callback prototype for audio buffer drain (i.e. wait for pending buffers to be played). \param data data pointer as passed to L{libvlc_audio_set_callbacks}() [IN] - ''' + ''' AudioSetVolumeCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_float, ctypes.c_bool) AudioSetVolumeCb.__doc__ = '''Callback prototype for audio volume change. \param data data pointer as passed to L{libvlc_audio_set_callbacks}() [IN] \param volume software volume (1. = nominal, 0. = mute) \param mute muted flag - ''' + ''' AudioSetupCb = ctypes.CFUNCTYPE(ctypes.POINTER(ctypes.c_int), ListPOINTER(ctypes.c_void_p), ctypes.c_char_p, ctypes.POINTER(ctypes.c_uint), ctypes.POINTER(ctypes.c_uint)) AudioSetupCb.__doc__ = '''Callback prototype to setup the audio playback. This is called when the media player needs to create a new audio output. @@ -941,12 +941,12 @@ This is called when the media player needs to create a new audio output. \param rate sample rate [IN/OUT] \param channels channels count [IN/OUT] \return 0 on success, anything else to skip audio playback - ''' + ''' AudioCleanupCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p) AudioCleanupCb.__doc__ = '''Callback prototype for audio playback cleanup. This is called when the media player no longer needs an audio output. \param opaque data pointer as passed to L{libvlc_audio_set_callbacks}() [IN] - ''' + ''' cb = CallbackDecorators # End of generated enum types # @@ -1210,7 +1210,7 @@ class EventManager(_Ctype): @note: Only a single notification can be registered for each event type in an EventManager instance. - + ''' _callback_handler = None @@ -1287,7 +1287,7 @@ class Instance(_Ctype): - a string - a list of strings as first parameters - the parameters given as the constructor parameters (must be strings) - + ''' def __new__(cls, *args): @@ -1297,7 +1297,7 @@ class Instance(_Ctype): i = args[0] if isinstance(i, _Ints): return _Constructor(cls, i) - elif isinstance(i, str): + elif isinstance(i, basestring): args = i.strip().split() elif isinstance(i, _Seqs): args = i @@ -1753,11 +1753,11 @@ class Instance(_Ctype): class Media(_Ctype): '''Create a new Media instance. - + Usage: Media(MRL, *options) See vlc.Instance.media_new documentation for details. - + ''' def __new__(cls, *args): @@ -2053,11 +2053,11 @@ class MediaLibrary(_Ctype): class MediaList(_Ctype): '''Create a new MediaList instance. - + Usage: MediaList(list_of_MRLs) See vlc.Instance.media_list_new documentation for details. - + ''' def __new__(cls, *args): @@ -2073,15 +2073,15 @@ class MediaList(_Ctype): def get_instance(self): return getattr(self, '_instance', None) - + def add_media(self, mrl): """Add media instance to media list. - + The L{lock} should be held upon entering this function. @param mrl: a media instance or a MRL. @return: 0 on success, -1 if the media list is read-only. """ - if isinstance(mrl, str): + if isinstance(mrl, basestring): mrl = (self.get_instance() or get_default_instance()).media_new(mrl) return libvlc_media_list_add_media(self, mrl) @@ -2193,7 +2193,7 @@ class MediaListPlayer(_Ctype): It may take as parameter either: - a vlc.Instance - nothing - + ''' def __new__(cls, arg=None): @@ -2319,13 +2319,13 @@ class MediaPlayer(_Ctype): It may take as parameter either: - a string (media URI), options... In this case, a vlc.Instance will be created. - a vlc.Instance, a string (media URI), options... - + ''' def __new__(cls, *args): if len(args) == 1 and isinstance(args[0], _Ints): return _Constructor(cls, args[0]) - + if args and isinstance(args[0], Instance): instance = args[0] args = args[1:] @@ -2397,13 +2397,13 @@ class MediaPlayer(_Ctype): Specify where the media player should render its video output. If LibVLC was built without Win32/Win64 API output support, then this has no effects. - + @param drawable: windows handle of the drawable. """ if not isinstance(drawable, ctypes.c_void_p): drawable = ctypes.c_void_p(int(drawable)) libvlc_media_player_set_hwnd(self, drawable) - + def video_get_width(self, num=0): """Get the width of a video in pixels. @@ -2556,12 +2556,12 @@ class MediaPlayer(_Ctype): If you want to use it along with Qt4 see the QMacCocoaViewContainer. Then the following code should work: @begincode - + NSView *video = [[NSView alloc] init]; QMacCocoaViewContainer *container = new QMacCocoaViewContainer(video, parent); L{set_nsobject}(mp, video); [video release]; - + @endcode You can find a live example in VLCVideoView in VLCKit.framework. @param drawable: the drawable that is either an NSView or an object following the VLCOpenGLVideoViewEmbedding protocol. @@ -4430,12 +4430,12 @@ def libvlc_media_player_set_nsobject(p_mi, drawable): If you want to use it along with Qt4 see the QMacCocoaViewContainer. Then the following code should work: @begincode - + NSView *video = [[NSView alloc] init]; QMacCocoaViewContainer *container = new QMacCocoaViewContainer(video, parent); L{libvlc_media_player_set_nsobject}(mp, video); [video release]; - + @endcode You can find a live example in VLCVideoView in VLCKit.framework. @param p_mi: the Media Player. @@ -5948,9 +5948,9 @@ def debug_callback(event, *args, **kwds): ''' l = ['event %s' % (event.type,)] if args: - l.extend(list(map(str, args))) + l.extend(map(str, args)) if kwds: - l.extend(sorted('%s=%s' % t for t in list(kwds.items()))) + l.extend(sorted('%s=%s' % t for t in kwds.items())) print('Debug callback (%s)' % ', '.join(l)) if __name__ == '__main__': From 47ad40aaac3569792cb6dfd3d52776c1ca6fbed2 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 22 Mar 2014 20:19:08 +0100 Subject: [PATCH 10/51] removed white spaces --- openlp/core/ui/media/vendor/vlc.py | 64 +++++++++++++++--------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/openlp/core/ui/media/vendor/vlc.py b/openlp/core/ui/media/vendor/vlc.py index df139ae36..0326e4104 100644 --- a/openlp/core/ui/media/vendor/vlc.py +++ b/openlp/core/ui/media/vendor/vlc.py @@ -823,7 +823,7 @@ class CallbackDecorators(object): Callback = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p) Callback.__doc__ = '''Callback function notification \param p_event the event triggering the callback - ''' + ''' LogCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_int, Log_ptr, ctypes.c_char_p, ctypes.c_void_p) LogCb.__doc__ = '''Callback prototype for LibVLC log message handler. \param data data pointer as given to L{libvlc_log_set}() @@ -834,7 +834,7 @@ class CallbackDecorators(object): \note Log message handlers must be thread-safe. \warning The message context pointer, the format string parameters and the variable arguments are only valid until the callback returns. - ''' + ''' VideoLockCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ListPOINTER(ctypes.c_void_p)) VideoLockCb.__doc__ = '''Callback prototype to allocate and lock a picture buffer. Whenever a new video frame needs to be decoded, the lock callback is @@ -846,7 +846,7 @@ planes must be aligned on 32-bytes boundaries. of void pointers, this callback must initialize the array) [OUT] \return a private pointer for the display and unlock callbacks to identify the picture buffers - ''' + ''' VideoUnlockCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p, ListPOINTER(ctypes.c_void_p)) VideoUnlockCb.__doc__ = '''Callback prototype to unlock a picture buffer. When the video frame decoding is complete, the unlock callback is invoked. @@ -859,7 +859,7 @@ but before the picture is displayed. callback [IN] \param planes pixel planes as defined by the @ref libvlc_video_lock_cb callback (this parameter is only for convenience) [IN] - ''' + ''' VideoDisplayCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p) VideoDisplayCb.__doc__ = '''Callback prototype to display a picture. When the video frame needs to be shown, as determined by the media playback @@ -867,7 +867,7 @@ clock, the display callback is invoked. \param opaque private pointer as passed to L{libvlc_video_set_callbacks}() [IN] \param picture private pointer returned from the @ref libvlc_video_lock_cb callback [IN] - ''' + ''' VideoFormatCb = ctypes.CFUNCTYPE(ctypes.POINTER(ctypes.c_uint), ListPOINTER(ctypes.c_void_p), ctypes.c_char_p, ctypes.POINTER(ctypes.c_uint), ctypes.POINTER(ctypes.c_uint), ctypes.POINTER(ctypes.c_uint), ctypes.POINTER(ctypes.c_uint)) VideoFormatCb.__doc__ = '''Callback prototype to configure picture buffers format. This callback gets the format of the video as output by the video decoder @@ -891,47 +891,47 @@ the pixel height. Furthermore, we recommend that pitches and lines be multiple of 32 to not break assumption that might be made by various optimizations in the video decoders, video filters and/or video converters. - ''' + ''' VideoCleanupCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p) VideoCleanupCb.__doc__ = '''Callback prototype to configure picture buffers format. \param opaque private pointer as passed to L{libvlc_video_set_callbacks}() (and possibly modified by @ref libvlc_video_format_cb) [IN] - ''' + ''' AudioPlayCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p, ctypes.c_uint, ctypes.c_int64) AudioPlayCb.__doc__ = '''Callback prototype for audio playback. \param data data pointer as passed to L{libvlc_audio_set_callbacks}() [IN] \param samples pointer to the first audio sample to play back [IN] \param count number of audio samples to play back \param pts expected play time stamp (see libvlc_delay()) - ''' + ''' AudioPauseCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_int64) AudioPauseCb.__doc__ = '''Callback prototype for audio pause. \note The pause callback is never called if the audio is already paused. \param data data pointer as passed to L{libvlc_audio_set_callbacks}() [IN] \param pts time stamp of the pause request (should be elapsed already) - ''' + ''' AudioResumeCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_int64) AudioResumeCb.__doc__ = '''Callback prototype for audio resumption (i.e. restart from pause). \note The resume callback is never called if the audio is not paused. \param data data pointer as passed to L{libvlc_audio_set_callbacks}() [IN] \param pts time stamp of the resumption request (should be elapsed already) - ''' + ''' AudioFlushCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_int64) AudioFlushCb.__doc__ = '''Callback prototype for audio buffer flush (i.e. discard all pending buffers and stop playback as soon as possible). \param data data pointer as passed to L{libvlc_audio_set_callbacks}() [IN] - ''' + ''' AudioDrainCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p) AudioDrainCb.__doc__ = '''Callback prototype for audio buffer drain (i.e. wait for pending buffers to be played). \param data data pointer as passed to L{libvlc_audio_set_callbacks}() [IN] - ''' + ''' AudioSetVolumeCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_float, ctypes.c_bool) AudioSetVolumeCb.__doc__ = '''Callback prototype for audio volume change. \param data data pointer as passed to L{libvlc_audio_set_callbacks}() [IN] \param volume software volume (1. = nominal, 0. = mute) \param mute muted flag - ''' + ''' AudioSetupCb = ctypes.CFUNCTYPE(ctypes.POINTER(ctypes.c_int), ListPOINTER(ctypes.c_void_p), ctypes.c_char_p, ctypes.POINTER(ctypes.c_uint), ctypes.POINTER(ctypes.c_uint)) AudioSetupCb.__doc__ = '''Callback prototype to setup the audio playback. This is called when the media player needs to create a new audio output. @@ -941,12 +941,12 @@ This is called when the media player needs to create a new audio output. \param rate sample rate [IN/OUT] \param channels channels count [IN/OUT] \return 0 on success, anything else to skip audio playback - ''' + ''' AudioCleanupCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p) AudioCleanupCb.__doc__ = '''Callback prototype for audio playback cleanup. This is called when the media player no longer needs an audio output. \param opaque data pointer as passed to L{libvlc_audio_set_callbacks}() [IN] - ''' + ''' cb = CallbackDecorators # End of generated enum types # @@ -1210,7 +1210,7 @@ class EventManager(_Ctype): @note: Only a single notification can be registered for each event type in an EventManager instance. - + ''' _callback_handler = None @@ -1287,7 +1287,7 @@ class Instance(_Ctype): - a string - a list of strings as first parameters - the parameters given as the constructor parameters (must be strings) - + ''' def __new__(cls, *args): @@ -1753,11 +1753,11 @@ class Instance(_Ctype): class Media(_Ctype): '''Create a new Media instance. - + Usage: Media(MRL, *options) See vlc.Instance.media_new documentation for details. - + ''' def __new__(cls, *args): @@ -2053,11 +2053,11 @@ class MediaLibrary(_Ctype): class MediaList(_Ctype): '''Create a new MediaList instance. - + Usage: MediaList(list_of_MRLs) See vlc.Instance.media_list_new documentation for details. - + ''' def __new__(cls, *args): @@ -2073,10 +2073,10 @@ class MediaList(_Ctype): def get_instance(self): return getattr(self, '_instance', None) - + def add_media(self, mrl): """Add media instance to media list. - + The L{lock} should be held upon entering this function. @param mrl: a media instance or a MRL. @return: 0 on success, -1 if the media list is read-only. @@ -2193,7 +2193,7 @@ class MediaListPlayer(_Ctype): It may take as parameter either: - a vlc.Instance - nothing - + ''' def __new__(cls, arg=None): @@ -2319,13 +2319,13 @@ class MediaPlayer(_Ctype): It may take as parameter either: - a string (media URI), options... In this case, a vlc.Instance will be created. - a vlc.Instance, a string (media URI), options... - + ''' def __new__(cls, *args): if len(args) == 1 and isinstance(args[0], _Ints): return _Constructor(cls, args[0]) - + if args and isinstance(args[0], Instance): instance = args[0] args = args[1:] @@ -2397,13 +2397,13 @@ class MediaPlayer(_Ctype): Specify where the media player should render its video output. If LibVLC was built without Win32/Win64 API output support, then this has no effects. - + @param drawable: windows handle of the drawable. """ if not isinstance(drawable, ctypes.c_void_p): drawable = ctypes.c_void_p(int(drawable)) libvlc_media_player_set_hwnd(self, drawable) - + def video_get_width(self, num=0): """Get the width of a video in pixels. @@ -2556,12 +2556,12 @@ class MediaPlayer(_Ctype): If you want to use it along with Qt4 see the QMacCocoaViewContainer. Then the following code should work: @begincode - + NSView *video = [[NSView alloc] init]; QMacCocoaViewContainer *container = new QMacCocoaViewContainer(video, parent); L{set_nsobject}(mp, video); [video release]; - + @endcode You can find a live example in VLCVideoView in VLCKit.framework. @param drawable: the drawable that is either an NSView or an object following the VLCOpenGLVideoViewEmbedding protocol. @@ -4430,12 +4430,12 @@ def libvlc_media_player_set_nsobject(p_mi, drawable): If you want to use it along with Qt4 see the QMacCocoaViewContainer. Then the following code should work: @begincode - + NSView *video = [[NSView alloc] init]; QMacCocoaViewContainer *container = new QMacCocoaViewContainer(video, parent); L{libvlc_media_player_set_nsobject}(mp, video); [video release]; - + @endcode You can find a live example in VLCVideoView in VLCKit.framework. @param p_mi: the Media Player. From 7a1825a79a44a7bdda5c029734a61dfb4fee9dda Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sun, 23 Mar 2014 11:49:03 +0100 Subject: [PATCH 11/51] tests --- openlp/core/lib/searchedit.py | 13 +- .../openlp_core_lib/test_searchedit.py | 137 ++++++++++++++++++ 2 files changed, 140 insertions(+), 10 deletions(-) create mode 100644 tests/interfaces/openlp_core_lib/test_searchedit.py diff --git a/openlp/core/lib/searchedit.py b/openlp/core/lib/searchedit.py index d6eaafa7d..4e79beaae 100644 --- a/openlp/core/lib/searchedit.py +++ b/openlp/core/lib/searchedit.py @@ -179,15 +179,8 @@ class SearchEdit(QtGui.QLineEdit): correct action on the button, and set the current search type (using the list of identifiers provided by the developer), the ``searchTypeChanged(int)`` signal is emitted with the identifier. """ - sender = self.sender() for action in self.menu_button.menu().actions(): + # Why is this needed? action.setChecked(False) - self.menu_button.setDefaultAction(sender) - self._current_search_type = sender.data() - # setplaceholder_text has been implemented in Qt 4.7 and in at least - # PyQt 4.9 (I am not sure, if it was implemented in PyQt 4.8). - try: - self.setPlaceholderText(self.menu_button.defaultAction().placeholder_text) - except AttributeError: - pass - self.emit(QtCore.SIGNAL('searchTypeChanged(int)'), self._current_search_type) + sender = self.sender() + self.set_current_search_type(sender.data()) diff --git a/tests/interfaces/openlp_core_lib/test_searchedit.py b/tests/interfaces/openlp_core_lib/test_searchedit.py new file mode 100644 index 000000000..5814d10f8 --- /dev/null +++ b/tests/interfaces/openlp_core_lib/test_searchedit.py @@ -0,0 +1,137 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2014 Raoul Snyman # +# Portions copyright (c) 2008-2014 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 # +############################################################################### +""" +Module to test the EditCustomForm. +""" +from unittest import TestCase +from unittest.mock import MagicMock + +from PyQt4 import QtCore, QtGui, QtTest + +from openlp.core.common import Registry +from openlp.core.lib.searchedit import SearchEdit +from tests.helpers.testmixin import TestMixin + + +class SearchTypes(object): + First = 0 + Second = 1 + + +SECOND_PLACEHOLDER_TEXT = "Second Placeholder Text" +SEARCH_TYPES = [(SearchTypes.First, QtGui.QIcon(), "First", "First Placeholder Text"), + (SearchTypes.Second, QtGui.QIcon(), "Second", SECOND_PLACEHOLDER_TEXT)] + + +class TestSearchEdit(TestCase, TestMixin): + """ + Test the EditCustomForm. + """ + def setUp(self): + """ + Create the UI + """ + Registry.create() + self.get_application() + self.main_window = QtGui.QMainWindow() + Registry().register('main_window', self.main_window) + + self.search_edit = SearchEdit(self.main_window) + # To complete set up we have to set the search types. + self.search_edit.set_search_types(SEARCH_TYPES) + + def tearDown(self): + """ + Delete all the C++ objects at the end so that we don't have a segfault + """ + del self.main_window + + + def set_search_types_test(self): + """ + Test setting the search types of the search edit. + """ + # GIVEN: The search edit with the search types set. NOTE: The set_search_types(types) is called in the setUp() + # method! + + # WHEN: + + # THEN: The first search type should be the first one in the list. + assert self.search_edit.current_search_type() == SearchTypes.First, "The first search type should be selected." + + def set_current_search_type_test(self): + """ + Test if changing the search type works. + """ + # GIVEN: + # WHEN: Change the search type + result = self.search_edit.set_current_search_type(SearchTypes.Second) + + # THEN: + assert result, "The call should return success (True)." + assert self.search_edit.current_search_type() == SearchTypes.Second,\ + "The search type should be SearchTypes.Second" + assert self.search_edit.placeholderText() == SECOND_PLACEHOLDER_TEXT,\ + "The correct placeholder text should be 'Second Placeholder Text'." + + def clear_button_visibility_test(self): + """ + Test if the clear button is hidden/shown correctly. + """ + # GIVEN: Everything is left to its defaults (hidden). + assert self.search_edit.clear_button.isHidden(), "Pre condition not met. Button should be hidden." + + # WHEN: Type something in the search edit. + QtTest.QTest.keyPress(self.search_edit, QtCore.Qt.Key_A) + QtTest.QTest.keyRelease(self.search_edit, QtCore.Qt.Key_A) + + # THEN: The clear button should not be hidden any more. + assert not self.search_edit.clear_button.isHidden(), "The clear button should be visible." + + def press_clear_button_test(self): + """ + Check if the search edit behaves correctly when pressing the clear button. + """ + # GIVEN: A search edit with text. + QtTest.QTest.keyPress(self.search_edit, QtCore.Qt.Key_A) + QtTest.QTest.keyRelease(self.search_edit, QtCore.Qt.Key_A) + + # WHEN: Press the clear button. + QtTest.QTest.mouseClick(self.search_edit.clear_button, QtCore.Qt.LeftButton) + + # THEN: The search edit text should be cleared and the button be hidden. + assert not self.search_edit.text(), "The search edit should not have any text." + assert self.search_edit.clear_button.isHidden(), "The clear button should be hidden." + + def resize_event_test(self): + """ + Just check if the resizeEvent() method is re-implemented. + """ + assert hasattr(self.search_edit, "resizeEvent"), "The search edit should re-implement the resizeEvent method." + \ No newline at end of file From fcf4d0ce1767f0f211d6497cdc5f37a9b99eb2e2 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sun, 23 Mar 2014 11:53:11 +0100 Subject: [PATCH 12/51] missing line at the end --- tests/interfaces/openlp_core_lib/test_searchedit.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/interfaces/openlp_core_lib/test_searchedit.py b/tests/interfaces/openlp_core_lib/test_searchedit.py index 5814d10f8..07db05dd7 100644 --- a/tests/interfaces/openlp_core_lib/test_searchedit.py +++ b/tests/interfaces/openlp_core_lib/test_searchedit.py @@ -134,4 +134,5 @@ class TestSearchEdit(TestCase, TestMixin): Just check if the resizeEvent() method is re-implemented. """ assert hasattr(self.search_edit, "resizeEvent"), "The search edit should re-implement the resizeEvent method." + \ No newline at end of file From 20533624e0aef3ea3822e1991409ca9d367e32d1 Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Sun, 23 Mar 2014 23:27:07 +0100 Subject: [PATCH 13/51] Fix method calls (broken with rev. 2329) --- openlp/plugins/songs/forms/editsongform.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 8b1e3a897..b655c0f73 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -601,7 +601,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog, RegistryProperties): def on_verse_add_button_clicked(self): self.verse_form.set_verse('', True) if self.verse_form.exec_(): - after_text, verse_tag, verse_num = self.verse_form.get_verse + after_text, verse_tag, verse_num = self.verse_form.get_verse() verse_def = '%s%s' % (verse_tag, verse_num) item = QtGui.QTableWidgetItem(after_text) item.setData(QtCore.Qt.UserRole, verse_def) @@ -619,7 +619,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog, RegistryProperties): verse_id = item.data(QtCore.Qt.UserRole) self.verse_form.set_verse(temp_text, True, verse_id) if self.verse_form.exec_(): - after_text, verse_tag, verse_num = self.verse_form.get_verse + after_text, verse_tag, verse_num = self.verse_form.get_verse() verse_def = '%s%s' % (verse_tag, verse_num) item.setData(QtCore.Qt.UserRole, verse_def) item.setText(after_text) @@ -661,7 +661,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog, RegistryProperties): self.verse_form.set_verse('') if not self.verse_form.exec_(): return - verse_list = self.verse_form.get_all_verses + verse_list = self.verse_form.get_all_verses() verse_list = str(verse_list.replace('\r\n', '\n')) self.verse_list_widget.clear() self.verse_list_widget.setRowCount(0) From 78e7cb58732da6ed9928b62419d12161f4285eeb Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Mon, 24 Mar 2014 14:32:28 +0100 Subject: [PATCH 14/51] Test for add_welcome_page --- tests/functional/openlp_core_lib/test_ui.py | 55 +++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 tests/functional/openlp_core_lib/test_ui.py diff --git a/tests/functional/openlp_core_lib/test_ui.py b/tests/functional/openlp_core_lib/test_ui.py new file mode 100644 index 000000000..747005bd8 --- /dev/null +++ b/tests/functional/openlp_core_lib/test_ui.py @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2014 Raoul Snyman # +# Portions copyright (c) 2008-2014 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 # +############################################################################### +""" +Package to test the openlp.core.lib.ui package. +""" +from PyQt4 import QtGui +from unittest import TestCase + +from openlp.core.lib.ui import * + + +class TestUi(TestCase): + """ + Test the functions in the ui module + """ + + def test_add_welcome_page(self): + """ + Test appending a welcome page to a wizard + """ + # GIVEN: A wizard + wizard = QtGui.QWizard() + + # WHEN: A welcome page has been added to the wizard + add_welcome_page(wizard, ':/wizards/wizard_firsttime.bmp') + + # THEN: The wizard should have one page with a pixmap. + self.assertEqual(1, len(wizard.pageIds()), 'The wizard should have one page.') + self.assertIsInstance(wizard.page(0).pixmap(QtGui.QWizard.WatermarkPixmap), QtGui.QPixmap) From 8ad47cb888c4700271db911d09ed2291fa60d38b Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Mon, 24 Mar 2014 17:49:50 +0100 Subject: [PATCH 15/51] Fixes for windows tests and for starting OpenLP on windows. --- .../presentations/lib/pptviewcontroller.py | 5 +- .../presentations/test_pptviewcontroller.py | 65 ++++++++++++++++++- tests/helpers/testmixin.py | 5 +- .../openlp_core_lib/test_pluginmanager.py | 4 ++ 4 files changed, 71 insertions(+), 8 deletions(-) diff --git a/openlp/plugins/presentations/lib/pptviewcontroller.py b/openlp/plugins/presentations/lib/pptviewcontroller.py index 46195478d..16008f7e9 100644 --- a/openlp/plugins/presentations/lib/pptviewcontroller.py +++ b/openlp/plugins/presentations/lib/pptviewcontroller.py @@ -34,6 +34,7 @@ if os.name == 'nt': from ctypes import cdll from ctypes.wintypes import RECT +from openlp.core.utils import AppLocation from openlp.core.lib import ScreenList from .presentationcontroller import PresentationController, PresentationDocument @@ -85,8 +86,8 @@ class PptviewController(PresentationController): if self.process: return log.debug('start PPTView') - dll_path = os.path.join( - self.plugin_manager.base_path, 'presentations', 'lib', 'pptviewlib', 'pptviewlib.dll') + dll_path = os.path.join(AppLocation.get_directory(AppLocation.AppDir), + 'presentations', 'lib', 'pptviewlib', 'pptviewlib.dll') self.process = cdll.LoadLibrary(dll_path) if log.isEnabledFor(logging.DEBUG): self.process.SetDebug(1) diff --git a/tests/functional/openlp_plugins/presentations/test_pptviewcontroller.py b/tests/functional/openlp_plugins/presentations/test_pptviewcontroller.py index 5f25c4d3a..1b43615f3 100644 --- a/tests/functional/openlp_plugins/presentations/test_pptviewcontroller.py +++ b/tests/functional/openlp_plugins/presentations/test_pptviewcontroller.py @@ -30,19 +30,78 @@ This module contains tests for the pptviewcontroller module of the Presentations plugin. """ import os +import shutil +if os.name == 'nt': + from ctypes import cdll + +from tempfile import mkdtemp from unittest import TestCase from tests.functional import MagicMock, patch +from tests.helpers.testmixin import TestMixin -from openlp.plugins.presentations.lib.pptviewcontroller import PptviewDocument +from openlp.plugins.presentations.lib.pptviewcontroller import PptviewDocument, PptviewController + +class TestPptviewController(TestCase, TestMixin): + """ + Test the PptviewController Class + """ #TODO: Items left to test # PptviewController -# __init__ -# check_availablecheck_installed # start_process(self) # kill + def setUp(self): + """ + Set up the patches and mocks need for all tests. + """ + self.get_application() + self.build_settings() + self.mock_plugin = MagicMock() + self.temp_folder = mkdtemp() + self.mock_plugin.settings_section = self.temp_folder + + def tearDown(self): + """ + Stop the patches + """ + self.destroy_settings() + shutil.rmtree(self.temp_folder) + + def constructor_test(self): + """ + Test the Constructor from the PptViewController + """ + # GIVEN: No presentation controller + controller = None + + # WHEN: The presentation controller object is created + controller = PptviewController(plugin=self.mock_plugin) + + # THEN: The name of the presentation controller should be correct + self.assertEqual('Powerpoint Viewer', controller.name, 'The name of the presentation controller should be correct') + + def check_available_test(self): + """ + Test check_available / check_installed + """ + # GIVEN: A mocked dll loader and a controller + with patch('ctypes.cdll.LoadLibrary') as mocked_load_library: + mocked_process = MagicMock() + mocked_process.CheckInstalled.return_value = True + mocked_load_library.return_value = mocked_process + controller = PptviewController(plugin=self.mock_plugin) + + # WHEN: check_available is called + available = controller.check_available() + + # THEN: On windows it should return True, on other platforms False + if os.name == 'nt': + self.assertTrue(available, 'check_available should return True on windows.') + else: + self.assertFalse(available, 'check_available should return False when not on windows.') + class TestPptviewDocument(TestCase): """ diff --git a/tests/helpers/testmixin.py b/tests/helpers/testmixin.py index bda6d7291..b4e8a5c59 100644 --- a/tests/helpers/testmixin.py +++ b/tests/helpers/testmixin.py @@ -53,13 +53,12 @@ class TestMixin(object): Build the settings Object and initialise it """ Settings.setDefaultFormat(Settings.IniFormat) - fd, self.ini_file = mkstemp('.ini') + self.fd, self.ini_file = mkstemp('.ini') Settings().set_filename(self.ini_file) def destroy_settings(self): """ Destroy the Settings Object """ - if hasattr(self, 'fd'): - os.close(self.fd) + os.close(self.fd) os.unlink(Settings().fileName()) diff --git a/tests/interfaces/openlp_core_lib/test_pluginmanager.py b/tests/interfaces/openlp_core_lib/test_pluginmanager.py index 2949a46fb..054aa6dc1 100644 --- a/tests/interfaces/openlp_core_lib/test_pluginmanager.py +++ b/tests/interfaces/openlp_core_lib/test_pluginmanager.py @@ -31,6 +31,7 @@ Package to test the openlp.core.lib.pluginmanager package. """ import sys import shutil +import gc from tempfile import mkdtemp from unittest import TestCase @@ -65,6 +66,9 @@ class TestPluginManager(TestCase, TestMixin): del self.main_window Settings().remove('advanced/data path') self.destroy_settings() + # On windows we need to manually garbage collect to close sqlalchemy files + # to avoid errors when temporary files are deleted. + gc.collect() shutil.rmtree(self.temp_dir) def find_plugins_test(self): From a4829c62ba1f408065ffb48b89239ab019e440b3 Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Wed, 26 Mar 2014 12:26:16 +0100 Subject: [PATCH 16/51] Add missing arguments for debug mode Fixes: https://launchpad.net/bugs/1296574 --- openlp/core/ui/slidecontroller.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index eb1f13fa6..7faf10ca2 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -471,7 +471,7 @@ class SlideController(DisplayController, RegistryProperties): category=self.category, triggers=self.live_escape) - def live_escape(self): + def live_escape(self, field=None): """ If you press ESC on the live screen it should close the display temporarily. """ @@ -1243,7 +1243,7 @@ class SlideController(DisplayController, RegistryProperties): if self.service_item: self.service_manager.add_service_item(self.service_item) - def on_go_live_click(self): + def on_go_live_click(self, field=None): """ triggered by clicking the Preview slide items """ @@ -1256,7 +1256,7 @@ class SlideController(DisplayController, RegistryProperties): self.on_media_close() self.on_go_live() - def on_go_live(self): + def on_go_live(self, field=None): """ If preview copy slide item to live controller from Preview Controller """ From bf32fe164a380cf18c3915976d57254f4a6f4cbe Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Wed, 26 Mar 2014 13:06:48 +0100 Subject: [PATCH 17/51] Test --- openlp/core/lib/ui.py | 6 +++-- tests/functional/openlp_core_lib/test_ui.py | 28 +++++++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index 6d9e9e8f8..3126d1a56 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -74,11 +74,13 @@ def create_button_box(dialog, name, standard_buttons, custom_buttons=None): :param name: A string which is set as object name. :param standard_buttons: A list of strings for the used buttons. It might contain: ``ok``, ``save``, ``cancel``, ``close``, and ``defaults``. - :param custom_buttons: A list of additional buttons. If a item is a instance of QtGui.QAbstractButton it is added - with QDialogButtonBox.ActionRole. Other wise the item has to be a tuple of a button and a ButtonRole. + :param custom_buttons: A list of additional buttons. If an item is an instance of QtGui.QAbstractButton it is added + with QDialogButtonBox.ActionRole. Otherwise the item has to be a tuple of a Button and a ButtonRole. """ if custom_buttons is None: custom_buttons = [] + if standard_buttons is None: + standard_buttons = [] buttons = QtGui.QDialogButtonBox.NoButton if 'ok' in standard_buttons: buttons |= QtGui.QDialogButtonBox.Ok diff --git a/tests/functional/openlp_core_lib/test_ui.py b/tests/functional/openlp_core_lib/test_ui.py index 747005bd8..babc94a81 100644 --- a/tests/functional/openlp_core_lib/test_ui.py +++ b/tests/functional/openlp_core_lib/test_ui.py @@ -53,3 +53,31 @@ class TestUi(TestCase): # THEN: The wizard should have one page with a pixmap. self.assertEqual(1, len(wizard.pageIds()), 'The wizard should have one page.') self.assertIsInstance(wizard.page(0).pixmap(QtGui.QWizard.WatermarkPixmap), QtGui.QPixmap) + + def test_create_button_box(self): + """ + Test creating a button box for a dialog + """ + # GIVEN: A dialog + dialog = QtGui.QDialog() + + # WHEN: We create the button box with five buttons + btnbox = create_button_box(dialog, 'my_btns', ['ok', 'save', 'cancel', 'close', 'defaults']) + + # THEN: We should get a QDialogButtonBox with five buttons + self.assertIsInstance(btnbox, QtGui.QDialogButtonBox) + self.assertEqual(5, len(btnbox.buttons())) + + # WHEN: We create the button box with a custom button + btnbox = create_button_box(dialog, 'my_btns', None, [QtGui.QPushButton('Custom')]) + # THEN: We should get a QDialogButtonBox with one button + self.assertIsInstance(btnbox, QtGui.QDialogButtonBox) + self.assertEqual(1, len(btnbox.buttons())) + + # WHEN: We create the button box with a custom button and a custom role + btnbox = create_button_box(dialog, 'my_btns', None, + [(QtGui.QPushButton('Help'), QtGui.QDialogButtonBox.HelpRole)]) + # THEN: We should get a QDialogButtonBox with one button with a certain role + self.assertIsInstance(btnbox, QtGui.QDialogButtonBox) + self.assertEqual(1, len(btnbox.buttons())) + self.assertEqual(QtGui.QDialogButtonBox.HelpRole, btnbox.buttonRole(btnbox.buttons()[0])) From b4bf94a4f073b281f8626cadb23a5d8afe7bde1a Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Fri, 28 Mar 2014 21:41:27 +0100 Subject: [PATCH 18/51] pep8 --- tests/interfaces/openlp_core_lib/test_searchedit.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/interfaces/openlp_core_lib/test_searchedit.py b/tests/interfaces/openlp_core_lib/test_searchedit.py index 07db05dd7..98c942885 100644 --- a/tests/interfaces/openlp_core_lib/test_searchedit.py +++ b/tests/interfaces/openlp_core_lib/test_searchedit.py @@ -72,7 +72,6 @@ class TestSearchEdit(TestCase, TestMixin): """ del self.main_window - def set_search_types_test(self): """ Test setting the search types of the search edit. From e4c3f08a2a82a70eb9b4bb0e20f2308b63d102eb Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Sat, 29 Mar 2014 15:31:28 +0200 Subject: [PATCH 19/51] Fix some of the tests which were failing in Python 3.4 --- openlp/plugins/songs/lib/easyslidesimport.py | 2 +- openlp/plugins/songs/lib/ewimport.py | 2 +- openlp/plugins/songs/lib/songbeamerimport.py | 2 +- .../plugins/songs/lib/songshowplusimport.py | 2 +- .../openlp_plugins/songs/test_ewimport.py | 22 +++++++++---------- .../songs/test_songbeamerimport.py | 8 +++---- .../songs/test_songshowplusimport.py | 10 ++++----- tests/helpers/songfileimport.py | 2 +- 8 files changed, 25 insertions(+), 25 deletions(-) diff --git a/openlp/plugins/songs/lib/easyslidesimport.py b/openlp/plugins/songs/lib/easyslidesimport.py index 628d64880..e28e7bf97 100644 --- a/openlp/plugins/songs/lib/easyslidesimport.py +++ b/openlp/plugins/songs/lib/easyslidesimport.py @@ -49,7 +49,7 @@ class EasySlidesImport(SongImport): """ Initialise the class. """ - SongImport.__init__(self, manager, **kwargs) + super(EasySlidesImport, self).__init__(manager, **kwargs) def do_import(self): log.info('Importing EasySlides XML file %s', self.import_source) diff --git a/openlp/plugins/songs/lib/ewimport.py b/openlp/plugins/songs/lib/ewimport.py index 9e3ae566e..cde0b1692 100644 --- a/openlp/plugins/songs/lib/ewimport.py +++ b/openlp/plugins/songs/lib/ewimport.py @@ -73,7 +73,7 @@ class EasyWorshipSongImport(SongImport): ability to import EasyWorship song files. """ def __init__(self, manager, **kwargs): - SongImport.__init__(self, manager, **kwargs) + super(EasyWorshipSongImport, self).__init__(manager, **kwargs) def do_import(self): """ diff --git a/openlp/plugins/songs/lib/songbeamerimport.py b/openlp/plugins/songs/lib/songbeamerimport.py index 4de763554..0106ca687 100644 --- a/openlp/plugins/songs/lib/songbeamerimport.py +++ b/openlp/plugins/songs/lib/songbeamerimport.py @@ -97,7 +97,7 @@ class SongBeamerImport(SongImport): """ Initialise the Song Beamer importer. """ - SongImport.__init__(self, manager, **kwargs) + super(SongBeamerImport, self).__init__(manager, **kwargs) def do_import(self): """ diff --git a/openlp/plugins/songs/lib/songshowplusimport.py b/openlp/plugins/songs/lib/songshowplusimport.py index 485a8f047..0a8dc4650 100644 --- a/openlp/plugins/songs/lib/songshowplusimport.py +++ b/openlp/plugins/songs/lib/songshowplusimport.py @@ -92,7 +92,7 @@ class SongShowPlusImport(SongImport): """ Initialise the SongShow Plus importer. """ - SongImport.__init__(self, manager, **kwargs) + super(SongShowPlusImport, self).__init__(manager, **kwargs) def do_import(self): """ diff --git a/tests/functional/openlp_plugins/songs/test_ewimport.py b/tests/functional/openlp_plugins/songs/test_ewimport.py index a22519bec..f98ba57d2 100644 --- a/tests/functional/openlp_plugins/songs/test_ewimport.py +++ b/tests/functional/openlp_plugins/songs/test_ewimport.py @@ -77,7 +77,7 @@ class EasyWorshipSongImportLogger(EasyWorshipSongImport): _title_assignment_list = [] def __init__(self, manager): - EasyWorshipSongImport.__init__(self, manager) + EasyWorshipSongImport.__init__(self, manager, filenames=[]) @property def title(self): @@ -147,7 +147,7 @@ class TestEasyWorshipSongImport(TestCase): mocked_manager = MagicMock() # WHEN: An importer object is created - importer = EasyWorshipSongImport(mocked_manager) + importer = EasyWorshipSongImport(mocked_manager, filenames=[]) # THEN: The importer object should not be None self.assertIsNotNone(importer, 'Import should not be none') @@ -159,7 +159,7 @@ class TestEasyWorshipSongImport(TestCase): # GIVEN: A mocked out SongImport class, a mocked out "manager" and a list of field descriptions. with patch('openlp.plugins.songs.lib.ewimport.SongImport'): mocked_manager = MagicMock() - importer = EasyWorshipSongImport(mocked_manager) + importer = EasyWorshipSongImport(mocked_manager, filenames=[]) importer.field_descriptions = TEST_FIELD_DESCS # WHEN: Called with a field name that exists @@ -177,7 +177,7 @@ class TestEasyWorshipSongImport(TestCase): # GIVEN: A mocked out SongImport class, a mocked out "manager" and a list of field descriptions with patch('openlp.plugins.songs.lib.ewimport.SongImport'): mocked_manager = MagicMock() - importer = EasyWorshipSongImport(mocked_manager) + importer = EasyWorshipSongImport(mocked_manager, filenames=[]) importer.field_descriptions = TEST_FIELD_DESCS # WHEN: Called with a field name that does not exist @@ -196,7 +196,7 @@ class TestEasyWorshipSongImport(TestCase): with patch('openlp.plugins.songs.lib.ewimport.SongImport'), \ patch('openlp.plugins.songs.lib.ewimport.struct') as mocked_struct: mocked_manager = MagicMock() - importer = EasyWorshipSongImport(mocked_manager) + importer = EasyWorshipSongImport(mocked_manager, filenames=[]) # WHEN: set_record_struct is called with a list of field descriptions return_value = importer.set_record_struct(TEST_FIELD_DESCS) @@ -213,7 +213,7 @@ class TestEasyWorshipSongImport(TestCase): # GIVEN: A mocked out SongImport class, a mocked out "manager", an encoding and some test data and known results with patch('openlp.plugins.songs.lib.ewimport.SongImport'): mocked_manager = MagicMock() - importer = EasyWorshipSongImport(mocked_manager) + importer = EasyWorshipSongImport(mocked_manager, filenames=[]) importer.encoding = TEST_DATA_ENCODING importer.fields = TEST_FIELDS importer.field_descriptions = TEST_FIELD_DESCS @@ -236,7 +236,7 @@ class TestEasyWorshipSongImport(TestCase): with patch('openlp.plugins.songs.lib.ewimport.SongImport'): mocked_manager = MagicMock() mocked_memo_file = MagicMock() - importer = EasyWorshipSongImport(mocked_manager) + importer = EasyWorshipSongImport(mocked_manager, filenames=[]) importer.memo_file = mocked_memo_file importer.encoding = TEST_DATA_ENCODING @@ -267,7 +267,7 @@ class TestEasyWorshipSongImport(TestCase): with patch('openlp.plugins.songs.lib.ewimport.SongImport'), \ patch('openlp.plugins.songs.lib.ewimport.os.path') as mocked_os_path: mocked_manager = MagicMock() - importer = EasyWorshipSongImport(mocked_manager) + importer = EasyWorshipSongImport(mocked_manager, filenames=[]) mocked_os_path.isfile.side_effect = [True, False] # WHEN: Supplied with an import source @@ -286,7 +286,7 @@ class TestEasyWorshipSongImport(TestCase): with patch('openlp.plugins.songs.lib.ewimport.SongImport'), \ patch('openlp.plugins.songs.lib.ewimport.os.path') as mocked_os_path: mocked_manager = MagicMock() - importer = EasyWorshipSongImport(mocked_manager) + importer = EasyWorshipSongImport(mocked_manager, filenames=[]) mocked_os_path.isfile.return_value = True importer.import_source = 'Songs.DB' @@ -307,7 +307,7 @@ class TestEasyWorshipSongImport(TestCase): patch('builtins.open') as mocked_open, \ patch('openlp.plugins.songs.lib.ewimport.struct') as mocked_struct: mocked_manager = MagicMock() - importer = EasyWorshipSongImport(mocked_manager) + importer = EasyWorshipSongImport(mocked_manager, filenames=[]) mocked_os_path.isfile.return_value = True mocked_os_path.getsize.return_value = 0x800 importer.import_source = 'Songs.DB' @@ -334,7 +334,7 @@ class TestEasyWorshipSongImport(TestCase): patch('builtins.open'), patch('openlp.plugins.songs.lib.ewimport.struct') as mocked_struct, \ patch('openlp.plugins.songs.lib.ewimport.retrieve_windows_encoding') as mocked_retrieve_windows_encoding: mocked_manager = MagicMock() - importer = EasyWorshipSongImport(mocked_manager) + importer = EasyWorshipSongImport(mocked_manager, filenames=[]) mocked_os_path.isfile.return_value = True mocked_os_path.getsize.return_value = 0x800 importer.import_source = 'Songs.DB' diff --git a/tests/functional/openlp_plugins/songs/test_songbeamerimport.py b/tests/functional/openlp_plugins/songs/test_songbeamerimport.py index 72901eb47..a968975b3 100644 --- a/tests/functional/openlp_plugins/songs/test_songbeamerimport.py +++ b/tests/functional/openlp_plugins/songs/test_songbeamerimport.py @@ -66,7 +66,7 @@ class TestSongBeamerImport(TestCase): mocked_manager = MagicMock() # WHEN: An importer object is created - importer = SongBeamerImport(mocked_manager) + importer = SongBeamerImport(mocked_manager, filenames=[]) # THEN: The importer object should not be None self.assertIsNotNone(importer, 'Import should not be none') @@ -79,7 +79,7 @@ class TestSongBeamerImport(TestCase): with patch('openlp.plugins.songs.lib.songbeamerimport.SongImport'): mocked_manager = MagicMock() mocked_import_wizard = MagicMock() - importer = SongBeamerImport(mocked_manager) + importer = SongBeamerImport(mocked_manager, filenames=[]) importer.import_wizard = mocked_import_wizard importer.stop_import_flag = True @@ -100,7 +100,7 @@ class TestSongBeamerImport(TestCase): with patch('openlp.plugins.songs.lib.songbeamerimport.SongImport'): mocked_manager = MagicMock() mocked_import_wizard = MagicMock() - importer = SongBeamerImport(mocked_manager) + importer = SongBeamerImport(mocked_manager, filenames=[]) importer.import_wizard = mocked_import_wizard importer.stop_import_flag = True @@ -127,7 +127,7 @@ class TestSongBeamerImport(TestCase): mocked_add_verse = MagicMock() mocked_finish = MagicMock() mocked_finish.return_value = True - importer = SongBeamerImport(mocked_manager) + importer = SongBeamerImport(mocked_manager, filenames=[]) importer.import_wizard = mocked_import_wizard importer.stop_import_flag = False importer.add_verse = mocked_add_verse diff --git a/tests/functional/openlp_plugins/songs/test_songshowplusimport.py b/tests/functional/openlp_plugins/songs/test_songshowplusimport.py index 5c945efb3..16af347b2 100644 --- a/tests/functional/openlp_plugins/songs/test_songshowplusimport.py +++ b/tests/functional/openlp_plugins/songs/test_songshowplusimport.py @@ -72,7 +72,7 @@ class TestSongShowPlusImport(TestCase): mocked_manager = MagicMock() # WHEN: An importer object is created - importer = SongShowPlusImport(mocked_manager) + importer = SongShowPlusImport(mocked_manager, filenames=[]) # THEN: The importer object should not be None self.assertIsNotNone(importer, 'Import should not be none') @@ -85,7 +85,7 @@ class TestSongShowPlusImport(TestCase): with patch('openlp.plugins.songs.lib.songshowplusimport.SongImport'): mocked_manager = MagicMock() mocked_import_wizard = MagicMock() - importer = SongShowPlusImport(mocked_manager) + importer = SongShowPlusImport(mocked_manager, filenames=[]) importer.import_wizard = mocked_import_wizard importer.stop_import_flag = True @@ -106,7 +106,7 @@ class TestSongShowPlusImport(TestCase): with patch('openlp.plugins.songs.lib.songshowplusimport.SongImport'): mocked_manager = MagicMock() mocked_import_wizard = MagicMock() - importer = SongShowPlusImport(mocked_manager) + importer = SongShowPlusImport(mocked_manager, filenames=[]) importer.import_wizard = mocked_import_wizard importer.stop_import_flag = True @@ -126,7 +126,7 @@ class TestSongShowPlusImport(TestCase): # GIVEN: A mocked out SongImport class, and a mocked out "manager" with patch('openlp.plugins.songs.lib.songshowplusimport.SongImport'): mocked_manager = MagicMock() - importer = SongShowPlusImport(mocked_manager) + importer = SongShowPlusImport(mocked_manager, filenames=[]) # WHEN: Supplied with the following arguments replicating verses being added test_values = [('Verse 1', VerseType.tags[VerseType.Verse] + '1'), @@ -153,7 +153,7 @@ class TestSongShowPlusImport(TestCase): # GIVEN: A mocked out SongImport class, and a mocked out "manager" with patch('openlp.plugins.songs.lib.songshowplusimport.SongImport'): mocked_manager = MagicMock() - importer = SongShowPlusImport(mocked_manager) + importer = SongShowPlusImport(mocked_manager, filenames=[]) # WHEN: Supplied with the following arguments replicating a verse order being added test_values = [('Verse 1', VerseType.tags[VerseType.Verse] + '1'), diff --git a/tests/helpers/songfileimport.py b/tests/helpers/songfileimport.py index 2ffecb11a..12754f55a 100644 --- a/tests/helpers/songfileimport.py +++ b/tests/helpers/songfileimport.py @@ -89,7 +89,7 @@ class SongImportTestHelper(TestCase): """ Import the given file and check that it has imported correctly """ - importer = self.importer_class(self.mocked_manager) + importer = self.importer_class(self.mocked_manager, filenames=[source_file_name]) importer.import_wizard = self.mocked_import_wizard importer.stop_import_flag = False importer.topics = [] From 0f0e09a2825cf743a10f40d03415dccd41b36412 Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Sat, 29 Mar 2014 20:56:20 +0100 Subject: [PATCH 20/51] Fixed wrong dll load path. --- openlp/plugins/presentations/lib/pptviewcontroller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/presentations/lib/pptviewcontroller.py b/openlp/plugins/presentations/lib/pptviewcontroller.py index 16008f7e9..a9090dd1e 100644 --- a/openlp/plugins/presentations/lib/pptviewcontroller.py +++ b/openlp/plugins/presentations/lib/pptviewcontroller.py @@ -87,7 +87,7 @@ class PptviewController(PresentationController): return log.debug('start PPTView') dll_path = os.path.join(AppLocation.get_directory(AppLocation.AppDir), - 'presentations', 'lib', 'pptviewlib', 'pptviewlib.dll') + 'plugins', 'presentations', 'lib', 'pptviewlib', 'pptviewlib.dll') self.process = cdll.LoadLibrary(dll_path) if log.isEnabledFor(logging.DEBUG): self.process.SetDebug(1) From 80284f6f8d7f6e69b9e80fa6cc4c63380a1682d9 Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Mon, 31 Mar 2014 10:08:07 +0200 Subject: [PATCH 21/51] =?UTF-8?q?Added=20'Neue=20evangelistische=20=C3=9Cb?= =?UTF-8?q?ersetzung'=20to=20the=20list=20of=20Online=20bible=20translatio?= =?UTF-8?q?ns?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bibles/resources/bibles_resources.sqlite | Bin 104448 -> 104448 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/openlp/plugins/bibles/resources/bibles_resources.sqlite b/openlp/plugins/bibles/resources/bibles_resources.sqlite index c0fa931d1bb88b6e6c0224feff9cbc5aa61c7312..8f1777124032ee11b547fd6e1897f7e9b8b717a9 100644 GIT binary patch delta 140 zcmZqJz}B#VZGtr8lZi6UtWOwppD}GrvEyc2pv27V$vF9Sk=*8E+;$J-cp0@sn0GQy zV$NjtVEV;$nrRkOJQF+PE5_Z7HH=yt8#x#a{Tmh785(&d85#W;QW;8tSOJL37!n!s n7}9~P9EMDWVulhhnaq&EkUIIpOKG-LhC2)z%$sZ8wyXjGKRhSf delta 78 zcmV-U0I~moum*sz29O&8*oM;vcbOJ_`n)A_D_S0h8-;9<#;^KHwY-0eln# kxdV~|X#+?C`U1-WngU+}2Lb8 Date: Mon, 31 Mar 2014 14:13:50 +0200 Subject: [PATCH 22/51] cleanup: remove local variable --- openlp/core/lib/searchedit.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/openlp/core/lib/searchedit.py b/openlp/core/lib/searchedit.py index 13e388775..de329236c 100644 --- a/openlp/core/lib/searchedit.py +++ b/openlp/core/lib/searchedit.py @@ -181,5 +181,4 @@ class SearchEdit(QtGui.QLineEdit): for action in self.menu_button.menu().actions(): # Why is this needed? action.setChecked(False) - sender = self.sender() - self.set_current_search_type(sender.data()) + self.set_current_search_type(self.sender().data()) From 5a02ab9471498575b48dfba981965f1d1fa7445a Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 31 Mar 2014 16:07:05 +0200 Subject: [PATCH 23/51] test: splash screen test --- .../openlp_core_ui/test_splashscreen.py | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 tests/interfaces/openlp_core_ui/test_splashscreen.py diff --git a/tests/interfaces/openlp_core_ui/test_splashscreen.py b/tests/interfaces/openlp_core_ui/test_splashscreen.py new file mode 100644 index 000000000..35c15f9ec --- /dev/null +++ b/tests/interfaces/openlp_core_ui/test_splashscreen.py @@ -0,0 +1,60 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2014 Raoul Snyman # +# Portions copyright (c) 2008-2014 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 # +############################################################################### +""" +Test the openlp.core.ui.splashscreen class. +""" +from unittest import TestCase + +from PyQt4 import QtGui + +from openlp.core.ui import SplashScreen +from tests.helpers.testmixin import TestMixin + + +class TestSplashScreen(TestCase, TestMixin): + def setUp(self): + self.get_application() + self.main_window = QtGui.QMainWindow() + + def tearDown(self): + """ + Delete all the C++ objects at the end so that we don't have a segfault + """ + del self.app + del self.main_window + + def setupUi_test(self): + """ + Test if the setupUi method.... + """ + # GIVEN: A splash screen instance. + splash = SplashScreen() + + # THEN: Check if the splash has a setupUi method. + assert hasattr(splash, 'setupUi'), 'The Splash Screen should have a setupUi() method.' From 13c053bc5cb438ef933f4fa2352c6d764857e3f0 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 31 Mar 2014 18:08:42 +0200 Subject: [PATCH 24/51] added jenkins script --- tests/utils/jenkins-script.py | 188 ++++++++++++++++++++++++++++++++++ 1 file changed, 188 insertions(+) create mode 100644 tests/utils/jenkins-script.py diff --git a/tests/utils/jenkins-script.py b/tests/utils/jenkins-script.py new file mode 100644 index 000000000..3a6f34a13 --- /dev/null +++ b/tests/utils/jenkins-script.py @@ -0,0 +1,188 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2014 Raoul Snyman # +# Portions copyright (c) 2008-2014 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 # +############################################################################### +""" +This script helps to trigger builds of branches. To use it you have to install the jenkins-webapi package: + + pip3 isntall jenkins-webapi + +You probably want to create an alias. Add this to your ~/.bashrc file and then logout and login: + + alias ci="python PATH-TO-THIS-SCRIPT TOKEN" + +If you do not know/have the token, then please ask for it (e. g. IRC). +""" + +from optparse import OptionParser +from subprocess import Popen, PIPE +import sys +import time + +from jenkins import Jenkins +from PyQt4 import QtCore, QtGui + + +JENKINS_URL = 'http://ci.openlp.org/' + + +class OpenLPJobs(object): + """ + This class holds any jobs we have on jenkins and we actually need in this script. + """ + Branch_Pull = 'Branch-01-Pull' + Branch_Functional = 'Branch-02-Functional-Tests' + Branch_Interface = 'Branch-03-Interface-Tests' + Branch_Windows = 'Branch-04-Windows_Tests' + + Jobs = [Branch_Pull, Branch_Functional, Branch_Interface, Branch_Windows] + + +class JenkinsTrigger(object): + def __init__(self, token): + """ + Create the JenkinsTrigger instance. + + :param token: The token we need to trigger the build. If you do not have this token, ask in IRC. + """ + self.token = token + self.repo_name = get_repo_name() + self.jenkins_instance = Jenkins(JENKINS_URL) + + def trigger_build(self): + """ + Ask our jenkins server to build the "Branch-01-Pull" job. + """ + self.jenkins_instance.job(OpenLPJobs.Branch_Pull).build({'BRANCH_NAME': self.repo_name}, token=self.token) + + def print_output(self): + """ + Print the status information of the build tirggered. + """ + print("Add this to your merge proposal:") + print("--------------------------------") + for job in OpenLPJobs.Jobs: + self.__print_build_info(job) + + def open_browser(self): + """ + Opens the browser. + """ + url = self.jenkins_instance.job(OpenLPJobs.Branch_Pull).info['url'] + # Open the url + Popen(('xdg-open', url), stderr=PIPE) + + def __print_build_info(self, job_name): + """ + This helper method prints the job information of the given ``job_name`` + + :param job_name: The name of the job we want the information from. For example *Branch-01-Pull*. Use the class + variables from the :class:`OpenLPJobs` class. + """ + job = self.jenkins_instance.job(job_name) + while job.info['inQueue']: + # Give other processes the possibility to take over. Like Thread.yield(). + time.sleep(0) + build = job.last_build + build.wait() + result_string = build.info['result'] + url = build.info['url'] + print('[%s] %s' % (result_string, url)) + # On failure open the browser. + if result_string == "FAILURE": + url += 'console' + Popen(('xdg-open', url), stderr=PIPE) + + +def get_repo_name(): + """ + This returns the name of branch of the wokring directory. For example it returns *lp:~googol/openlp/render*. + """ + # Run the bzr command. + bzr = Popen(('bzr', 'info'), stdout=PIPE, stderr=PIPE) + raw_output, error = bzr.communicate() + # Detect any errors + if error: + print('This is not a branch.') + return + # Clean the output. + raw_output = raw_output.decode() + output_list = list(map(str.strip, raw_output.split('\n'))) + # Determine the branch's name + repo_name = '' + for line in output_list: + # Check if it is remote branch. + if 'push branch' in line: + repo_name = line.replace('push branch: bzr+ssh://bazaar.launchpad.net/', 'lp:') + break + # Check if trunk. Note, bzr info can return both 'push branch' as well as 'checkout of branch'. The later can + # occur before the first. So we do not want to break here to make sure we find any orrucances of + elif 'checkout of branch' in line: + repo_name = line.replace('checkout of branch: bzr+ssh://bazaar.launchpad.net/+branch/', 'lp:') + repo_name = repo_name.strip('/') + + # Did we find the branch name? + if not repo_name: + for line in output_list: + # Check if the branch was pushed. + if 'Shared repository with trees (format: 2a)' in line: + print('Not a branch. cd to a branch.') + return + print('Not a branch. Have you pushed it to launchpad?') + return + return repo_name + + +def main(): + usage = 'Usage: python %prog TOKEN [options]' + + parser = OptionParser(usage=usage) + parser.add_option('-d', '--disable-output', dest='enable_output', action="store_false", default=True, + help='Print output for the merge request.') + parser.add_option('-b', '--open-browser', dest='open_browser', action="store_true", default=False, + help='Opens the jenkins page in your browser.') + #parser.add_option('-e', '--open-browser-on-error', dest='open_browser_on_error', action="store_true", default=False, + # help='Opens the jenkins page in your browser in case a test fails.') + options, args = parser.parse_args(sys.argv) + + if len(args) == 2: + if not get_repo_name(): + return + token = args[-1] + jenkins_trigger = JenkinsTrigger(token) + jenkins_trigger.trigger_build() + # Open the browser before printing the output. + if options.open_browser: + jenkins_trigger.open_browser() + if options.enable_output: + jenkins_trigger.print_output() + else: + raise Exception() + +if __name__ == '__main__': + main() From 5f0b40fe3017a41222f85056d6be65d8c2c07b5a Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 31 Mar 2014 18:27:26 +0200 Subject: [PATCH 25/51] Moved script --- tests/utils/jenkins-script.py => scripts/jenkins_script.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/utils/jenkins-script.py => scripts/jenkins_script.py (100%) diff --git a/tests/utils/jenkins-script.py b/scripts/jenkins_script.py similarity index 100% rename from tests/utils/jenkins-script.py rename to scripts/jenkins_script.py From 4bed39869a7846720cf60d564f44585e8d9ca6e0 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 31 Mar 2014 18:30:07 +0200 Subject: [PATCH 26/51] updated check_dependencies.py sciprt --- scripts/check_dependencies.py | 1 + scripts/jenkins_script.py | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/check_dependencies.py b/scripts/check_dependencies.py index adb6a47f2..bab1c6419 100755 --- a/scripts/check_dependencies.py +++ b/scripts/check_dependencies.py @@ -94,6 +94,7 @@ OPTIONAL_MODULES = [ ('psycopg2', '(PostgreSQL support)', True), ('nose', '(testing framework)', True), ('mock', '(testing module)', sys.version_info[1] < 3), + ('jenkins', '(access jenkins api - package name: enkins-webapi)', True), ] w = sys.stdout.write diff --git a/scripts/jenkins_script.py b/scripts/jenkins_script.py index 3a6f34a13..eefe74150 100644 --- a/scripts/jenkins_script.py +++ b/scripts/jenkins_script.py @@ -45,7 +45,6 @@ import sys import time from jenkins import Jenkins -from PyQt4 import QtCore, QtGui JENKINS_URL = 'http://ci.openlp.org/' From 716a79bcc576547512982d7dc24cd5e5dc9fd894 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 31 Mar 2014 18:37:43 +0200 Subject: [PATCH 27/51] cleaned doc --- scripts/jenkins_script.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/scripts/jenkins_script.py b/scripts/jenkins_script.py index eefe74150..d275463c3 100644 --- a/scripts/jenkins_script.py +++ b/scripts/jenkins_script.py @@ -40,6 +40,7 @@ If you do not know/have the token, then please ask for it (e. g. IRC). """ from optparse import OptionParser +from requests.exceptions import HTTPError from subprocess import Popen, PIPE import sys import time @@ -58,8 +59,9 @@ class OpenLPJobs(object): Branch_Functional = 'Branch-02-Functional-Tests' Branch_Interface = 'Branch-03-Interface-Tests' Branch_Windows = 'Branch-04-Windows_Tests' + Branch_PEP = 'Branch-05-Code-Analysis' - Jobs = [Branch_Pull, Branch_Functional, Branch_Interface, Branch_Windows] + Jobs = [Branch_Pull, Branch_Functional, Branch_Interface, Branch_Windows, Branch_PEP] class JenkinsTrigger(object): @@ -113,9 +115,9 @@ class JenkinsTrigger(object): url = build.info['url'] print('[%s] %s' % (result_string, url)) # On failure open the browser. - if result_string == "FAILURE": - url += 'console' - Popen(('xdg-open', url), stderr=PIPE) + #if result_string == "FAILURE": + # url += 'console' + # Popen(('xdg-open', url), stderr=PIPE) def get_repo_name(): @@ -162,7 +164,7 @@ def main(): parser = OptionParser(usage=usage) parser.add_option('-d', '--disable-output', dest='enable_output', action="store_false", default=True, - help='Print output for the merge request.') + help='Disable output.') parser.add_option('-b', '--open-browser', dest='open_browser', action="store_true", default=False, help='Opens the jenkins page in your browser.') #parser.add_option('-e', '--open-browser-on-error', dest='open_browser_on_error', action="store_true", default=False, @@ -174,14 +176,18 @@ def main(): return token = args[-1] jenkins_trigger = JenkinsTrigger(token) - jenkins_trigger.trigger_build() + try: + jenkins_trigger.trigger_build() + except HTTPError as e: + print("Wrong token.") + return # Open the browser before printing the output. if options.open_browser: jenkins_trigger.open_browser() if options.enable_output: jenkins_trigger.print_output() else: - raise Exception() + parser.print_help() if __name__ == '__main__': main() From 6204454bfbe70fffbe51eb531ebc60c48c09554c Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 31 Mar 2014 18:40:36 +0200 Subject: [PATCH 28/51] updated doc --- scripts/jenkins_script.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/jenkins_script.py b/scripts/jenkins_script.py index d275463c3..1a655799b 100644 --- a/scripts/jenkins_script.py +++ b/scripts/jenkins_script.py @@ -32,11 +32,11 @@ This script helps to trigger builds of branches. To use it you have to install t pip3 isntall jenkins-webapi -You probably want to create an alias. Add this to your ~/.bashrc file and then logout and login: +You probably want to create an alias. Add this to your ~/.bashrc file and then logout and login (to apply the alias): - alias ci="python PATH-TO-THIS-SCRIPT TOKEN" + alias ci="python3 ~/Projects/OpenLP/trunk/script/jenkins_script.py TOKEN" -If you do not know/have the token, then please ask for it (e. g. IRC). +You can look up the token in the Branch-01-Pull job configuration or ask in IRC. """ from optparse import OptionParser From c451a8eafa71d7c3ed67b393551f7e20159188f8 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 31 Mar 2014 19:01:09 +0200 Subject: [PATCH 29/51] added test --- openlp/core/common/registry.py | 1 + scripts/jenkins_script.py | 2 +- .../functional/openlp_core_common/test_registry.py | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/openlp/core/common/registry.py b/openlp/core/common/registry.py index 014a534f7..33eb64880 100644 --- a/openlp/core/common/registry.py +++ b/openlp/core/common/registry.py @@ -151,6 +151,7 @@ class Registry(object): if result: results.append(result) except TypeError: + print("sdf") # Who has called me can help in debugging trace_error_handler(log) log.exception('Exception for function %s', function) diff --git a/scripts/jenkins_script.py b/scripts/jenkins_script.py index 1a655799b..0e29271a2 100644 --- a/scripts/jenkins_script.py +++ b/scripts/jenkins_script.py @@ -30,7 +30,7 @@ """ This script helps to trigger builds of branches. To use it you have to install the jenkins-webapi package: - pip3 isntall jenkins-webapi + pip3 install jenkins-webapi You probably want to create an alias. Add this to your ~/.bashrc file and then logout and login (to apply the alias): diff --git a/tests/functional/openlp_core_common/test_registry.py b/tests/functional/openlp_core_common/test_registry.py index a57d7ea85..e27b69d10 100644 --- a/tests/functional/openlp_core_common/test_registry.py +++ b/tests/functional/openlp_core_common/test_registry.py @@ -100,6 +100,20 @@ class TestRegistry(TestCase): # THEN: I expect then function to have been called and a return given self.assertEqual(return_value[0], 'function_2', 'A return value is provided and matches') + def remove_function_test(self): + """ + Test the remove_function() method + """ + # GIVEN: An existing registry register a function + Registry.create() + Registry().register_function('test1', self.dummy_function_1) + + # WHEN: Remove the function. + Registry().remove_function('test1', self.dummy_function_1) + + # THEN: The method should not be available. + assert not Registry().functions_list['test1'], 'The function should not be in the dict anymore.' + def dummy_function_1(self): return "function_1" From 52279248462f191b9aeb0f103c39c0803db2b25c Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 31 Mar 2014 19:29:14 +0200 Subject: [PATCH 30/51] fix: removed stray print --- openlp/core/common/registry.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openlp/core/common/registry.py b/openlp/core/common/registry.py index 33eb64880..014a534f7 100644 --- a/openlp/core/common/registry.py +++ b/openlp/core/common/registry.py @@ -151,7 +151,6 @@ class Registry(object): if result: results.append(result) except TypeError: - print("sdf") # Who has called me can help in debugging trace_error_handler(log) log.exception('Exception for function %s', function) From 20e7517b033c82f8b9ebcee157fd86e9cf969737 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 31 Mar 2014 19:30:14 +0200 Subject: [PATCH 31/51] doc: shortened path --- scripts/jenkins_script.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/jenkins_script.py b/scripts/jenkins_script.py index 0e29271a2..cd75bbc6e 100644 --- a/scripts/jenkins_script.py +++ b/scripts/jenkins_script.py @@ -34,7 +34,7 @@ This script helps to trigger builds of branches. To use it you have to install t You probably want to create an alias. Add this to your ~/.bashrc file and then logout and login (to apply the alias): - alias ci="python3 ~/Projects/OpenLP/trunk/script/jenkins_script.py TOKEN" + alias ci="python3 ./scripts/jenkins_script.py TOKEN" You can look up the token in the Branch-01-Pull job configuration or ask in IRC. """ From 3db984a846290345b589b294a18d9dfc13cee05e Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 31 Mar 2014 19:32:49 +0200 Subject: [PATCH 32/51] clean up: simplify code --- openlp/core/common/registry.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/openlp/core/common/registry.py b/openlp/core/common/registry.py index 014a534f7..218325823 100644 --- a/openlp/core/common/registry.py +++ b/openlp/core/common/registry.py @@ -62,11 +62,9 @@ class Registry(object): registry = cls() registry.service_list = {} registry.functions_list = {} - registry.running_under_test = False - registry.initialising = True # Allow the tests to remove Registry entries but not the live system - if 'nose' in sys.argv[0]: - registry.running_under_test = True + registry.running_under_test = 'nose' in sys.argv[0] + registry.initialising = True return registry def get(self, key): @@ -128,7 +126,7 @@ class Registry(object): :param event: The function description.. :param function: The function to be called when the event happens. """ - if self.running_under_test is False: + if not self.running_under_test: trace_error_handler(log) log.error('Invalid Method call for key %s' % event) raise KeyError('Invalid Method call for key %s' % event) From 6235fa19a912e57e4a64c0b3841670bc91af77ca Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 31 Mar 2014 19:52:49 +0200 Subject: [PATCH 33/51] long line --- scripts/jenkins_script.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/jenkins_script.py b/scripts/jenkins_script.py index cd75bbc6e..75d4f6376 100644 --- a/scripts/jenkins_script.py +++ b/scripts/jenkins_script.py @@ -167,8 +167,8 @@ def main(): help='Disable output.') parser.add_option('-b', '--open-browser', dest='open_browser', action="store_true", default=False, help='Opens the jenkins page in your browser.') - #parser.add_option('-e', '--open-browser-on-error', dest='open_browser_on_error', action="store_true", default=False, - # help='Opens the jenkins page in your browser in case a test fails.') + #parser.add_option('-e', '--open-browser-on-error', dest='open_browser_on_error', action="store_true", + # default=False, help='Opens the jenkins page in your browser in case a test fails.') options, args = parser.parse_args(sys.argv) if len(args) == 2: From ab4cbfd85ee86295a3bf65508b27a98735fdab49 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 31 Mar 2014 19:57:15 +0200 Subject: [PATCH 34/51] fix: spelling mistake --- scripts/check_dependencies.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/check_dependencies.py b/scripts/check_dependencies.py index bab1c6419..5298139be 100755 --- a/scripts/check_dependencies.py +++ b/scripts/check_dependencies.py @@ -94,7 +94,7 @@ OPTIONAL_MODULES = [ ('psycopg2', '(PostgreSQL support)', True), ('nose', '(testing framework)', True), ('mock', '(testing module)', sys.version_info[1] < 3), - ('jenkins', '(access jenkins api - package name: enkins-webapi)', True), + ('jenkins', '(access jenkins api - package name: jenkins-webapi)', True), ] w = sys.stdout.write From 9d9a8145f64fc59ac98c3dc8637f4c04cb5ed4ce Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 31 Mar 2014 20:10:14 +0200 Subject: [PATCH 35/51] fixed dectection --- scripts/jenkins_script.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/scripts/jenkins_script.py b/scripts/jenkins_script.py index 75d4f6376..386ab69ef 100644 --- a/scripts/jenkins_script.py +++ b/scripts/jenkins_script.py @@ -141,10 +141,9 @@ def get_repo_name(): if 'push branch' in line: repo_name = line.replace('push branch: bzr+ssh://bazaar.launchpad.net/', 'lp:') break - # Check if trunk. Note, bzr info can return both 'push branch' as well as 'checkout of branch'. The later can - # occur before the first. So we do not want to break here to make sure we find any orrucances of elif 'checkout of branch' in line: - repo_name = line.replace('checkout of branch: bzr+ssh://bazaar.launchpad.net/+branch/', 'lp:') + repo_name = line.replace('checkout of branch: bzr+ssh://bazaar.launchpad.net/', 'lp:') + break repo_name = repo_name.strip('/') # Did we find the branch name? From 6ca37531a057e32870b6bf9dc0759d523a9f4312 Mon Sep 17 00:00:00 2001 From: Jonathan Springer Date: Tue, 1 Apr 2014 13:07:25 -0400 Subject: [PATCH 36/51] Remove unnecessary platform specific code, remove orphaned and unused registry execute, and fix two functions to register to the registry instead of executing. --- openlp/core/ui/mainwindow.py | 16 ++++++---------- openlp/core/ui/slidecontroller.py | 1 - openlp/plugins/bibles/forms/bibleupgradeform.py | 2 +- openlp/plugins/bibles/lib/db.py | 2 +- 4 files changed, 8 insertions(+), 13 deletions(-) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 703307e18..6c56bee37 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -322,14 +322,8 @@ class Ui_MainWindow(object): # i18n add Language Actions add_actions(self.settings_language_menu, (self.auto_language_item, None)) add_actions(self.settings_language_menu, self.language_group.actions()) - # Order things differently in OS X so that Preferences menu item in the - # app menu is correct (this gets picked up automatically by Qt). - if sys.platform == 'darwin': - add_actions(self.settings_menu, (self.settings_plugin_list_item, self.settings_language_menu.menuAction(), - None, self.settings_configure_item, self.settings_shortcuts_item, self.formatting_tag_item)) - else: - add_actions(self.settings_menu, (self.settings_plugin_list_item, self.settings_language_menu.menuAction(), - None, self.formatting_tag_item, self.settings_shortcuts_item, self.settings_configure_item)) + add_actions(self.settings_menu, (self.settings_plugin_list_item, self.settings_language_menu.menuAction(), + None, self.formatting_tag_item, self.settings_shortcuts_item, self.settings_configure_item)) add_actions(self.tools_menu, (self.tools_add_tool_item, None)) add_actions(self.tools_menu, (self.tools_open_data_folder, None)) add_actions(self.tools_menu, (self.tools_first_time_wizard, None)) @@ -393,8 +387,10 @@ class Ui_MainWindow(object): self.import_language_item.setText(translate('OpenLP.MainWindow', '&Language')) self.export_theme_item.setText(translate('OpenLP.MainWindow', '&Theme')) self.export_language_item.setText(translate('OpenLP.MainWindow', '&Language')) - self.settings_shortcuts_item.setText(translate('OpenLP.MainWindow', 'Configure &Shortcuts...')) - self.formatting_tag_item.setText(translate('OpenLP.MainWindow', 'Configure &Formatting Tags...')) + # Do not use config, options, setup, settings or preferences in menu item name unless it is OpenLP's preferences. + # Qt automatically detects the Preferences entry for the Mac OS X menu based on the name of the menu item. + self.settings_shortcuts_item.setText(translate('OpenLP.MainWindow', '&Shortcuts...')) + self.formatting_tag_item.setText(translate('OpenLP.MainWindow', '&Formatting Tags...')) self.settings_configure_item.setText(translate('OpenLP.MainWindow', '&Configure OpenLP...')) self.settings_export_item.setStatusTip(translate('OpenLP.MainWindow', 'Export OpenLP settings to a specified *.config file')) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 7faf10ca2..ed3ddaeda 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -1039,7 +1039,6 @@ class SlideController(DisplayController, RegistryProperties): """ self.preview_widget.change_slide(row) self.update_preview() - Registry().execute('slidecontroller_%s_changed' % self.type_prefix, row) def update_preview(self): """ diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index 9925b1ebc..d9936dfe6 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -78,7 +78,7 @@ class BibleUpgradeForm(OpenLPWizard): Set up the UI for the bible wizard. """ super(BibleUpgradeForm, self).setupUi(image) - Registry().execute('openlp_stop_wizard', self.stop_import) + Registry().register_function('openlp_stop_wizard', self.stop_import) def stop_import(self): """ diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index 743bb01c6..48c11fa5e 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -154,7 +154,7 @@ class BibleDB(QtCore.QObject, Manager, RegistryProperties): if 'path' in kwargs: self.path = kwargs['path'] self.wizard = None - Registry().execute('openlp_stop_wizard', self.stop_import) + Registry().register_function('openlp_stop_wizard', self.stop_import) def stop_import(self): """ From edd1ed849a8d2a5561a4adea9af7be36d659d9ee Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Tue, 1 Apr 2014 18:32:19 +0100 Subject: [PATCH 37/51] minor fixes --- openlp/core/common/__init__.py | 4 +++- openlp/plugins/bibles/lib/db.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/openlp/core/common/__init__.py b/openlp/core/common/__init__.py index 03bf964bc..8df86032e 100644 --- a/openlp/core/common/__init__.py +++ b/openlp/core/common/__init__.py @@ -51,8 +51,10 @@ def trace_error_handler(logger): :param logger: logger to use so traceback is logged to correct class """ + log_string = "OpenLP Error trace" for tb in traceback.extract_stack(): - logger.error('Called by ' + tb[3] + ' at line ' + str(tb[1]) + ' in ' + tb[0]) + log_string = ('%s\n File %s at line %d \n\t called %s' % (log_string, tb[0], tb[1], tb[3])) + logger.error(log_string) def check_directory_exists(directory, do_not_log=False): diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index 743bb01c6..9ffa5d53e 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -561,7 +561,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager): Return a book by name or abbreviation. :param name: The name or abbreviation of the book. - :param lower: True if the comparsion should be only lowercase + :param lower: True if the comparison should be only lowercase """ log.debug('BiblesResourcesDB.get_book("%s")', name) if not isinstance(name, str): From d26b34aee0837267c68df61c685cd8de9c9c3700 Mon Sep 17 00:00:00 2001 From: Jonathan Springer Date: Tue, 1 Apr 2014 14:58:22 -0400 Subject: [PATCH 38/51] Modify loading file from the command line to only load files ending with osz, oszl, or otz. --- openlp/core/ui/mainwindow.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 6c56bee37..b14694ccc 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -597,10 +597,12 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow, RegistryProperties): args = [] for a in self.arguments: args.extend([a]) - filename = args[0] - if not isinstance(filename, str): - filename = str(filename, sys.getfilesystemencoding()) - self.service_manager_contents.load_file(filename) + for arg in args: + filename = arg + if not isinstance(filename, str): + filename = str(filename, sys.getfilesystemencoding()) + if filename.endswith(('.osz', '.oszl', '.otz')): + self.service_manager_contents.load_file(filename) elif Settings().value(self.general_settings_section + '/auto open'): self.service_manager_contents.load_Last_file() self.timer_version_id = self.startTimer(1000) From c38c576f946de6f5b82c3d6568d61926606fa9b4 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 2 Apr 2014 19:51:21 +0100 Subject: [PATCH 39/51] test fixes --- openlp/plugins/remotes/lib/httpserver.py | 25 +++++-- resources/__init__.py | 1 - scripts/translation_utils.py | 74 ++++++++++--------- setup.py | 10 ++- .../openlp_core_common/test_applocation.py | 22 +++--- tests/functional/openlp_core_lib/__init__.py | 2 +- tests/functional/openlp_core_lib/test_db.py | 2 +- .../openlp_core_lib/test_file_dialog.py | 7 +- .../openlp_core_lib/test_formattingtags.py | 1 - .../openlp_core_lib/test_htmlbuilder.py | 1 - tests/functional/openlp_core_lib/test_lib.py | 4 +- .../openlp_core_lib/test_renderer.py | 2 +- .../functional/openlp_core_lib/test_theme.py | 1 - .../functional/openlp_core_utils/__init__.py | 2 +- .../openlp_plugins/bibles/__init__.py | 1 - .../openlp_plugins/bibles/test_http.py | 6 +- .../openlp_plugins/bibles/test_lib.py | 2 - .../openlp_plugins/images/__init__.py | 2 +- .../openlp_plugins/images/test_lib.py | 6 +- .../songs/test_songshowplusimport.py | 12 +-- .../songs/test_worshipcenterproimport.py | 74 ++++++++++--------- tests/interfaces/openlp_core_lib/__init__.py | 2 +- .../interfaces/openlp_core_utils/__init__.py | 2 +- tests/interfaces/openlp_plugins/__init__.py | 2 +- .../openlp_plugins/custom/__init__.py | 1 + .../openlp_plugins/remotes/__init__.py | 2 +- .../openlp_plugins/songs/__init__.py | 2 +- tests/utils/__init__.py | 1 - 28 files changed, 142 insertions(+), 127 deletions(-) diff --git a/openlp/plugins/remotes/lib/httpserver.py b/openlp/plugins/remotes/lib/httpserver.py index fa578184b..22d0349f8 100644 --- a/openlp/plugins/remotes/lib/httpserver.py +++ b/openlp/plugins/remotes/lib/httpserver.py @@ -28,15 +28,15 @@ ############################################################################### """ -The :mod:`http` module contains the API web server. This is a lightweight web -server used by remotes to interact with OpenLP. It uses JSON to communicate with -the remotes. +The :mod:`http` module contains the API web server. This is a lightweight web server used by remotes to interact +with OpenLP. It uses JSON to communicate with the remotes. """ import ssl import socket import os import logging +import time from PyQt4 import QtCore @@ -53,8 +53,8 @@ log = logging.getLogger(__name__) class CustomHandler(BaseHTTPRequestHandler, HttpRouter): """ Stateless session handler to handle the HTTP request and process it. - This class handles just the overrides to the base methods and the logic to invoke the - methods within the HttpRouter class. + This class handles just the overrides to the base methods and the logic to invoke the methods within the HttpRouter + class. DO not try change the structure as this is as per the documentation. """ @@ -116,9 +116,20 @@ class OpenLPServer(): log.debug('Started ssl httpd...') else: port = Settings().value(self.settings_section + '/port') - self.httpd = ThreadingHTTPServer((address, port), CustomHandler) + loop = 1 + while loop < 3: + try: + self.httpd = ThreadingHTTPServer((address, port), CustomHandler) + except OSError: + loop += 1 + time.sleep(0.1) + except: + log.error('Failed to start server ') log.debug('Started non ssl httpd...') - self.httpd.serve_forever() + if hasattr(self, 'httpd') and self.httpd: + self.httpd.serve_forever() + else: + log.debug('Failed to start server') def stop_server(self): """ diff --git a/resources/__init__.py b/resources/__init__.py index 20e2bd293..1bfef8133 100644 --- a/resources/__init__.py +++ b/resources/__init__.py @@ -32,4 +32,3 @@ The :mod:`resources` module contains a bunch of resources for OpenLP. DO NOT REMOVE THIS FILE, IT IS REQUIRED FOR INCLUDING THE RESOURCES ON SOME PLATFORMS! """ - diff --git a/scripts/translation_utils.py b/scripts/translation_utils.py index 402813f5b..5aa320806 100755 --- a/scripts/translation_utils.py +++ b/scripts/translation_utils.py @@ -52,7 +52,9 @@ This is done easily via the ``-d``, ``-p`` and ``-u`` options:: """ import os -import urllib.request, urllib.error, urllib.parse +import urllib.request +import urllib.error +import urllib.parse from getpass import getpass import base64 import json @@ -70,6 +72,7 @@ quiet_mode = False username = '' password = '' + class Command(object): """ Provide an enumeration of commands. @@ -80,6 +83,7 @@ class Command(object): Update = 4 Generate = 5 + class CommandStack(object): """ This class provides an iterable stack. @@ -134,13 +138,13 @@ class CommandStack(object): results.append(str((item['command'], ))) return '[%s]' % ', '.join(results) + def print_quiet(text, linefeed=True): """ - This method checks to see if we are in quiet mode, and if not prints - ``text`` out. + This method checks to see if we are in quiet mode, and if not prints ``text`` out. - ``text`` - The text to print. + :param text: The text to print. + :param linefeed: Linefeed required """ global quiet_mode if not quiet_mode: @@ -149,33 +153,33 @@ def print_quiet(text, linefeed=True): else: print(text, end=' ') + def print_verbose(text): """ - This method checks to see if we are in verbose mode, and if so prints - ``text`` out. + This method checks to see if we are in verbose mode, and if so prints ``text`` out. - ``text`` - The text to print. + :param text: The text to print. """ global verbose_mode, quiet_mode if not quiet_mode and verbose_mode: print(' %s' % text) + def run(command): """ This method runs an external application. - ``command`` - The command to run. + :param command: The command to run. """ print_verbose(command) process = QtCore.QProcess() process.start(command) - while (process.waitForReadyRead()): + while process.waitForReadyRead(): print_verbose('ReadyRead: %s' % QtCore.QString(process.readAll())) print_verbose('Error(s):\n%s' % process.readAllStandardError()) print_verbose('Output:\n%s' % process.readAllStandardOutput()) + def download_translations(): """ This method downloads the translation files from the Pootle server. @@ -190,9 +194,8 @@ def download_translations(): password = getpass(' Transifex password: ') # First get the list of languages url = SERVER_URL + 'resource/ents/' - base64string = base64.encodestring( - '%s:%s' % (username, password))[:-1] - auth_header = 'Basic %s' % base64string + base64string = base64.encodbytes('%s:%s' % (username, password))[:-1] + auth_header = 'Basic %s' % base64string request = urllib.request.Request(url + '?details') request.add_header('Authorization', auth_header) print_verbose('Downloading list of languages from: %s' % url) @@ -207,8 +210,7 @@ def download_translations(): lang_url = url + 'translation/%s/?file' % language request = urllib.request.Request(lang_url) request.add_header('Authorization', auth_header) - filename = os.path.join(os.path.abspath('..'), 'resources', 'i18n', - language + '.ts') + filename = os.path.join(os.path.abspath('..'), 'resources', 'i18n', language + '.ts') print_verbose('Get Translation File: %s' % filename) response = urllib.request.urlopen(request) fd = open(filename, 'w') @@ -217,10 +219,10 @@ def download_translations(): print_quiet(' Done.') return True + def prepare_project(): """ - This method creates the project file needed to update the translation files - and compile them into .qm files. + This method creates the project file needed to update the translation files and compile them into .qm files. """ print_quiet('Generating the openlp.pro file') lines = [] @@ -229,9 +231,9 @@ def prepare_project(): print_verbose('Starting directory: %s' % start_dir) for root, dirs, files in os.walk(start_dir): for file in files: - path = root.replace(start_dir, '').replace('\\', '/') #.replace(u'..', u'.') + path = root.replace(start_dir, '').replace('\\', '/') if file.startswith('hook-') or file.startswith('test_'): - continue + continue ignore = False for ignored_path in IGNORED_PATHS: if path.startswith(ignored_path): @@ -263,6 +265,7 @@ def prepare_project(): file.close() print_quiet(' Done.') + def update_translations(): print_quiet('Update the translation files') if not os.path.exists(os.path.join(os.path.abspath('..'), 'openlp.pro')): @@ -273,11 +276,12 @@ def update_translations(): run('pylupdate4 -verbose -noobsolete openlp.pro') os.chdir(os.path.abspath('scripts')) + def generate_binaries(): print_quiet('Generate the related *.qm files') if not os.path.exists(os.path.join(os.path.abspath('..'), 'openlp.pro')): print('You have not generated a project file yet, please run this script with the -p option. It is also ' + - 'recommended that you this script with the -u option to update the translation files as well.') + 'recommended that you this script with the -u option to update the translation files as well.') return else: os.chdir(os.path.abspath('..')) @@ -290,12 +294,11 @@ def create_translation(): This method opens a browser to the OpenLP project page at Transifex so that the user can request a new language. """ - print_quiet('Please request a new language at the OpenLP project on ' - 'Transifex.') - webbrowser.open('https://www.transifex.net/projects/p/openlp/' - 'resource/ents/') + print_quiet('Please request a new language at the OpenLP project on Transifex.') + webbrowser.open('https://www.transifex.net/projects/p/openlp/resource/ents/') print_quiet('Opening browser to OpenLP project...') + def process_stack(command_stack): """ This method looks at the commands in the command stack, and processes them @@ -323,6 +326,7 @@ def process_stack(command_stack): else: print_quiet('No commands to process.') + def main(): global verbose_mode, quiet_mode, username, password # Set up command line options. @@ -331,23 +335,23 @@ def main(): 'This script is used to manage OpenLP\'s translation files.' parser = OptionParser(usage=usage) parser.add_option('-U', '--username', dest='username', metavar='USERNAME', - help='Transifex username, used for authentication') + help='Transifex username, used for authentication') parser.add_option('-P', '--password', dest='password', metavar='PASSWORD', - help='Transifex password, used for authentication') + help='Transifex password, used for authentication') parser.add_option('-d', '--download-ts', dest='download', - action='store_true', help='download language files from Transifex') + action='store_true', help='download language files from Transifex') parser.add_option('-c', '--create', dest='create', action='store_true', - help='go to Transifex to request a new translation file') + help='go to Transifex to request a new translation file') parser.add_option('-p', '--prepare', dest='prepare', action='store_true', - help='generate a project file, used to update the translations') + help='generate a project file, used to update the translations') parser.add_option('-u', '--update', action='store_true', dest='update', - help='update translation files (needs a project file)') + help='update translation files (needs a project file)') parser.add_option('-g', '--generate', dest='generate', action='store_true', - help='compile .ts files into .qm files') + help='compile .ts files into .qm files') parser.add_option('-v', '--verbose', dest='verbose', action='store_true', - help='show extra information while processing translations') + help='show extra information while processing translations') parser.add_option('-q', '--quiet', dest='quiet', action='store_true', - help='suppress all output other than errors') + help='suppress all output other than errors') (options, args) = parser.parse_args() # Create and populate the command stack command_stack = CommandStack() diff --git a/setup.py b/setup.py index 276188188..fc4a6f89b 100755 --- a/setup.py +++ b/setup.py @@ -106,9 +106,9 @@ try: # If they are equal, then this tree is tarball with the source for the release. We do not want the revision number # in the version string. if tree_revision == tag_revision: - version_string = tag_version + version_string = tag_version else: - version_string = '%s-bzr%s' % (tag_version, tree_revision) + version_string = '%s-bzr%s' % (tag_version, tree_revision) ver_file = open(VERSION_FILE, 'w') ver_file.write(version_string) except: @@ -123,7 +123,9 @@ setup( version=version_string, description="Open source Church presentation and lyrics projection application.", long_description="""\ -OpenLP (previously openlp.org) is free church presentation software, or lyrics projection software, used to display slides of songs, Bible verses, videos, images, and even presentations (if PowerPoint is installed) for church worship using a computer and a data projector.""", +OpenLP (previously openlp.org) is free church presentation software, or lyrics projection software, used to display +slides of songs, Bible verses, videos, images, and even presentations (if PowerPoint is installed) for church worship +using a computer and a data projector.""", classifiers=[ 'Development Status :: 4 - Beta', 'Environment :: MacOS X', @@ -158,7 +160,7 @@ OpenLP (previously openlp.org) is free church presentation software, or lyrics p 'Topic :: Multimedia :: Sound/Audio', 'Topic :: Multimedia :: Video', 'Topic :: Religion' - ], # Get strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers + ], # Get strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers keywords='open source church presentation lyrics projection song bible display project', author='Raoul Snyman', author_email='raoulsnyman@openlp.org', diff --git a/tests/functional/openlp_core_common/test_applocation.py b/tests/functional/openlp_core_common/test_applocation.py index 8bac4abbf..27a47de6e 100644 --- a/tests/functional/openlp_core_common/test_applocation.py +++ b/tests/functional/openlp_core_common/test_applocation.py @@ -54,9 +54,9 @@ class TestAppLocation(TestCase): # GIVEN: A mocked out Settings class and a mocked out AppLocation.get_directory() mocked_settings = mocked_class.return_value mocked_settings.contains.return_value = False - mocked_get_directory.return_value = os.path.join('test','dir') + mocked_get_directory.return_value = os.path.join('test', 'dir') mocked_check_directory_exists.return_value = True - mocked_os.path.normpath.return_value = os.path.join('test','dir') + mocked_os.path.normpath.return_value = os.path.join('test', 'dir') # WHEN: we call AppLocation.get_data_path() data_path = AppLocation.get_data_path() @@ -64,8 +64,8 @@ class TestAppLocation(TestCase): # THEN: check that all the correct methods were called, and the result is correct mocked_settings.contains.assert_called_with('advanced/data path') mocked_get_directory.assert_called_with(AppLocation.DataDir) - mocked_check_directory_exists.assert_called_with(os.path.join('test','dir')) - self.assertEqual(os.path.join('test','dir'), data_path, 'Result should be "test/dir"') + mocked_check_directory_exists.assert_called_with(os.path.join('test', 'dir')) + self.assertEqual(os.path.join('test', 'dir'), data_path, 'Result should be "test/dir"') def get_data_path_with_custom_location_test(self): """ @@ -110,14 +110,14 @@ class TestAppLocation(TestCase): with patch('openlp.core.common.AppLocation.get_data_path') as mocked_get_data_path, \ patch('openlp.core.common.applocation.os.listdir') as mocked_listdir: # GIVEN: Our mocked modules/methods. - mocked_get_data_path.return_value = os.path.join('test','dir') + mocked_get_data_path.return_value = os.path.join('test', 'dir') mocked_listdir.return_value = copy.deepcopy(FILE_LIST) # When: Get the list of files. result = AppLocation.get_files('section', '.mp3') # Then: Check if the section parameter was used correctly. - mocked_listdir.assert_called_with(os.path.join('test','dir','section')) + mocked_listdir.assert_called_with(os.path.join('test', 'dir', 'section')) # Then: check if the file lists are identical. self.assertListEqual(['file5.mp3', 'file6.mp3'], result, 'The file lists should be identical.') @@ -129,15 +129,15 @@ class TestAppLocation(TestCase): with patch('openlp.core.common.AppLocation.get_data_path') as mocked_get_data_path, \ patch('openlp.core.common.applocation.check_directory_exists') as mocked_check_directory_exists: # GIVEN: A mocked out AppLocation.get_data_path() - mocked_get_data_path.return_value = os.path.join('test','dir') + mocked_get_data_path.return_value = os.path.join('test', 'dir') mocked_check_directory_exists.return_value = True # WHEN: we call AppLocation.get_data_path() data_path = AppLocation.get_section_data_path('section') # THEN: check that all the correct methods were called, and the result is correct - mocked_check_directory_exists.assert_called_with(os.path.join('test','dir','section')) - self.assertEqual(os.path.join('test','dir','section'), data_path, 'Result should be "test/dir/section"') + mocked_check_directory_exists.assert_called_with(os.path.join('test', 'dir', 'section')) + self.assertEqual(os.path.join('test', 'dir', 'section'), data_path, 'Result should be "test/dir/section"') def get_directory_for_app_dir_test(self): """ @@ -145,13 +145,13 @@ class TestAppLocation(TestCase): """ # GIVEN: A mocked out _get_frozen_path function with patch('openlp.core.common.applocation.get_frozen_path') as mocked_get_frozen_path: - mocked_get_frozen_path.return_value = os.path.join('app','dir') + mocked_get_frozen_path.return_value = os.path.join('app', 'dir') # WHEN: We call AppLocation.get_directory directory = AppLocation.get_directory(AppLocation.AppDir) # THEN: check that the correct directory is returned - self.assertEqual(os.path.join('app','dir'), directory, 'Directory should be "app/dir"') + self.assertEqual(os.path.join('app', 'dir'), directory, 'Directory should be "app/dir"') def get_directory_for_plugins_dir_test(self): """ diff --git a/tests/functional/openlp_core_lib/__init__.py b/tests/functional/openlp_core_lib/__init__.py index 70585a1d1..0f0461449 100644 --- a/tests/functional/openlp_core_lib/__init__.py +++ b/tests/functional/openlp_core_lib/__init__.py @@ -28,4 +28,4 @@ ############################################################################### """ Package to test the openlp.core.lib package. -""" \ No newline at end of file +""" diff --git a/tests/functional/openlp_core_lib/test_db.py b/tests/functional/openlp_core_lib/test_db.py index 470bd0636..f11292209 100644 --- a/tests/functional/openlp_core_lib/test_db.py +++ b/tests/functional/openlp_core_lib/test_db.py @@ -52,7 +52,7 @@ class TestDB(TestCase): with patch('openlp.core.lib.db.create_engine') as mocked_create_engine, \ patch('openlp.core.lib.db.MetaData') as MockedMetaData, \ patch('openlp.core.lib.db.sessionmaker') as mocked_sessionmaker, \ - patch('openlp.core.lib.db.scoped_session') as mocked_scoped_session: + patch('openlp.core.lib.db.scoped_session') as mocked_scoped_session: mocked_engine = MagicMock() mocked_metadata = MagicMock() mocked_sessionmaker_object = MagicMock() diff --git a/tests/functional/openlp_core_lib/test_file_dialog.py b/tests/functional/openlp_core_lib/test_file_dialog.py index 1d8040525..b2c2178a9 100644 --- a/tests/functional/openlp_core_lib/test_file_dialog.py +++ b/tests/functional/openlp_core_lib/test_file_dialog.py @@ -42,7 +42,8 @@ class TestFileDialog(TestCase): # THEN: The returned value should be an empty QStringList and os.path.exists should not have been called assert not self.mocked_os.path.exists.called self.assertEqual(result, [], - 'FileDialog.getOpenFileNames should return and empty list when QFileDialog.getOpenFileNames is canceled') + 'FileDialog.getOpenFileNames should return and empty list when QFileDialog.getOpenFileNames ' + 'is canceled') def returned_file_list_test(self): """ @@ -70,5 +71,5 @@ class TestFileDialog(TestCase): self.mocked_os.path.exists.assert_callde_with('/non-existing') self.mocked_os.path.exists.assert_callde_with('/non-existing') self.mocked_qt_gui.QmessageBox.information.called_with(self.mocked_parent, UiStrings().FileNotFound, - UiStrings().FileNotFoundMessage % '/non-existing') - self.assertEqual(result, ['/Valid File', '/url encoded file #1'], 'The returned file list is incorrect') \ No newline at end of file + UiStrings().FileNotFoundMessage % '/non-existing') + self.assertEqual(result, ['/Valid File', '/url encoded file #1'], 'The returned file list is incorrect') diff --git a/tests/functional/openlp_core_lib/test_formattingtags.py b/tests/functional/openlp_core_lib/test_formattingtags.py index 17f044d0f..c1311c543 100644 --- a/tests/functional/openlp_core_lib/test_formattingtags.py +++ b/tests/functional/openlp_core_lib/test_formattingtags.py @@ -108,4 +108,3 @@ class TestFormattingTags(TestCase): # THEN: The lists should now be identical. assert old_tags_list == FormattingTags.get_html_tags(), 'The lists should be identical.' - diff --git a/tests/functional/openlp_core_lib/test_htmlbuilder.py b/tests/functional/openlp_core_lib/test_htmlbuilder.py index 05d15a1c2..ef5ffdf43 100644 --- a/tests/functional/openlp_core_lib/test_htmlbuilder.py +++ b/tests/functional/openlp_core_lib/test_htmlbuilder.py @@ -321,4 +321,3 @@ class Htmbuilder(TestCase): # THEN: THE css should be the same. assert FOOTER_CSS == css, 'The footer strings should be equal.' - diff --git a/tests/functional/openlp_core_lib/test_lib.py b/tests/functional/openlp_core_lib/test_lib.py index 8faf7747a..bb3a17ebb 100644 --- a/tests/functional/openlp_core_lib/test_lib.py +++ b/tests/functional/openlp_core_lib/test_lib.py @@ -311,8 +311,8 @@ class TestLib(TestCase): mocked_buffer.open.assert_called_with('writeonly') mocked_image.save.assert_called_with(mocked_buffer, "PNG") mocked_byte_array.toBase64.assert_called_with() - self.assertEqual('base64mock', result, - 'The result should be the return value of the mocked out base64 method') + self.assertEqual('base64mock', result, 'The result should be the return value of the mocked out ' + 'base64 method') def create_thumb_with_size_test(self): """ diff --git a/tests/functional/openlp_core_lib/test_renderer.py b/tests/functional/openlp_core_lib/test_renderer.py index d0aa82b74..51e915e3f 100644 --- a/tests/functional/openlp_core_lib/test_renderer.py +++ b/tests/functional/openlp_core_lib/test_renderer.py @@ -86,4 +86,4 @@ class TestRenderer(TestCase): self.assertEqual(renderer.width, 1024, 'The base renderer should be a live controller') self.assertEqual(renderer.height, 768, 'The base renderer should be a live controller') self.assertEqual(renderer.screen_ratio, 0.75, 'The base renderer should be a live controller') - self.assertEqual(renderer.footer_start, 691, 'The base renderer should be a live controller') \ No newline at end of file + self.assertEqual(renderer.footer_start, 691, 'The base renderer should be a live controller') diff --git a/tests/functional/openlp_core_lib/test_theme.py b/tests/functional/openlp_core_lib/test_theme.py index f0229e64c..bcdced35f 100644 --- a/tests/functional/openlp_core_lib/test_theme.py +++ b/tests/functional/openlp_core_lib/test_theme.py @@ -69,4 +69,3 @@ class TestTheme(TestCase): 'The theme should have a font_footer_name of Arial') self.assertTrue(default_theme.font_main_bold is False, 'The theme should have a font_main_bold of false') self.assertTrue(len(default_theme.__dict__) == 47, 'The theme should have 47 variables') - diff --git a/tests/functional/openlp_core_utils/__init__.py b/tests/functional/openlp_core_utils/__init__.py index 1f4f74a33..6b241e7fc 100644 --- a/tests/functional/openlp_core_utils/__init__.py +++ b/tests/functional/openlp_core_utils/__init__.py @@ -25,4 +25,4 @@ # 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 # -############################################################################### \ No newline at end of file +############################################################################### diff --git a/tests/functional/openlp_plugins/bibles/__init__.py b/tests/functional/openlp_plugins/bibles/__init__.py index 4c8c00fec..6b241e7fc 100644 --- a/tests/functional/openlp_plugins/bibles/__init__.py +++ b/tests/functional/openlp_plugins/bibles/__init__.py @@ -26,4 +26,3 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### - diff --git a/tests/functional/openlp_plugins/bibles/test_http.py b/tests/functional/openlp_plugins/bibles/test_http.py index 9a1be8d0e..b9bb8f11c 100644 --- a/tests/functional/openlp_plugins/bibles/test_http.py +++ b/tests/functional/openlp_plugins/bibles/test_http.py @@ -116,7 +116,8 @@ class TestBSExtract(TestCase): self.mock_get_soup_for_bible_ref.assert_called_once_with( 'http://m.bibleserver.com/overlay/selectBook?translation=NIV') self.assertIsNone(result, - 'BSExtract.get_books_from_http should return None when get_soup_for_bible_ref returns a false value') + 'BSExtract.get_books_from_http should return None when get_soup_for_bible_ref returns a ' + 'false value') def get_books_from_http_no_content_test(self): """ @@ -146,7 +147,8 @@ class TestBSExtract(TestCase): self.mock_log.error.assert_called_once_with('No books found in the Bibleserver response.') self.mock_send_error_message.assert_called_once_with('parse') self.assertIsNone(result, - 'BSExtract.get_books_from_http should return None when get_soup_for_bible_ref returns a false value') + 'BSExtract.get_books_from_http should return None when get_soup_for_bible_ref returns a ' + 'false value') def get_books_from_http_content_test(self): """ diff --git a/tests/functional/openlp_plugins/bibles/test_lib.py b/tests/functional/openlp_plugins/bibles/test_lib.py index 9b3e79591..0c8bb8211 100644 --- a/tests/functional/openlp_plugins/bibles/test_lib.py +++ b/tests/functional/openlp_plugins/bibles/test_lib.py @@ -85,5 +85,3 @@ class TestLib(TestCase): # THEN: It should be False self.assertFalse(has_verse_list, 'The SearchResults object should have a verse list') - - diff --git a/tests/functional/openlp_plugins/images/__init__.py b/tests/functional/openlp_plugins/images/__init__.py index 1f4f74a33..6b241e7fc 100644 --- a/tests/functional/openlp_plugins/images/__init__.py +++ b/tests/functional/openlp_plugins/images/__init__.py @@ -25,4 +25,4 @@ # 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 # -############################################################################### \ No newline at end of file +############################################################################### diff --git a/tests/functional/openlp_plugins/images/test_lib.py b/tests/functional/openlp_plugins/images/test_lib.py index 80d452644..202b5a42b 100644 --- a/tests/functional/openlp_plugins/images/test_lib.py +++ b/tests/functional/openlp_plugins/images/test_lib.py @@ -108,7 +108,7 @@ class TestImageMediaItem(TestCase): Test that the save_new_images_list() saves all images in the list """ # GIVEN: A list with 3 images - image_list = [ 'test_image_1.jpg', 'test_image_2.jpg', 'test_image_3.jpg' ] + image_list = ['test_image_1.jpg', 'test_image_2.jpg', 'test_image_3.jpg'] with patch('openlp.plugins.images.lib.mediaitem.ImageMediaItem.load_full_list') as mocked_load_full_list: self.media_item.manager = MagicMock() @@ -124,7 +124,7 @@ class TestImageMediaItem(TestCase): Test that the save_new_images_list() ignores everything in the provided list except strings """ # GIVEN: A list with images and objects - image_list = [ 'test_image_1.jpg', None, True, ImageFilenames(), 'test_image_2.jpg' ] + image_list = ['test_image_1.jpg', None, True, ImageFilenames(), 'test_image_2.jpg'] with patch('openlp.plugins.images.lib.mediaitem.ImageMediaItem.load_full_list') as mocked_load_full_list: self.media_item.manager = MagicMock() @@ -171,7 +171,7 @@ class TestImageMediaItem(TestCase): assert self.media_item.manager.delete_object.call_count == 7, \ 'manager.delete_object() should be called exactly 7 times' - # CLEANUP: Remove added attribute from ImageFilenames and ImageGroups + # CLEANUP: Remove added attribute from Image Filenames and ImageGroups delattr(ImageFilenames, 'group_id') delattr(ImageGroups, 'parent_id') diff --git a/tests/functional/openlp_plugins/songs/test_songshowplusimport.py b/tests/functional/openlp_plugins/songs/test_songshowplusimport.py index 16af347b2..f3fe231d0 100644 --- a/tests/functional/openlp_plugins/songs/test_songshowplusimport.py +++ b/tests/functional/openlp_plugins/songs/test_songshowplusimport.py @@ -115,8 +115,8 @@ class TestSongShowPlusImport(TestCase): # THEN: do_import should return none and the progress bar setMaximum should be called with the length of # import_source. - self.assertIsNone(importer.do_import(), - 'do_import should return None when import_source is a list and stop_import_flag is True') + self.assertIsNone(importer.do_import(), 'do_import should return None when import_source is a list ' + 'and stop_import_flag is True') mocked_import_wizard.progress_bar.setMaximum.assert_called_with(len(importer.import_source)) def to_openlp_verse_tag_test(self): @@ -143,8 +143,8 @@ class TestSongShowPlusImport(TestCase): # THEN: The returned value should should correlate with the input arguments for original_tag, openlp_tag in test_values: self.assertEquals(importer.to_openlp_verse_tag(original_tag), openlp_tag, - 'SongShowPlusImport.to_openlp_verse_tag should return "%s" when called with "%s"' - % (openlp_tag, original_tag)) + 'SongShowPlusImport.to_openlp_verse_tag should return "%s" when called with "%s"' % + (openlp_tag, original_tag)) def to_openlp_verse_tag_verse_order_test(self): """ @@ -171,5 +171,5 @@ class TestSongShowPlusImport(TestCase): # THEN: The returned value should should correlate with the input arguments for original_tag, openlp_tag in test_values: self.assertEquals(importer.to_openlp_verse_tag(original_tag, ignore_unique=True), openlp_tag, - 'SongShowPlusImport.to_openlp_verse_tag should return "%s" when called with "%s"' - % (openlp_tag, original_tag)) + 'SongShowPlusImport.to_openlp_verse_tag should return "%s" when called with "%s"' % + (openlp_tag, original_tag)) diff --git a/tests/functional/openlp_plugins/songs/test_worshipcenterproimport.py b/tests/functional/openlp_plugins/songs/test_worshipcenterproimport.py index 630fb572e..c6acbe965 100644 --- a/tests/functional/openlp_plugins/songs/test_worshipcenterproimport.py +++ b/tests/functional/openlp_plugins/songs/test_worshipcenterproimport.py @@ -73,35 +73,37 @@ class WorshipCenterProImportLogger(WorshipCenterProImport): RECORDSET_TEST_DATA = [TestRecord(1, 'TITLE', 'Amazing Grace'), - TestRecord(1, 'LYRICS', - 'Amazing grace! How&crlf;sweet the sound&crlf;That saved a wretch like me!&crlf;' - 'I once was lost,&crlf;but now am found;&crlf;Was blind, but now I see.&crlf;&crlf;' - '\'Twas grace that&crlf;taught my heart to fear,&crlf;And grace my fears relieved;&crlf;' - 'How precious did&crlf;that grace appear&crlf;The hour I first believed.&crlf;&crlf;' - 'Through many dangers,&crlf;toils and snares,&crlf;I have already come;&crlf;' - '\'Tis grace hath brought&crlf;me safe thus far,&crlf;' - 'And grace will lead me home.&crlf;&crlf;The Lord has&crlf;promised good to me,&crlf;' - 'His Word my hope secures;&crlf;He will my Shield&crlf;and Portion be,&crlf;' - 'As long as life endures.&crlf;&crlf;Yea, when this flesh&crlf;and heart shall fail,&crlf;' - 'And mortal life shall cease,&crlf;I shall possess,&crlf;within the veil,&crlf;' - 'A life of joy and peace.&crlf;&crlf;The earth shall soon&crlf;dissolve like snow,&crlf;' - 'The sun forbear to shine;&crlf;But God, Who called&crlf;me here below,&crlf;' - 'Shall be forever mine.&crlf;&crlf;When we\'ve been there&crlf;ten thousand years,&crlf;' - 'Bright shining as the sun,&crlf;We\'ve no less days to&crlf;sing God\'s praise&crlf;' - 'Than when we\'d first begun.&crlf;&crlf;'), + TestRecord( + 1, 'LYRICS', + 'Amazing grace! How&crlf;sweet the sound&crlf;That saved a wretch like me!&crlf;' + 'I once was lost,&crlf;but now am found;&crlf;Was blind, but now I see.&crlf;&crlf;' + '\'Twas grace that&crlf;taught my heart to fear,&crlf;And grace my fears relieved;&crlf;' + 'How precious did&crlf;that grace appear&crlf;The hour I first believed.&crlf;&crlf;' + 'Through many dangers,&crlf;toils and snares,&crlf;I have already come;&crlf;' + '\'Tis grace hath brought&crlf;me safe thus far,&crlf;' + 'And grace will lead me home.&crlf;&crlf;The Lord has&crlf;promised good to me,&crlf;' + 'His Word my hope secures;&crlf;He will my Shield&crlf;and Portion be,&crlf;' + 'As long as life endures.&crlf;&crlf;Yea, when this flesh&crlf;and heart shall fail,&crlf;' + 'And mortal life shall cease,&crlf;I shall possess,&crlf;within the veil,&crlf;' + 'A life of joy and peace.&crlf;&crlf;The earth shall soon&crlf;dissolve like snow,&crlf;' + 'The sun forbear to shine;&crlf;But God, Who called&crlf;me here below,&crlf;' + 'Shall be forever mine.&crlf;&crlf;When we\'ve been there&crlf;ten thousand years,&crlf;' + 'Bright shining as the sun,&crlf;We\'ve no less days to&crlf;sing God\'s praise&crlf;' + 'Than when we\'d first begun.&crlf;&crlf;'), TestRecord(2, 'TITLE', 'Beautiful Garden Of Prayer, The'), - TestRecord(2, 'LYRICS', - 'There\'s a garden where&crlf;Jesus is waiting,&crlf;' - 'There\'s a place that&crlf;is wondrously fair,&crlf;For it glows with the&crlf;' - 'light of His presence.&crlf;\'Tis the beautiful&crlf;garden of prayer.&crlf;&crlf;' - 'Oh, the beautiful garden,&crlf;the garden of prayer!&crlf;Oh, the beautiful&crlf;' - 'garden of prayer!&crlf;There my Savior awaits,&crlf;and He opens the gates&crlf;' - 'To the beautiful&crlf;garden of prayer.&crlf;&crlf;There\'s a garden where&crlf;' - 'Jesus is waiting,&crlf;And I go with my&crlf;burden and care,&crlf;' - 'Just to learn from His&crlf;lips words of comfort&crlf;In the beautiful&crlf;' - 'garden of prayer.&crlf;&crlf;There\'s a garden where&crlf;Jesus is waiting,&crlf;' - 'And He bids you to come,&crlf;meet Him there;&crlf;Just to bow and&crlf;' - 'receive a new blessing&crlf;In the beautiful&crlf;garden of prayer.&crlf;&crlf;')] + TestRecord( + 2, 'LYRICS', + 'There\'s a garden where&crlf;Jesus is waiting,&crlf;' + 'There\'s a place that&crlf;is wondrously fair,&crlf;For it glows with the&crlf;' + 'light of His presence.&crlf;\'Tis the beautiful&crlf;garden of prayer.&crlf;&crlf;' + 'Oh, the beautiful garden,&crlf;the garden of prayer!&crlf;Oh, the beautiful&crlf;' + 'garden of prayer!&crlf;There my Savior awaits,&crlf;and He opens the gates&crlf;' + 'To the beautiful&crlf;garden of prayer.&crlf;&crlf;There\'s a garden where&crlf;' + 'Jesus is waiting,&crlf;And I go with my&crlf;burden and care,&crlf;' + 'Just to learn from His&crlf;lips words of comfort&crlf;In the beautiful&crlf;' + 'garden of prayer.&crlf;&crlf;There\'s a garden where&crlf;Jesus is waiting,&crlf;' + 'And He bids you to come,&crlf;meet Him there;&crlf;Just to bow and&crlf;' + 'receive a new blessing&crlf;In the beautiful&crlf;garden of prayer.&crlf;&crlf;')] SONG_TEST_DATA = [{'title': 'Amazing Grace', 'verses': [ ('Amazing grace! How\nsweet the sound\nThat saved a wretch like me!\nI once was lost,\n' @@ -118,7 +120,7 @@ SONG_TEST_DATA = [{'title': 'Amazing Grace', 'me here below,\nShall be forever mine.'), ('When we\'ve been there\nten thousand years,\nBright shining as the sun,\n' 'We\'ve no less days to\nsing God\'s praise\nThan when we\'d first begun.')]}, - {'title': 'Beautiful Garden Of Prayer, The', + {'title': 'Beautiful Garden Of Prayer, The', 'verses': [ ('There\'s a garden where\nJesus is waiting,\nThere\'s a place that\nis wondrously fair,\n' 'For it glows with the\nlight of His presence.\n\'Tis the beautiful\ngarden of prayer.'), @@ -129,6 +131,7 @@ SONG_TEST_DATA = [{'title': 'Amazing Grace', ('There\'s a garden where\nJesus is waiting,\nAnd He bids you to come,\nmeet Him there;\n' 'Just to bow and\nreceive a new blessing\nIn the beautiful\ngarden of prayer.')]}] + class TestWorshipCenterProSongImport(TestCase): """ Test the functions in the :mod:`worshipcenterproimport` module. @@ -155,7 +158,7 @@ class TestWorshipCenterProSongImport(TestCase): # a mocked "manager" and a mocked out log_error method. with patch('openlp.plugins.songs.lib.worshipcenterproimport.SongImport'), \ patch('openlp.plugins.songs.lib.worshipcenterproimport.pyodbc.connect') as mocked_pyodbc_connect, \ - patch('openlp.plugins.songs.lib.worshipcenterproimport.translate') as mocked_translate: + patch('openlp.plugins.songs.lib.worshipcenterproimport.translate') as mocked_translate: mocked_manager = MagicMock() mocked_log_error = MagicMock() mocked_translate.return_value = 'Translated Text' @@ -171,9 +174,9 @@ class TestWorshipCenterProSongImport(TestCase): # THEN: do_import should return None, and pyodbc, translate & log_error are called with known calls self.assertIsNone(return_value, 'do_import should return None when pyodbc raises an exception.') - mocked_pyodbc_connect.assert_called_with( 'DRIVER={Microsoft Access Driver (*.mdb)};DBQ=import_source') + mocked_pyodbc_connect.assert_called_with('DRIVER={Microsoft Access Driver (*.mdb)};DBQ=import_source') mocked_translate.assert_called_with('SongsPlugin.WorshipCenterProImport', - 'Unable to connect the WorshipCenter Pro database.') + 'Unable to connect the WorshipCenter Pro database.') mocked_log_error.assert_called_with('import_source', 'Translated Text') def song_import_test(self): @@ -184,7 +187,7 @@ class TestWorshipCenterProSongImport(TestCase): # translate method, a mocked "manager", add_verse method & mocked_finish method. with patch('openlp.plugins.songs.lib.worshipcenterproimport.SongImport'), \ patch('openlp.plugins.songs.lib.worshipcenterproimport.pyodbc') as mocked_pyodbc, \ - patch('openlp.plugins.songs.lib.worshipcenterproimport.translate') as mocked_translate: + patch('openlp.plugins.songs.lib.worshipcenterproimport.translate') as mocked_translate: mocked_manager = MagicMock() mocked_import_wizard = MagicMock() mocked_add_verse = MagicMock() @@ -201,7 +204,6 @@ class TestWorshipCenterProSongImport(TestCase): # WHEN: Calling the do_import method return_value = importer.do_import() - # THEN: do_import should return None, and pyodbc, import_wizard, importer.title and add_verse are called with # known calls self.assertIsNone(return_value, 'do_import should return None when pyodbc raises an exception.') @@ -214,10 +216,10 @@ class TestWorshipCenterProSongImport(TestCase): for song_data in SONG_TEST_DATA: title_value = song_data['title'] self.assertIn(title_value, importer._title_assignment_list, - 'title should have been set to %s' % title_value) + 'title should have been set to %s' % title_value) verse_calls = song_data['verses'] add_verse_call_count += len(verse_calls) for call in verse_calls: mocked_add_verse.assert_any_call(call) self.assertEqual(mocked_add_verse.call_count, add_verse_call_count, - 'Incorrect number of calls made to add_verse') + 'Incorrect number of calls made to add_verse') diff --git a/tests/interfaces/openlp_core_lib/__init__.py b/tests/interfaces/openlp_core_lib/__init__.py index 1f4f74a33..6b241e7fc 100644 --- a/tests/interfaces/openlp_core_lib/__init__.py +++ b/tests/interfaces/openlp_core_lib/__init__.py @@ -25,4 +25,4 @@ # 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 # -############################################################################### \ No newline at end of file +############################################################################### diff --git a/tests/interfaces/openlp_core_utils/__init__.py b/tests/interfaces/openlp_core_utils/__init__.py index 1f4f74a33..6b241e7fc 100644 --- a/tests/interfaces/openlp_core_utils/__init__.py +++ b/tests/interfaces/openlp_core_utils/__init__.py @@ -25,4 +25,4 @@ # 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 # -############################################################################### \ No newline at end of file +############################################################################### diff --git a/tests/interfaces/openlp_plugins/__init__.py b/tests/interfaces/openlp_plugins/__init__.py index 1f4f74a33..6b241e7fc 100644 --- a/tests/interfaces/openlp_plugins/__init__.py +++ b/tests/interfaces/openlp_plugins/__init__.py @@ -25,4 +25,4 @@ # 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 # -############################################################################### \ No newline at end of file +############################################################################### diff --git a/tests/interfaces/openlp_plugins/custom/__init__.py b/tests/interfaces/openlp_plugins/custom/__init__.py index 6b241e7fc..4c8c00fec 100644 --- a/tests/interfaces/openlp_plugins/custom/__init__.py +++ b/tests/interfaces/openlp_plugins/custom/__init__.py @@ -26,3 +26,4 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### + diff --git a/tests/interfaces/openlp_plugins/remotes/__init__.py b/tests/interfaces/openlp_plugins/remotes/__init__.py index 1f4f74a33..6b241e7fc 100644 --- a/tests/interfaces/openlp_plugins/remotes/__init__.py +++ b/tests/interfaces/openlp_plugins/remotes/__init__.py @@ -25,4 +25,4 @@ # 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 # -############################################################################### \ No newline at end of file +############################################################################### diff --git a/tests/interfaces/openlp_plugins/songs/__init__.py b/tests/interfaces/openlp_plugins/songs/__init__.py index 1f4f74a33..6b241e7fc 100644 --- a/tests/interfaces/openlp_plugins/songs/__init__.py +++ b/tests/interfaces/openlp_plugins/songs/__init__.py @@ -25,4 +25,4 @@ # 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 # -############################################################################### \ No newline at end of file +############################################################################### diff --git a/tests/utils/__init__.py b/tests/utils/__init__.py index 22f4ad8e5..e76e095ea 100644 --- a/tests/utils/__init__.py +++ b/tests/utils/__init__.py @@ -48,4 +48,3 @@ def convert_file_service_item(test_path, name, row=0): finally: open_file.close() return first_line - From 151f1017c538a3612b9627ea5902348c5bb4ba82 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 2 Apr 2014 20:35:09 +0100 Subject: [PATCH 40/51] finished --- .../openlp_core_common/test_registry.py | 1 - .../test_registryproperties.py | 2 +- .../openlp_core_common/test_uistrings.py | 2 - .../test_formattingtagscontroller.py | 19 ++-- .../openlp_core_ui/test_formattingtagsform.py | 1 - .../openlp_core_ui/test_servicemanager.py | 2 +- .../openlp_core_utils/test_actions.py | 2 - .../openlp_core_utils/test_utils.py | 8 +- .../openlp_plugins/presentations/__init__.py | 2 +- .../presentations/test_pptviewcontroller.py | 7 +- .../openlp_plugins/remotes/__init__.py | 2 +- .../openlp_plugins/remotes/test_router.py | 5 +- .../openlp_plugins/songs/test_ewimport.py | 105 ++++++++++-------- .../openlp_plugins/songs/test_lib.py | 32 +++--- .../songs/test_songbeamerimport.py | 10 +- .../openlp_plugins/songs/test_songselect.py | 2 +- .../songs/test_songshowplusimport.py | 6 +- .../songs/test_worshipcenterproimport.py | 4 +- tests/helpers/songfileimport.py | 21 ++-- .../openlp_core_lib/test_pluginmanager.py | 1 - .../openlp_core_lib/test_searchedit.py | 2 - .../openlp_core_ui/test_mainwindow.py | 1 - .../openlp_core_ui/test_servicenotedialog.py | 5 +- .../openlp_core_utils/test_utils.py | 1 - .../openlp_plugins/bibles/test_lib_http.py | 1 - .../openlp_plugins/bibles/test_lib_manager.py | 1 - .../bibles/test_lib_parse_reference.py | 7 +- .../openlp_plugins/custom/__init__.py | 1 - .../openlp_plugins/custom/forms/__init__.py | 2 +- .../custom/forms/test_customform.py | 1 - .../custom/forms/test_customslideform.py | 1 - .../openlp_plugins/songs/forms/__init__.py | 2 +- .../songs/forms/test_authorsform.py | 1 - .../songs/forms/test_editverseform.py | 1 - 34 files changed, 128 insertions(+), 133 deletions(-) diff --git a/tests/functional/openlp_core_common/test_registry.py b/tests/functional/openlp_core_common/test_registry.py index e27b69d10..8776f4bfb 100644 --- a/tests/functional/openlp_core_common/test_registry.py +++ b/tests/functional/openlp_core_common/test_registry.py @@ -119,4 +119,3 @@ class TestRegistry(TestCase): def dummy_function_2(self): return "function_2" - diff --git a/tests/functional/openlp_core_common/test_registryproperties.py b/tests/functional/openlp_core_common/test_registryproperties.py index 441860544..fa8a2b540 100644 --- a/tests/functional/openlp_core_common/test_registryproperties.py +++ b/tests/functional/openlp_core_common/test_registryproperties.py @@ -63,4 +63,4 @@ class TestRegistryProperties(TestCase, RegistryProperties): # WHEN the application is registered Registry().register('application', application) # THEN the application should be none - self.assertEquals(self.application, application, 'The application value should match') \ No newline at end of file + self.assertEquals(self.application, application, 'The application value should match') diff --git a/tests/functional/openlp_core_common/test_uistrings.py b/tests/functional/openlp_core_common/test_uistrings.py index 606bff732..742934b94 100644 --- a/tests/functional/openlp_core_common/test_uistrings.py +++ b/tests/functional/openlp_core_common/test_uistrings.py @@ -46,5 +46,3 @@ class TestUiStrings(TestCase): # THEN: Check if the instances are the same. self.assertIs(first_instance, second_instance, 'Two UiStrings objects should be the same instance') - - diff --git a/tests/functional/openlp_core_ui/test_formattingtagscontroller.py b/tests/functional/openlp_core_ui/test_formattingtagscontroller.py index b09b095be..1d8512940 100644 --- a/tests/functional/openlp_core_ui/test_formattingtagscontroller.py +++ b/tests/functional/openlp_core_ui/test_formattingtagscontroller.py @@ -72,9 +72,10 @@ class TestFormattingTagController(TestCase): # THEN: The result should match the predetermined value. self.assertTrue(result == test['gen'], - 'Function should handle end tag correctly : %s and %s for %s ' % (test['gen'], result, test['start'])) - self.assertTrue(error == test['valid'], - 'Function should not generate unexpected error messages : %s ' % error) + 'Function should handle end tag correctly : %s and %s for %s ' % + (test['gen'], result, test['start'])) + self.assertTrue(error == test['valid'], 'Function should not generate unexpected error messages : %s ' % + error) def test_start_tag_changed_processes_correctly(self): """ @@ -94,10 +95,10 @@ class TestFormattingTagController(TestCase): error, result = self.services.start_tag_changed(test['start'], test['end']) # THEN: The result should match the predetermined value. - self.assertTrue(result == test['gen'], - 'Function should handle end tag correctly : %s and %s ' % (test['gen'], result)) - self.assertTrue(error == test['valid'], - 'Function should not generate unexpected error messages : %s ' % error) + self.assertTrue(result == test['gen'], 'Function should handle end tag correctly : %s and %s ' % + (test['gen'], result)) + self.assertTrue(error == test['valid'], 'Function should not generate unexpected error messages : %s ' % + error) def test_start_html_to_end_html(self): """ @@ -112,5 +113,5 @@ class TestFormattingTagController(TestCase): result = self.services.start_html_to_end_html(test1) # THEN: The result should match the predetermined value. - self.assertTrue(result == test2, 'Calculated end tag should be valid: %s and %s = %s' - % (test1, test2, result)) \ No newline at end of file + self.assertTrue(result == test2, 'Calculated end tag should be valid: %s and %s = %s' % + (test1, test2, result)) diff --git a/tests/functional/openlp_core_ui/test_formattingtagsform.py b/tests/functional/openlp_core_ui/test_formattingtagsform.py index f9a9621aa..05b5fed74 100644 --- a/tests/functional/openlp_core_ui/test_formattingtagsform.py +++ b/tests/functional/openlp_core_ui/test_formattingtagsform.py @@ -74,4 +74,3 @@ class TestFormattingTagForm(TestCase): # THEN: setEnabled and setDefault should have been called on save_push_button #form.save_button.setEnabled.assert_called_with(True) - diff --git a/tests/functional/openlp_core_ui/test_servicemanager.py b/tests/functional/openlp_core_ui/test_servicemanager.py index 3de560786..260f88b6b 100644 --- a/tests/functional/openlp_core_ui/test_servicemanager.py +++ b/tests/functional/openlp_core_ui/test_servicemanager.py @@ -74,4 +74,4 @@ class TestServiceManager(TestCase): # THEN: The the controller should be registered in the registry. self.assertNotEqual(service, None, 'The base service should be created') self.assertEqual(service['openlp_core']['service-theme'], 'test_theme', 'The test theme should be saved') - self.assertEqual(service['openlp_core']['lite-service'], False, 'The lite service should be saved') \ No newline at end of file + self.assertEqual(service['openlp_core']['lite-service'], False, 'The lite service should be saved') diff --git a/tests/functional/openlp_core_utils/test_actions.py b/tests/functional/openlp_core_utils/test_actions.py index 092c96ac1..2868f8555 100644 --- a/tests/functional/openlp_core_utils/test_actions.py +++ b/tests/functional/openlp_core_utils/test_actions.py @@ -149,5 +149,3 @@ class TestActionList(TestCase, TestMixin): # THEN: Both action should keep their shortcuts. assert len(action3.shortcuts()) == 2, 'The action should have two shortcut assigned.' assert len(action_with_same_shortcuts3.shortcuts()) == 2, 'The action should have two shortcuts assigned.' - - diff --git a/tests/functional/openlp_core_utils/test_utils.py b/tests/functional/openlp_core_utils/test_utils.py index d6405d77b..a97d757ea 100644 --- a/tests/functional/openlp_core_utils/test_utils.py +++ b/tests/functional/openlp_core_utils/test_utils.py @@ -107,7 +107,7 @@ class TestUtils(TestCase): """ # GIVEN: sys.getfilesystemencoding returns "cp1252" with patch('openlp.core.utils.sys.getfilesystemencoding') as mocked_getfilesystemencoding, \ - patch('openlp.core.utils.sys.getdefaultencoding') as mocked_getdefaultencoding: + patch('openlp.core.utils.sys.getdefaultencoding') as mocked_getdefaultencoding: mocked_getfilesystemencoding.return_value = 'cp1252' # WHEN: get_filesystem_encoding() is called @@ -124,7 +124,7 @@ class TestUtils(TestCase): """ # GIVEN: sys.getfilesystemencoding returns None and sys.getdefaultencoding returns "utf-8" with patch('openlp.core.utils.sys.getfilesystemencoding') as mocked_getfilesystemencoding, \ - patch('openlp.core.utils.sys.getdefaultencoding') as mocked_getdefaultencoding: + patch('openlp.core.utils.sys.getdefaultencoding') as mocked_getdefaultencoding: mocked_getfilesystemencoding.return_value = None mocked_getdefaultencoding.return_value = 'utf-8' @@ -175,7 +175,7 @@ class TestUtils(TestCase): # THEN: A tuple should be returned. self.assertEqual(wanted_result, result, - 'A two-entry tuple with the directory and file name (empty) should have been returned.') + 'A two-entry tuple with the directory and file name (empty) should have been returned.') def clean_filename_test(self): """ @@ -206,7 +206,7 @@ class TestUtils(TestCase): # THEN: We get a properly sorted list self.assertEqual(['Aushang', '\u00C4u\u00DFerung', 'Auszug'], sorted_list, - 'Strings should be sorted properly') + 'Strings should be sorted properly') def get_natural_key_test(self): """ diff --git a/tests/functional/openlp_plugins/presentations/__init__.py b/tests/functional/openlp_plugins/presentations/__init__.py index 1f4f74a33..6b241e7fc 100644 --- a/tests/functional/openlp_plugins/presentations/__init__.py +++ b/tests/functional/openlp_plugins/presentations/__init__.py @@ -25,4 +25,4 @@ # 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 # -############################################################################### \ No newline at end of file +############################################################################### diff --git a/tests/functional/openlp_plugins/presentations/test_pptviewcontroller.py b/tests/functional/openlp_plugins/presentations/test_pptviewcontroller.py index 1b43615f3..8a8897cec 100644 --- a/tests/functional/openlp_plugins/presentations/test_pptviewcontroller.py +++ b/tests/functional/openlp_plugins/presentations/test_pptviewcontroller.py @@ -80,7 +80,8 @@ class TestPptviewController(TestCase, TestMixin): controller = PptviewController(plugin=self.mock_plugin) # THEN: The name of the presentation controller should be correct - self.assertEqual('Powerpoint Viewer', controller.name, 'The name of the presentation controller should be correct') + self.assertEqual('Powerpoint Viewer', controller.name, + 'The name of the presentation controller should be correct') def check_available_test(self): """ @@ -98,9 +99,9 @@ class TestPptviewController(TestCase, TestMixin): # THEN: On windows it should return True, on other platforms False if os.name == 'nt': - self.assertTrue(available, 'check_available should return True on windows.') + self.assertTrue(available, 'check_available should return True on windows.') else: - self.assertFalse(available, 'check_available should return False when not on windows.') + self.assertFalse(available, 'check_available should return False when not on windows.') class TestPptviewDocument(TestCase): diff --git a/tests/functional/openlp_plugins/remotes/__init__.py b/tests/functional/openlp_plugins/remotes/__init__.py index 1f4f74a33..6b241e7fc 100644 --- a/tests/functional/openlp_plugins/remotes/__init__.py +++ b/tests/functional/openlp_plugins/remotes/__init__.py @@ -25,4 +25,4 @@ # 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 # -############################################################################### \ No newline at end of file +############################################################################### diff --git a/tests/functional/openlp_plugins/remotes/test_router.py b/tests/functional/openlp_plugins/remotes/test_router.py index 774ce5fcd..9e13a448b 100644 --- a/tests/functional/openlp_plugins/remotes/test_router.py +++ b/tests/functional/openlp_plugins/remotes/test_router.py @@ -111,7 +111,8 @@ class TestRouter(TestCase, TestMixin): Test the get_content_type logic """ # GIVEN: a set of files and their corresponding types - headers = [ ['test.html', 'text/html'], ['test.css', 'text/css'], + headers = [ + ['test.html', 'text/html'], ['test.css', 'text/css'], ['test.js', 'application/javascript'], ['test.jpg', 'image/jpeg'], ['test.gif', 'image/gif'], ['test.ico', 'image/x-icon'], ['test.png', 'image/png'], ['test.whatever', 'text/plain'], @@ -142,7 +143,7 @@ class TestRouter(TestCase, TestMixin): # THEN: it should return a 404 self.router.send_response.assert_called_once_with(404) - self.router.send_header.assert_called_once_with('Content-type','text/html') + self.router.send_header.assert_called_once_with('Content-type', 'text/html') self.assertEqual(self.router.end_headers.call_count, 1, 'end_headers called once') def serve_file_with_valid_params_test(self): diff --git a/tests/functional/openlp_plugins/songs/test_ewimport.py b/tests/functional/openlp_plugins/songs/test_ewimport.py index f98ba57d2..9e327517c 100644 --- a/tests/functional/openlp_plugins/songs/test_ewimport.py +++ b/tests/functional/openlp_plugins/songs/test_ewimport.py @@ -41,33 +41,33 @@ TEST_PATH = os.path.abspath( os.path.join(os.path.dirname(__file__), '..', '..', '..', 'resources', 'easyworshipsongs')) SONG_TEST_DATA = [ {'title': 'Amazing Grace', - 'authors': ['John Newton'], - 'copyright': 'Public Domain', - 'ccli_number': 0, - 'verses': - [('Amazing grace how sweet the sound,\nThat saved a wretch like me;\n' - 'I once was lost, but now am found\nWas blind, but now I see.', 'v1'), - ('T\'was grace that taught my heart to fear,\nAnd grace my fears relieved;\n' - 'How precious did that grace appear\nThe hour I first believed.', 'v2'), - ('Through many dangers, toil and snares,\nI have already come;\n' - '\'Tis grace has brought me safe thus far,\nAnd grace will lead me home.', 'v3'), - ('When we\'ve been there ten thousand years\nBright shining as the sun,\n' - 'We\'ve no less days to sing God\'s praise\nThan when we\'ve first begun.', 'v4')], - 'verse_order_list': []}, + 'authors': ['John Newton'], + 'copyright': 'Public Domain', + 'ccli_number': 0, + 'verses': + [('Amazing grace how sweet the sound,\nThat saved a wretch like me;\n' + 'I once was lost, but now am found\nWas blind, but now I see.', 'v1'), + ('T\'was grace that taught my heart to fear,\nAnd grace my fears relieved;\n' + 'How precious did that grace appear\nThe hour I first believed.', 'v2'), + ('Through many dangers, toil and snares,\nI have already come;\n' + '\'Tis grace has brought me safe thus far,\nAnd grace will lead me home.', 'v3'), + ('When we\'ve been there ten thousand years\nBright shining as the sun,\n' + 'We\'ve no less days to sing God\'s praise\nThan when we\'ve first begun.', 'v4')], + 'verse_order_list': []}, {'title': 'Beautiful Garden Of Prayer', - 'authors': ['Eleanor Allen Schroll James H. Fillmore'], - 'copyright': 'Public Domain', - 'ccli_number': 0, - 'verses': - [('O the beautiful garden, the garden of prayer,\nO the beautiful garden of prayer.\n' - 'There my Savior awaits, and He opens the gates\nTo the beautiful garden of prayer.', 'c1'), - ('There\'s a garden where Jesus is waiting,\nThere\'s a place that is wondrously fair.\n' - 'For it glows with the light of His presence,\n\'Tis the beautiful garden of prayer.', 'v1'), - ('There\'s a garden where Jesus is waiting,\nAnd I go with my burden and care.\n' - 'Just to learn from His lips, words of comfort,\nIn the beautiful garden of prayer.', 'v2'), - ('There\'s a garden where Jesus is waiting,\nAnd He bids you to come meet Him there,\n' - 'Just to bow and receive a new blessing,\nIn the beautiful garden of prayer.', 'v3')], - 'verse_order_list': []}] + 'authors': ['Eleanor Allen Schroll James H. Fillmore'], + 'copyright': 'Public Domain', + 'ccli_number': 0, + 'verses': + [('O the beautiful garden, the garden of prayer,\nO the beautiful garden of prayer.\n' + 'There my Savior awaits, and He opens the gates\nTo the beautiful garden of prayer.', 'c1'), + ('There\'s a garden where Jesus is waiting,\nThere\'s a place that is wondrously fair.\n' + 'For it glows with the light of His presence,\n\'Tis the beautiful garden of prayer.', 'v1'), + ('There\'s a garden where Jesus is waiting,\nAnd I go with my burden and care.\n' + 'Just to learn from His lips, words of comfort,\nIn the beautiful garden of prayer.', 'v2'), + ('There\'s a garden where Jesus is waiting,\nAnd He bids you to come meet Him there,\n' + 'Just to bow and receive a new blessing,\nIn the beautiful garden of prayer.', 'v3')], + 'verse_order_list': []}] class EasyWorshipSongImportLogger(EasyWorshipSongImport): @@ -95,26 +95,32 @@ class TestFieldDesc: self.size = size TEST_DATA_ENCODING = 'cp1252' -CODE_PAGE_MAPPINGS = [(852, 'cp1250'), (737, 'cp1253'), (775, 'cp1257'), (855, 'cp1251'), (857, 'cp1254'), +CODE_PAGE_MAPPINGS = [ + (852, 'cp1250'), (737, 'cp1253'), (775, 'cp1257'), (855, 'cp1251'), (857, 'cp1254'), (866, 'cp1251'), (869, 'cp1253'), (862, 'cp1255'), (874, 'cp874')] -TEST_FIELD_DESCS = [TestFieldDesc('Title', FieldType.String, 50), +TEST_FIELD_DESCS = [ + TestFieldDesc('Title', FieldType.String, 50), TestFieldDesc('Text Percentage Bottom', FieldType.Int16, 2), TestFieldDesc('RecID', FieldType.Int32, 4), TestFieldDesc('Default Background', FieldType.Logical, 1), TestFieldDesc('Words', FieldType.Memo, 250), TestFieldDesc('Words', FieldType.Memo, 250), TestFieldDesc('BK Bitmap', FieldType.Blob, 10), TestFieldDesc('Last Modified', FieldType.Timestamp, 10)] -TEST_FIELDS = [b'A Heart Like Thine\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0', 32868, 2147483750, +TEST_FIELDS = [ + b'A Heart Like Thine\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0', 32868, 2147483750, 129, b'{\\rtf1\\ansi\\deff0\\deftab254{\\fonttbl{\\f0\\fnil\\fcharset0 Arial;}{\\f1\\fnil\\fcharset0 Verdana;}}' - b'{\\colortbl\\red0\\green0\\blue0;\\red255\\green0\\blue0;\\red0\\green128\\blue0;\\red0\\green0\\blue255;' - b'\\red255\\green255\\blue0;\\red255\\green0\\blue255;\\red128\\g\xBF\xBD\7\0f\r\0\0\1\0', - b'{\\rtf1\\ansi\\deff0\\deftab254{\\fonttbl{\\f0\\fnil\\fcharset0 Arial;}{\\f1\\fnil\\fcharset0 Verdana;}}' - b'{\\colortbl\\red0\\green0\\blue0;\\red255\\green0\\blue0;\\red0\\green128\\blue0;\\red0\\green0\\blue255;\\red255' - b'\\green255\\blue0;\\red255\\green0\\blue255;\\red128\\g\6\0\xEF\xBF\xBD\6\0\0\1\0', b'\0\0\0\0\0\0\0\0\0\0', 0] + b'{\\colortbl\\red0\\green0\\blue0;\\red255\\green0\\blue0;\\red0\\green128\\blue0;\\red0\\green0\\blue255;' + b'\\red255\\green255\\blue0;\\red255\\green0\\blue255;\\red128\\g\xBF\xBD\7\0f\r\0\0\1\0', + b'{\\rtf1\\ansi\\deff0\\deftab254{\\fonttbl{\\f0\\fnil\\fcharset0 Arial;}{\\f1\\fnil\\fcharset0 Verdana;}}' + b'{\\colortbl\\red0\\green0\\blue0;\\red255\\green0\\blue0;\\red0\\green128\\blue0;\\red0\\green0' + b'\\blue255;\\red255' + b'\\green255\\blue0;\\red255\\green0\\blue255;\\red128\\g\6\0\xEF\xBF\xBD\6\0\0\1\0', + b'\0\0\0\0\0\0\0\0\0\0', 0] GET_MEMO_FIELD_TEST_RESULTS = [ - (4, b'\2', {'return': b'\2','read': (1, 3430), 'seek': (507136, (8, os.SEEK_CUR))}), + (4, b'\2', {'return': b'\2', 'read': (1, 3430), 'seek': (507136, (8, os.SEEK_CUR))}), (4, b'\3', {'return': b'', 'read': (1, ), 'seek': (507136, )}), (5, b'\3', {'return': b'\3', 'read': (1, 1725), 'seek': (3220111360, (41, os.SEEK_CUR), 3220111408)}), (5, b'\4', {'return': b'', 'read': (), 'seek': ()})] + class TestEasyWorshipSongImport(TestCase): """ Test the functions in the :mod:`ewimport` module. @@ -135,7 +141,7 @@ class TestEasyWorshipSongImport(TestCase): self.assertIsNotNone(field_desc_entry, 'Import should not be none') self.assertEquals(field_desc_entry.name, name, 'FieldDescEntry.name should be the same as the name argument') self.assertEquals(field_desc_entry.field_type, field_type, - 'FieldDescEntry.type should be the same as the typeargument') + 'FieldDescEntry.type should be the same as the type argument') self.assertEquals(field_desc_entry.size, size, 'FieldDescEntry.size should be the same as the size argument') def create_importer_test(self): @@ -164,7 +170,7 @@ class TestEasyWorshipSongImport(TestCase): # WHEN: Called with a field name that exists existing_fields = ['Title', 'Text Percentage Bottom', 'RecID', 'Default Background', 'Words', - 'BK Bitmap', 'Last Modified'] + 'BK Bitmap', 'Last Modified'] for field_name in existing_fields: # THEN: The item corresponding the index returned should have the same name attribute @@ -194,7 +200,7 @@ class TestEasyWorshipSongImport(TestCase): # GIVEN: A mocked out SongImport class, a mocked out struct class, and a mocked out "manager" and a list of # field descriptions with patch('openlp.plugins.songs.lib.ewimport.SongImport'), \ - patch('openlp.plugins.songs.lib.ewimport.struct') as mocked_struct: + patch('openlp.plugins.songs.lib.ewimport.struct') as mocked_struct: mocked_manager = MagicMock() importer = EasyWorshipSongImport(mocked_manager, filenames=[]) @@ -225,7 +231,8 @@ class TestEasyWorshipSongImport(TestCase): # THEN: get_field should return the known results self.assertEquals(return_value, result, - 'get_field should return "%s" when called with "%s"' % (result, TEST_FIELDS[field_index])) + 'get_field should return "%s" when called with "%s"' % + (result, TEST_FIELDS[field_index])) def get_memo_field_test(self): """ @@ -265,7 +272,7 @@ class TestEasyWorshipSongImport(TestCase): """ # GIVEN: A mocked out SongImport class, a mocked out "manager" with patch('openlp.plugins.songs.lib.ewimport.SongImport'), \ - patch('openlp.plugins.songs.lib.ewimport.os.path') as mocked_os_path: + patch('openlp.plugins.songs.lib.ewimport.os.path') as mocked_os_path: mocked_manager = MagicMock() importer = EasyWorshipSongImport(mocked_manager, filenames=[]) mocked_os_path.isfile.side_effect = [True, False] @@ -284,7 +291,7 @@ class TestEasyWorshipSongImport(TestCase): """ # GIVEN: A mocked out SongImport class, os.path and a mocked out "manager" with patch('openlp.plugins.songs.lib.ewimport.SongImport'), \ - patch('openlp.plugins.songs.lib.ewimport.os.path') as mocked_os_path: + patch('openlp.plugins.songs.lib.ewimport.os.path') as mocked_os_path: mocked_manager = MagicMock() importer = EasyWorshipSongImport(mocked_manager, filenames=[]) mocked_os_path.isfile.return_value = True @@ -305,7 +312,7 @@ class TestEasyWorshipSongImport(TestCase): with patch('openlp.plugins.songs.lib.ewimport.SongImport'), \ patch('openlp.plugins.songs.lib.ewimport.os.path') as mocked_os_path, \ patch('builtins.open') as mocked_open, \ - patch('openlp.plugins.songs.lib.ewimport.struct') as mocked_struct: + patch('openlp.plugins.songs.lib.ewimport.struct') as mocked_struct: mocked_manager = MagicMock() importer = EasyWorshipSongImport(mocked_manager, filenames=[]) mocked_os_path.isfile.return_value = True @@ -320,7 +327,7 @@ class TestEasyWorshipSongImport(TestCase): for effect in struct_unpack_return_values: self.assertIsNone(importer.do_import(), 'do_import should return None when db_size is less than 0x800') self.assertEqual(mocked_open().close.call_count, 2, - 'The open db and memo files should have been closed') + 'The open db and memo files should have been closed') mocked_open().close.reset_mock() self.assertIs(mocked_open().seek.called, False, 'db_file.seek should not have been called.') @@ -332,7 +339,8 @@ class TestEasyWorshipSongImport(TestCase): with patch('openlp.plugins.songs.lib.ewimport.SongImport'), \ patch('openlp.plugins.songs.lib.ewimport.os.path') as mocked_os_path, \ patch('builtins.open'), patch('openlp.plugins.songs.lib.ewimport.struct') as mocked_struct, \ - patch('openlp.plugins.songs.lib.ewimport.retrieve_windows_encoding') as mocked_retrieve_windows_encoding: + patch('openlp.plugins.songs.lib.ewimport.retrieve_windows_encoding') as \ + mocked_retrieve_windows_encoding: mocked_manager = MagicMock() importer = EasyWorshipSongImport(mocked_manager, filenames=[]) mocked_os_path.isfile.return_value = True @@ -357,7 +365,8 @@ class TestEasyWorshipSongImport(TestCase): # GIVEN: Test files with a mocked out SongImport class, a mocked out "manager", a mocked out "import_wizard", # and mocked out "author", "add_copyright", "add_verse", "finish" methods. with patch('openlp.plugins.songs.lib.ewimport.SongImport'), \ - patch('openlp.plugins.songs.lib.ewimport.retrieve_windows_encoding') as mocked_retrieve_windows_encoding: + patch('openlp.plugins.songs.lib.ewimport.retrieve_windows_encoding') as \ + mocked_retrieve_windows_encoding: mocked_retrieve_windows_encoding.return_value = 'cp1252' mocked_manager = MagicMock() mocked_import_wizard = MagicMock() @@ -395,10 +404,10 @@ class TestEasyWorshipSongImport(TestCase): self.assertEqual(importer.copyright, song_copyright) if ccli_number: self.assertEquals(importer.ccli_number, ccli_number, 'ccli_number for %s should be %s' - % (title, ccli_number)) + % (title, ccli_number)) for verse_text, verse_tag in add_verse_calls: mocked_add_verse.assert_any_call(verse_text, verse_tag) if verse_order_list: - self.assertEquals(importer.verse_order_list, verse_order_list, 'verse_order_list for %s should be %s' - % (title, verse_order_list)) + self.assertEquals(importer.verse_order_list, verse_order_list, + 'verse_order_list for %s should be %s' % (title, verse_order_list)) mocked_finish.assert_called_with() diff --git a/tests/functional/openlp_plugins/songs/test_lib.py b/tests/functional/openlp_plugins/songs/test_lib.py index beff6d0d5..f6e5d98b9 100644 --- a/tests/functional/openlp_plugins/songs/test_lib.py +++ b/tests/functional/openlp_plugins/songs/test_lib.py @@ -44,20 +44,20 @@ class TestLib(TestCase): """ Mock up two songs and provide a set of lyrics for the songs_probably_equal tests. """ - self.full_lyrics ='''amazing grace how sweet the sound that saved a wretch like me i once was lost but now am + self.full_lyrics = '''amazing grace how sweet the sound that saved a wretch like me i once was lost but now am found was blind but now i see twas grace that taught my heart to fear and grace my fears relieved how - precious did that grace appear the hour i first believed through many dangers toils and snares i have already - come tis grace that brought me safe thus far and grace will lead me home''' - self.short_lyrics ='''twas grace that taught my heart to fear and grace my fears relieved how precious did that - grace appear the hour i first believed''' - self.error_lyrics ='''amazing how sweet the trumpet that saved a wrench like me i once was losst but now am + precious did that grace appear the hour i first believed through many dangers toils and snares i have + already come tis grace that brought me safe thus far and grace will lead me home''' + self.short_lyrics = '''twas grace that taught my heart to fear and grace my fears relieved how precious did + that grace appear the hour i first believed''' + self.error_lyrics = '''amazing how sweet the trumpet that saved a wrench like me i once was losst but now am found waf blind but now i see it was grace that taught my heart to fear and grace my fears relieved how precious did that grace appppppppear the hour i first believedxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx snares i have already come to this grace that brought me safe so far and grace will lead me home''' - self.different_lyrics='''on a hill far away stood an old rugged cross the emblem of suffering and shame and i love - that old cross where the dearest and best for a world of lost sinners was slain so ill cherish the old rugged - cross till my trophies at last i lay down i will cling to the old rugged cross and exchange it some day for a - crown''' + self.different_lyrics = '''on a hill far away stood an old rugged cross the emblem of suffering and shame and + i love that old cross where the dearest and best for a world of lost sinners was slain so ill cherish the + old rugged cross till my trophies at last i lay down i will cling to the old rugged cross and exchange it + some day for a crown''' self.song1 = MagicMock() self.song2 = MagicMock() @@ -99,7 +99,7 @@ class TestLib(TestCase): result = songs_probably_equal(self.song1, self.song2) # THEN: The result should be True. - assert result == True, 'The result should be True' + assert result is True, 'The result should be True' def songs_probably_equal_short_song_test(self): """ @@ -113,7 +113,7 @@ class TestLib(TestCase): result = songs_probably_equal(self.song1, self.song2) # THEN: The result should be True. - assert result == True, 'The result should be True' + assert result is True, 'The result should be True' def songs_probably_equal_error_song_test(self): """ @@ -127,7 +127,7 @@ class TestLib(TestCase): result = songs_probably_equal(self.song1, self.song2) # THEN: The result should be True. - assert result == True, 'The result should be True' + assert result is True, 'The result should be True' def songs_probably_equal_different_song_test(self): """ @@ -141,7 +141,7 @@ class TestLib(TestCase): result = songs_probably_equal(self.song1, self.song2) # THEN: The result should be False. - assert result == False, 'The result should be False' + assert result is False, 'The result should be False' def remove_typos_beginning_test(self): """ @@ -267,8 +267,8 @@ class TestLib(TestCase): # WHEN: We call strip_rtf on the input RTF result, result_enc = strip_rtf( - '{\\rtf1 \\ansi \\ansicpg1252 {\\fonttbl \\f0 \\fswiss \\fcharset%s Helvetica;}' \ - '{\\colortbl ;\\red0 \\green0 \\blue0 ;}\\pard \\f0 %s}' % (charset, input)) + '{\\rtf1 \\ansi \\ansicpg1252 {\\fonttbl \\f0 \\fswiss \\fcharset%s Helvetica;}' + '{\\colortbl ;\\red0 \\green0 \\blue0 ;}\\pard \\f0 %s}' % (charset, input)) # THEN: The stripped text matches thed expected result assert result == exp_result, 'The result should be %s' % exp_result diff --git a/tests/functional/openlp_plugins/songs/test_songbeamerimport.py b/tests/functional/openlp_plugins/songs/test_songbeamerimport.py index a968975b3..e7bd891d3 100644 --- a/tests/functional/openlp_plugins/songs/test_songbeamerimport.py +++ b/tests/functional/openlp_plugins/songs/test_songbeamerimport.py @@ -110,7 +110,7 @@ class TestSongBeamerImport(TestCase): # THEN: do_import should return none and the progress bar setMaximum should be called with the length of # import_source. self.assertIsNone(importer.do_import(), - 'do_import should return None when import_source is a list and stop_import_flag is True') + 'do_import should return None when import_source is a list and stop_import_flag is True') mocked_import_wizard.progress_bar.setMaximum.assert_called_with(len(importer.import_source)) def file_import_test(self): @@ -147,9 +147,9 @@ class TestSongBeamerImport(TestCase): for verse_text, verse_tag in add_verse_calls: mocked_add_verse.assert_any_call(verse_text, verse_tag) if song_book_name: - self.assertEquals(importer.song_book_name, song_book_name, 'song_book_name for %s should be "%s"' - % (song_file, song_book_name)) + self.assertEquals(importer.song_book_name, song_book_name, 'song_book_name for %s should be "%s"' % + (song_file, song_book_name)) if song_number: - self.assertEquals(importer.song_number, song_number, 'song_number for %s should be %s' - % (song_file, song_number)) + self.assertEquals(importer.song_number, song_number, 'song_number for %s should be %s' % + (song_file, song_number)) mocked_finish.assert_called_with() diff --git a/tests/functional/openlp_plugins/songs/test_songselect.py b/tests/functional/openlp_plugins/songs/test_songselect.py index 0b32cff95..8d1237190 100644 --- a/tests/functional/openlp_plugins/songs/test_songselect.py +++ b/tests/functional/openlp_plugins/songs/test_songselect.py @@ -352,7 +352,7 @@ class TestSongSelect(TestCase): """ # GIVEN: A song to save, and some mocked out objects with patch('openlp.plugins.songs.lib.songselect.clean_song') as mocked_clean_song, \ - patch('openlp.plugins.songs.lib.songselect.Author') as MockedAuthor: + patch('openlp.plugins.songs.lib.songselect.Author') as MockedAuthor: song_dict = { 'title': 'Arky Arky', 'authors': ['Public Domain'], diff --git a/tests/functional/openlp_plugins/songs/test_songshowplusimport.py b/tests/functional/openlp_plugins/songs/test_songshowplusimport.py index f3fe231d0..7876558e9 100644 --- a/tests/functional/openlp_plugins/songs/test_songshowplusimport.py +++ b/tests/functional/openlp_plugins/songs/test_songshowplusimport.py @@ -129,7 +129,8 @@ class TestSongShowPlusImport(TestCase): importer = SongShowPlusImport(mocked_manager, filenames=[]) # WHEN: Supplied with the following arguments replicating verses being added - test_values = [('Verse 1', VerseType.tags[VerseType.Verse] + '1'), + test_values = [ + ('Verse 1', VerseType.tags[VerseType.Verse] + '1'), ('Verse 2', VerseType.tags[VerseType.Verse] + '2'), ('verse1', VerseType.tags[VerseType.Verse] + '1'), ('Verse', VerseType.tags[VerseType.Verse] + '1'), @@ -156,7 +157,8 @@ class TestSongShowPlusImport(TestCase): importer = SongShowPlusImport(mocked_manager, filenames=[]) # WHEN: Supplied with the following arguments replicating a verse order being added - test_values = [('Verse 1', VerseType.tags[VerseType.Verse] + '1'), + test_values = [ + ('Verse 1', VerseType.tags[VerseType.Verse] + '1'), ('Verse 2', VerseType.tags[VerseType.Verse] + '2'), ('verse1', VerseType.tags[VerseType.Verse] + '1'), ('Verse', VerseType.tags[VerseType.Verse] + '1'), diff --git a/tests/functional/openlp_plugins/songs/test_worshipcenterproimport.py b/tests/functional/openlp_plugins/songs/test_worshipcenterproimport.py index c6acbe965..9a58a6c2b 100644 --- a/tests/functional/openlp_plugins/songs/test_worshipcenterproimport.py +++ b/tests/functional/openlp_plugins/songs/test_worshipcenterproimport.py @@ -204,8 +204,8 @@ class TestWorshipCenterProSongImport(TestCase): # WHEN: Calling the do_import method return_value = importer.do_import() - # THEN: do_import should return None, and pyodbc, import_wizard, importer.title and add_verse are called with - # known calls + # THEN: do_import should return None, and pyodbc, import_wizard, importer.title and add_verse are called + # with known calls self.assertIsNone(return_value, 'do_import should return None when pyodbc raises an exception.') mocked_pyodbc.connect.assert_called_with('DRIVER={Microsoft Access Driver (*.mdb)};DBQ=import_source') mocked_pyodbc.connect().cursor.assert_any_call() diff --git a/tests/helpers/songfileimport.py b/tests/helpers/songfileimport.py index 12754f55a..cc67770c1 100644 --- a/tests/helpers/songfileimport.py +++ b/tests/helpers/songfileimport.py @@ -116,28 +116,27 @@ class SongImportTestHelper(TestCase): if song_copyright: self.mocked_add_copyright.assert_called_with(song_copyright) if ccli_number: - self.assertEquals(importer.ccli_number, ccli_number, 'ccli_number for %s should be %s' - % (source_file_name, ccli_number)) + self.assertEquals(importer.ccli_number, ccli_number, 'ccli_number for %s should be %s' % + (source_file_name, ccli_number)) for verse_text, verse_tag in add_verse_calls: self.mocked_add_verse.assert_any_call(verse_text, verse_tag) if topics: self.assertEquals(importer.topics, topics, 'topics for %s should be %s' % (source_file_name, topics)) if comments: - self.assertEquals(importer.comments, comments, 'comments for %s should be "%s"' - % (source_file_name, comments)) + self.assertEquals(importer.comments, comments, 'comments for %s should be "%s"' % + (source_file_name, comments)) if song_book_name: - self.assertEquals(importer.song_book_name, song_book_name, 'song_book_name for %s should be "%s"' - % (source_file_name, song_book_name)) + self.assertEquals(importer.song_book_name, song_book_name, 'song_book_name for %s should be "%s"' % + (source_file_name, song_book_name)) if song_number: - self.assertEquals(importer.song_number, song_number, 'song_number for %s should be %s' - % (source_file_name, song_number)) + self.assertEquals(importer.song_number, song_number, 'song_number for %s should be %s' % + (source_file_name, song_number)) if verse_order_list: - self.assertEquals(importer.verse_order_list, [], 'verse_order_list for %s should be %s' - % (source_file_name, verse_order_list)) + self.assertEquals(importer.verse_order_list, [], 'verse_order_list for %s should be %s' % + (source_file_name, verse_order_list)) self.mocked_finish.assert_called_with() def _get_data(self, data, key): if key in data: return data[key] return '' - diff --git a/tests/interfaces/openlp_core_lib/test_pluginmanager.py b/tests/interfaces/openlp_core_lib/test_pluginmanager.py index 054aa6dc1..262f9f2f3 100644 --- a/tests/interfaces/openlp_core_lib/test_pluginmanager.py +++ b/tests/interfaces/openlp_core_lib/test_pluginmanager.py @@ -95,4 +95,3 @@ class TestPluginManager(TestCase, TestMixin): assert 'songusage' in plugin_names, 'There should be a "songusage" plugin.' assert 'alerts' in plugin_names, 'There should be a "alerts" plugin.' assert 'remotes' in plugin_names, 'There should be a "remotes" plugin.' - diff --git a/tests/interfaces/openlp_core_lib/test_searchedit.py b/tests/interfaces/openlp_core_lib/test_searchedit.py index 98c942885..22bf6fae3 100644 --- a/tests/interfaces/openlp_core_lib/test_searchedit.py +++ b/tests/interfaces/openlp_core_lib/test_searchedit.py @@ -133,5 +133,3 @@ class TestSearchEdit(TestCase, TestMixin): Just check if the resizeEvent() method is re-implemented. """ assert hasattr(self.search_edit, "resizeEvent"), "The search edit should re-implement the resizeEvent method." - - \ No newline at end of file diff --git a/tests/interfaces/openlp_core_ui/test_mainwindow.py b/tests/interfaces/openlp_core_ui/test_mainwindow.py index de5452632..b79036547 100644 --- a/tests/interfaces/openlp_core_ui/test_mainwindow.py +++ b/tests/interfaces/openlp_core_ui/test_mainwindow.py @@ -85,4 +85,3 @@ class TestMainWindow(TestCase, TestMixin): # THEN: The current widget should have been set. self.main_window.media_tool_box.setCurrentIndex.assert_called_with(2) - diff --git a/tests/interfaces/openlp_core_ui/test_servicenotedialog.py b/tests/interfaces/openlp_core_ui/test_servicenotedialog.py index 7344dc633..86fc425c1 100644 --- a/tests/interfaces/openlp_core_ui/test_servicenotedialog.py +++ b/tests/interfaces/openlp_core_ui/test_servicenotedialog.py @@ -90,9 +90,8 @@ class TestStartNoteDialog(TestCase, TestMixin): with patch('PyQt4.QtGui.QDialog.exec_'): self.form.exec_() self.form.text_edit.setPlainText(text) - okWidget = self.form.button_box.button(self.form.button_box.Save) - QtTest.QTest.mouseClick(okWidget, QtCore.Qt.LeftButton) + ok_widget = self.form.button_box.button(self.form.button_box.Save) + QtTest.QTest.mouseClick(ok_widget, QtCore.Qt.LeftButton) # THEN the following text is returned self.assertEqual(self.form.text_edit.toPlainText(), text, 'The new text should be returned') - diff --git a/tests/interfaces/openlp_core_utils/test_utils.py b/tests/interfaces/openlp_core_utils/test_utils.py index 3c3879b34..3da1db2e2 100644 --- a/tests/interfaces/openlp_core_utils/test_utils.py +++ b/tests/interfaces/openlp_core_utils/test_utils.py @@ -86,4 +86,3 @@ class TestUtils(TestCase, TestMixin): # THEN the result is false assert result is True, 'The file is not an image file so the test should return True' - diff --git a/tests/interfaces/openlp_plugins/bibles/test_lib_http.py b/tests/interfaces/openlp_plugins/bibles/test_lib_http.py index 9f90df64e..517732e4d 100644 --- a/tests/interfaces/openlp_plugins/bibles/test_lib_http.py +++ b/tests/interfaces/openlp_plugins/bibles/test_lib_http.py @@ -97,4 +97,3 @@ class TestBibleHTTP(TestCase): # THEN: We should get back a valid service item assert len(results.verse_list) == 36, 'The book of John should not have had any verses added or removed' - diff --git a/tests/interfaces/openlp_plugins/bibles/test_lib_manager.py b/tests/interfaces/openlp_plugins/bibles/test_lib_manager.py index b00bbee00..7296cfc08 100644 --- a/tests/interfaces/openlp_plugins/bibles/test_lib_manager.py +++ b/tests/interfaces/openlp_plugins/bibles/test_lib_manager.py @@ -115,4 +115,3 @@ class TestBibleManager(TestCase, TestMixin): verses = self.manager.get_verse_count_by_book_ref_id('tests', 54, 3) # THEN the chapter count should be returned self.assertEqual(16, verses, '1 Timothy v3 should have 16 verses returned from the bible') - diff --git a/tests/interfaces/openlp_plugins/bibles/test_lib_parse_reference.py b/tests/interfaces/openlp_plugins/bibles/test_lib_parse_reference.py index 811d048db..b085bd1df 100644 --- a/tests/interfaces/openlp_plugins/bibles/test_lib_parse_reference.py +++ b/tests/interfaces/openlp_plugins/bibles/test_lib_parse_reference.py @@ -83,7 +83,7 @@ class TestBibleManager(TestCase, TestMixin): # WHEN asking to parse the bible reference results = parse_reference('1 Timothy 1', self.manager.db_cache['tests'], MagicMock(), 54) # THEN a verse array should be returned - self.assertEquals([(54, 1, 1, -1)], results , "The bible verses should matches the expected results") + self.assertEquals([(54, 1, 1, -1)], results, "The bible verses should matches the expected results") def parse_reference_two_test(self): """ @@ -93,7 +93,7 @@ class TestBibleManager(TestCase, TestMixin): # WHEN asking to parse the bible reference results = parse_reference('1 Timothy 1:1-2', self.manager.db_cache['tests'], MagicMock(), 54) # THEN a verse array should be returned - self.assertEquals([(54, 1, 1, 2)], results , "The bible verses should matches the expected results") + self.assertEquals([(54, 1, 1, 2)], results, "The bible verses should matches the expected results") def parse_reference_three_test(self): """ @@ -103,4 +103,5 @@ class TestBibleManager(TestCase, TestMixin): # WHEN asking to parse the bible reference results = parse_reference('1 Timothy 1:1-2:1', self.manager.db_cache['tests'], MagicMock(), 54) # THEN a verse array should be returned - self.assertEquals([(54,1,1,-1),(54,2,1,1)], results , "The bible verses should matches the expected results") \ No newline at end of file + self.assertEquals([(54, 1, 1, -1), (54, 2, 1, 1)], results, "The bible verses should matches the expected " + "results") diff --git a/tests/interfaces/openlp_plugins/custom/__init__.py b/tests/interfaces/openlp_plugins/custom/__init__.py index 4c8c00fec..6b241e7fc 100644 --- a/tests/interfaces/openlp_plugins/custom/__init__.py +++ b/tests/interfaces/openlp_plugins/custom/__init__.py @@ -26,4 +26,3 @@ # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### - diff --git a/tests/interfaces/openlp_plugins/custom/forms/__init__.py b/tests/interfaces/openlp_plugins/custom/forms/__init__.py index 1f4f74a33..6b241e7fc 100644 --- a/tests/interfaces/openlp_plugins/custom/forms/__init__.py +++ b/tests/interfaces/openlp_plugins/custom/forms/__init__.py @@ -25,4 +25,4 @@ # 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 # -############################################################################### \ No newline at end of file +############################################################################### diff --git a/tests/interfaces/openlp_plugins/custom/forms/test_customform.py b/tests/interfaces/openlp_plugins/custom/forms/test_customform.py index 93b271797..ca238b1a6 100644 --- a/tests/interfaces/openlp_plugins/custom/forms/test_customform.py +++ b/tests/interfaces/openlp_plugins/custom/forms/test_customform.py @@ -88,7 +88,6 @@ class TestEditCustomForm(TestCase, TestMixin): self.assertEqual(self.form.title_edit.text(), '', 'The title edit should be empty') self.assertEqual(self.form.credit_edit.text(), '', 'The credit edit should be empty') - def on_add_button_clicked_test(self): """ Test the on_add_button_clicked_test method / add_button button. diff --git a/tests/interfaces/openlp_plugins/custom/forms/test_customslideform.py b/tests/interfaces/openlp_plugins/custom/forms/test_customslideform.py index a2bfb1f10..261519362 100644 --- a/tests/interfaces/openlp_plugins/custom/forms/test_customslideform.py +++ b/tests/interfaces/openlp_plugins/custom/forms/test_customslideform.py @@ -92,4 +92,3 @@ class TestEditCustomSlideForm(TestCase, TestMixin): # THEN: The dialog should have focus. mocked_set_focus.assert_called_with() - diff --git a/tests/interfaces/openlp_plugins/songs/forms/__init__.py b/tests/interfaces/openlp_plugins/songs/forms/__init__.py index 1f4f74a33..6b241e7fc 100644 --- a/tests/interfaces/openlp_plugins/songs/forms/__init__.py +++ b/tests/interfaces/openlp_plugins/songs/forms/__init__.py @@ -25,4 +25,4 @@ # 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 # -############################################################################### \ No newline at end of file +############################################################################### diff --git a/tests/interfaces/openlp_plugins/songs/forms/test_authorsform.py b/tests/interfaces/openlp_plugins/songs/forms/test_authorsform.py index 5d965c042..2257bbc84 100644 --- a/tests/interfaces/openlp_plugins/songs/forms/test_authorsform.py +++ b/tests/interfaces/openlp_plugins/songs/forms/test_authorsform.py @@ -145,4 +145,3 @@ class TestAuthorsForm(TestCase, TestMixin): # THEN: The display_name_edit should have the correct value self.assertEqual(self.form.display_edit.text(), display_name, 'The display name should be set correctly') - diff --git a/tests/interfaces/openlp_plugins/songs/forms/test_editverseform.py b/tests/interfaces/openlp_plugins/songs/forms/test_editverseform.py index 284d850c4..178b1cd7c 100644 --- a/tests/interfaces/openlp_plugins/songs/forms/test_editverseform.py +++ b/tests/interfaces/openlp_plugins/songs/forms/test_editverseform.py @@ -120,4 +120,3 @@ class TestEditVerseForm(TestCase, TestMixin): # THEN: The verse text edit should have a Chorus:1 in it self.assertIn('---[Chorus:1]---', self.form.verse_text_edit.toPlainText(), 'The verse text edit should have a "Chorus 1" marker') - From bc55bcd7fa7719cf212c001ad5256986bab0935f Mon Sep 17 00:00:00 2001 From: Jonathan Springer Date: Thu, 3 Apr 2014 08:38:39 -0400 Subject: [PATCH 41/51] Fix argurment to pass correct type. --- openlp/core/utils/languagemanager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/utils/languagemanager.py b/openlp/core/utils/languagemanager.py index cd5ce7add..bb584f7bd 100644 --- a/openlp/core/utils/languagemanager.py +++ b/openlp/core/utils/languagemanager.py @@ -74,7 +74,7 @@ class LanguageManager(object): log.debug('Translation files: %s', AppLocation.get_directory( AppLocation.LanguageDir)) trans_dir = QtCore.QDir(AppLocation.get_directory(AppLocation.LanguageDir)) - file_names = trans_dir.entryList('*.qm', QtCore.QDir.Files, QtCore.QDir.Name) + file_names = trans_dir.entryList(['*.qm'], QtCore.QDir.Files, QtCore.QDir.Name) # Remove qm files from the list which start with "qt_". file_names = [file_ for file_ in file_names if not file_.startswith('qt_')] return list(map(trans_dir.filePath, file_names)) From 7ef62293f3392e9fd714c0cbb7466e975ff54e54 Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Thu, 3 Apr 2014 22:22:10 +0200 Subject: [PATCH 42/51] Added test --- .../presentations/test_pdfcontroller.py | 51 ++++++++++++++++--- 1 file changed, 44 insertions(+), 7 deletions(-) diff --git a/tests/functional/openlp_plugins/presentations/test_pdfcontroller.py b/tests/functional/openlp_plugins/presentations/test_pdfcontroller.py index 65c7bf916..b1e356249 100644 --- a/tests/functional/openlp_plugins/presentations/test_pdfcontroller.py +++ b/tests/functional/openlp_plugins/presentations/test_pdfcontroller.py @@ -33,6 +33,7 @@ import os import shutil from unittest import TestCase, SkipTest from tempfile import mkdtemp +from PyQt4 import QtCore, QtGui from openlp.plugins.presentations.lib.pdfcontroller import PdfController, PdfDocument from tests.functional import MagicMock @@ -45,6 +46,11 @@ __default_settings__ = { 'presentations/enable_pdf_program': False } +SCREEN = { + 'primary': False, + 'number': 1, + 'size': QtCore.QRect(0, 0, 1024, 768) +} class TestPdfController(TestCase, TestMixin): """ @@ -56,7 +62,12 @@ class TestPdfController(TestCase, TestMixin): """ self.get_application() self.build_settings() - ScreenList.create(self.app.desktop()) + # Mocked out desktop object + self.desktop = MagicMock() + self.desktop.primaryScreen.return_value = SCREEN['primary'] + self.desktop.screenCount.return_value = SCREEN['number'] + self.desktop.screenGeometry.return_value = SCREEN['size'] + self.screens = ScreenList.create(self.desktop) Settings().extend_default_settings(__default_settings__) self.temp_folder = mkdtemp() self.thumbnail_folder = mkdtemp() @@ -67,12 +78,11 @@ class TestPdfController(TestCase, TestMixin): """ Delete all the C++ objects at the end so that we don't have a segfault """ - try: - self.destroy_settings() - shutil.rmtree(self.thumbnail_folder) - shutil.rmtree(self.temp_folder) - except OSError: - pass + del self.screens + self.destroy_settings() + shutil.rmtree(self.thumbnail_folder) + shutil.rmtree(self.temp_folder) + def constructor_test(self): """ @@ -106,3 +116,30 @@ class TestPdfController(TestCase, TestMixin): # THEN: The load should succeed and we should be able to get a pagecount self.assertTrue(loaded, 'The loading of the PDF should succeed.') self.assertEqual(3, document.get_slide_count(), 'The pagecount of the PDF should be 3.') + + def load_pdf_pictures_test(self): + """ + Test loading of a Pdf and check size of generate pictures + """ + # GIVEN: A Pdf-file + test_file = os.path.join(TEST_RESOURCES_PATH, 'presentations', 'pdf_test1.pdf') + + # WHEN: The Pdf is loaded + controller = PdfController(plugin=self.mock_plugin) + if not controller.check_available(): + raise SkipTest('Could not detect mudraw or ghostscript, so skipping PDF test') + controller.temp_folder = self.temp_folder + controller.thumbnail_folder = self.thumbnail_folder + document = PdfDocument(controller, test_file) + loaded = document.load_presentation() + + # THEN: The load should succeed and pictures should be created and have been scales to fit the screen + self.assertTrue(loaded, 'The loading of the PDF should succeed.') + image = QtGui.QImage(os.path.join(self.temp_folder, 'pdf_test1.pdf', 'mainslide001.png')) + # Based on the converter used the resolution will differ a bit + if controller.gsbin: + self.assertEqual(760, image.height(), 'The height should be 760') + self.assertEqual(537, image.width(), 'The width should be 537') + else: + self.assertEqual(767, image.height(), 'The height should be 767') + self.assertEqual(543, image.width(), 'The width should be 543') From 576ab6e1f95e6469987a1fccdc7c26ac759064b1 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 4 Apr 2014 21:20:00 +0100 Subject: [PATCH 43/51] head --- openlp/core/common/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/common/__init__.py b/openlp/core/common/__init__.py index 8df86032e..8a8e6eef3 100644 --- a/openlp/core/common/__init__.py +++ b/openlp/core/common/__init__.py @@ -53,7 +53,7 @@ def trace_error_handler(logger): """ log_string = "OpenLP Error trace" for tb in traceback.extract_stack(): - log_string = ('%s\n File %s at line %d \n\t called %s' % (log_string, tb[0], tb[1], tb[3])) + log_string = '%s\n File %s at line %d \n\t called %s' % (log_string, tb[0], tb[1], tb[3]) logger.error(log_string) From 8813490badca58d8395b6ba1b654837852d16f60 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 4 Apr 2014 21:24:11 +0100 Subject: [PATCH 44/51] fix tests --- .../openlp_plugins/presentations/test_pdfcontroller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/functional/openlp_plugins/presentations/test_pdfcontroller.py b/tests/functional/openlp_plugins/presentations/test_pdfcontroller.py index b1e356249..277e83a5b 100644 --- a/tests/functional/openlp_plugins/presentations/test_pdfcontroller.py +++ b/tests/functional/openlp_plugins/presentations/test_pdfcontroller.py @@ -52,6 +52,7 @@ SCREEN = { 'size': QtCore.QRect(0, 0, 1024, 768) } + class TestPdfController(TestCase, TestMixin): """ Test the PdfController. @@ -83,7 +84,6 @@ class TestPdfController(TestCase, TestMixin): shutil.rmtree(self.thumbnail_folder) shutil.rmtree(self.temp_folder) - def constructor_test(self): """ Test the Constructor from the PdfController From e5d5af38c2f45b279f43a698b6c99ca22ba0609c Mon Sep 17 00:00:00 2001 From: Jonathan Springer Date: Sun, 6 Apr 2014 22:03:05 -0400 Subject: [PATCH 45/51] Move opening of files passed in via command line to function. --- openlp/core/ui/mainwindow.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index b14694ccc..b70192039 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -594,15 +594,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow, RegistryProperties): self.live_controller.display.setFocus() self.activateWindow() if self.arguments: - args = [] - for a in self.arguments: - args.extend([a]) - for arg in args: - filename = arg - if not isinstance(filename, str): - filename = str(filename, sys.getfilesystemencoding()) - if filename.endswith(('.osz', '.oszl', '.otz')): - self.service_manager_contents.load_file(filename) + self.open_cmd_line_files() elif Settings().value(self.general_settings_section + '/auto open'): self.service_manager_contents.load_Last_file() self.timer_version_id = self.startTimer(1000) @@ -1362,3 +1354,17 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow, RegistryProperties): if self.new_data_path == AppLocation.get_directory(AppLocation.DataDir): settings.remove('advanced/data path') self.application.set_normal_cursor() + + def open_cmd_line_files(self): + """ + Open files passed in through command line arguments + """ + args = [] + for a in self.arguments: + args.extend([a]) + for arg in args: + filename = arg + if not isinstance(filename, str): + filename = str(filename, sys.getfilesystemencoding()) + if filename.endswith(('.osz', '.oszl')): + self.service_manager_contents.load_file(filename) From 1945b4c380001d4b774986584b815c40ad14bd44 Mon Sep 17 00:00:00 2001 From: Jonathan Springer Date: Sun, 6 Apr 2014 22:07:19 -0400 Subject: [PATCH 46/51] Remove changes to platform specific code. --- openlp/core/ui/mainwindow.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index b70192039..d11fae767 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -322,8 +322,14 @@ class Ui_MainWindow(object): # i18n add Language Actions add_actions(self.settings_language_menu, (self.auto_language_item, None)) add_actions(self.settings_language_menu, self.language_group.actions()) - add_actions(self.settings_menu, (self.settings_plugin_list_item, self.settings_language_menu.menuAction(), - None, self.formatting_tag_item, self.settings_shortcuts_item, self.settings_configure_item)) + # Order things differently in OS X so that Preferences menu item in the + # app menu is correct (this gets picked up automatically by Qt). + if sys.platform == 'darwin': + add_actions(self.settings_menu, (self.settings_plugin_list_item, self.settings_language_menu.menuAction(), + None, self.settings_configure_item, self.settings_shortcuts_item, self.formatting_tag_item)) + else: + add_actions(self.settings_menu, (self.settings_plugin_list_item, self.settings_language_menu.menuAction(), + None, self.formatting_tag_item, self.settings_shortcuts_item, self.settings_configure_item)) add_actions(self.tools_menu, (self.tools_add_tool_item, None)) add_actions(self.tools_menu, (self.tools_open_data_folder, None)) add_actions(self.tools_menu, (self.tools_first_time_wizard, None)) @@ -387,10 +393,8 @@ class Ui_MainWindow(object): self.import_language_item.setText(translate('OpenLP.MainWindow', '&Language')) self.export_theme_item.setText(translate('OpenLP.MainWindow', '&Theme')) self.export_language_item.setText(translate('OpenLP.MainWindow', '&Language')) - # Do not use config, options, setup, settings or preferences in menu item name unless it is OpenLP's preferences. - # Qt automatically detects the Preferences entry for the Mac OS X menu based on the name of the menu item. - self.settings_shortcuts_item.setText(translate('OpenLP.MainWindow', '&Shortcuts...')) - self.formatting_tag_item.setText(translate('OpenLP.MainWindow', '&Formatting Tags...')) + self.settings_shortcuts_item.setText(translate('OpenLP.MainWindow', 'Configure &Shortcuts...')) + self.formatting_tag_item.setText(translate('OpenLP.MainWindow', 'Configure &Formatting Tags...')) self.settings_configure_item.setText(translate('OpenLP.MainWindow', '&Configure OpenLP...')) self.settings_export_item.setStatusTip(translate('OpenLP.MainWindow', 'Export OpenLP settings to a specified *.config file')) From 47767b02c1af747234ea19ee783bffcf76e520b4 Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Tue, 8 Apr 2014 22:41:33 +0200 Subject: [PATCH 47/51] Fix debug messages Fixes: https://launchpad.net/bugs/1170231 --- openlp/plugins/bibles/lib/db.py | 74 ++++++++++++++++----------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index 9ffa5d53e..f24005748 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -191,7 +191,7 @@ class BibleDB(QtCore.QObject, Manager, RegistryProperties): :param testament: *Defaults to 1.* The testament_reference_id from bibles_resources.sqlite of the testament this book belongs to. """ - log.debug('BibleDB.create_book("%s", "%s")', name, bk_ref_id) + log.debug('BibleDB.create_book("%s", "%s")' % (name, bk_ref_id)) book = Book.populate(name=name, book_reference_id=bk_ref_id, testament_reference_id=testament) self.save_object(book) return book @@ -202,7 +202,7 @@ class BibleDB(QtCore.QObject, Manager, RegistryProperties): :param book: The book object """ - log.debug('BibleDB.update_book("%s")', book.name) + log.debug('BibleDB.update_book("%s")' % book.name) return self.save_object(book) def delete_book(self, db_book): @@ -211,7 +211,7 @@ class BibleDB(QtCore.QObject, Manager, RegistryProperties): :param db_book: The book object. """ - log.debug('BibleDB.delete_book("%s")', db_book.name) + log.debug('BibleDB.delete_book("%s")' % db_book.name) if self.delete_object(Book, db_book.id): return True return False @@ -225,7 +225,7 @@ class BibleDB(QtCore.QObject, Manager, RegistryProperties): :param text_list: A dict of the verses to be inserted. The key is the verse number, and the value is the verse text. """ - log.debug('BibleDBcreate_chapter("%s", "%s")', book_id, chapter) + log.debug('BibleDBcreate_chapter("%s", "%s")' % (book_id, chapter)) # Text list has book and chapter as first two elements of the array. for verse_number, verse_text in text_list.items(): verse = Verse.populate( @@ -267,7 +267,7 @@ class BibleDB(QtCore.QObject, Manager, RegistryProperties): """ if not isinstance(value, str): value = str(value) - log.debug('BibleDB.save_meta("%s/%s")', key, value) + log.debug('BibleDB.save_meta("%s/%s")' % (key, value)) meta = self.get_object(BibleMeta, key) if meta: meta.value = value @@ -281,7 +281,7 @@ class BibleDB(QtCore.QObject, Manager, RegistryProperties): :param book: The name of the book to return. """ - log.debug('BibleDB.get_book("%s")', book) + log.debug('BibleDB.get_book("%s")' % book) return self.get_object_filtered(Book, Book.name.like(book + '%')) def get_books(self): @@ -292,17 +292,17 @@ class BibleDB(QtCore.QObject, Manager, RegistryProperties): log.debug('BibleDB.get_books()') return self.get_all_objects(Book, order_by_ref=Book.id) - def get_book_by_book_ref_id(self, id): + def get_book_by_book_ref_id(self, ref_id): """ Return a book object from the database. - :param id: The reference id of the book to return. + :param ref_id: The reference id of the book to return. """ - log.debug('BibleDB.get_book_by_book_ref_id("%s")', id) - return self.get_object_filtered(Book, Book.book_reference_id.like(id)) + log.debug('BibleDB.get_book_by_book_ref_id("%s")' % ref_id) + return self.get_object_filtered(Book, Book.book_reference_id.like(ref_id)) def get_book_ref_id_by_name(self, book, maxbooks, language_id=None): - log.debug('BibleDB.get_book_ref_id_by_name:("%s", "%s")', book, language_id) + log.debug('BibleDB.get_book_ref_id_by_name:("%s", "%s")' % (book, language_id)) book_id = None if BiblesResourcesDB.get_book(book, True): book_temp = BiblesResourcesDB.get_book(book, True) @@ -328,7 +328,7 @@ class BibleDB(QtCore.QObject, Manager, RegistryProperties): :param book: The name of the book, according to the selected language. :param language_selection: The language selection the user has chosen in the settings section of the Bible. """ - log.debug('get_book_ref_id_by_localised_name("%s", "%s")', book, language_selection) + log.debug('get_book_ref_id_by_localised_name("%s", "%s")' % (book, language_selection)) from openlp.plugins.bibles.lib import LanguageSelection, BibleStrings book_names = BibleStrings().BookNames # escape reserved characters @@ -376,14 +376,14 @@ class BibleDB(QtCore.QObject, Manager, RegistryProperties): [(u'35', 1, 1, 1), (u'35', 2, 2, 3)] :param show_error: """ - log.debug('BibleDB.get_verses("%s")', reference_list) + log.debug('BibleDB.get_verses("%s")' % reference_list) verse_list = [] book_error = False for book_id, chapter, start_verse, end_verse in reference_list: db_book = self.get_book_by_book_ref_id(book_id) if db_book: book_id = db_book.book_reference_id - log.debug('Book name corrected to "%s"', db_book.name) + log.debug('Book name corrected to "%s"' % db_book.name) if end_verse == -1: end_verse = self.get_verse_count(book_id, chapter) verses = self.session.query(Verse) \ @@ -395,7 +395,7 @@ class BibleDB(QtCore.QObject, Manager, RegistryProperties): .all() verse_list.extend(verses) else: - log.debug('OpenLP failed to find book with id "%s"', book_id) + log.debug('OpenLP failed to find book with id "%s"' % book_id) book_error = True if book_error and show_error: critical_error_message_box( @@ -414,7 +414,7 @@ class BibleDB(QtCore.QObject, Manager, RegistryProperties): contains spaces, it will split apart and AND'd on the list of values. """ - log.debug('BibleDB.verse_search("%s")', text) + log.debug('BibleDB.verse_search("%s")' % text) verses = self.session.query(Verse) if text.find(',') > -1: keywords = ['%%%s%%' % keyword.strip() for keyword in text.split(',')] @@ -433,7 +433,7 @@ class BibleDB(QtCore.QObject, Manager, RegistryProperties): :param book: The book object to get the chapter count for. """ - log.debug('BibleDB.get_chapter_count("%s")', book.name) + log.debug('BibleDB.get_chapter_count("%s")' % book.name) count = self.session.query(func.max(Verse.chapter)).join(Book).filter( Book.book_reference_id == book.book_reference_id).scalar() if not count: @@ -447,7 +447,7 @@ class BibleDB(QtCore.QObject, Manager, RegistryProperties): :param book_ref_id: The book reference id. :param chapter: The chapter to get the verse count for. """ - log.debug('BibleDB.get_verse_count("%s", "%s")', book_ref_id, chapter) + log.debug('BibleDB.get_verse_count("%s", "%s")' % (book_ref_id, chapter)) count = self.session.query(func.max(Verse.verse)).join(Book) \ .filter(Book.book_reference_id == book_ref_id) \ .filter(Verse.chapter == chapter) \ @@ -563,7 +563,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager): :param name: The name or abbreviation of the book. :param lower: True if the comparison should be only lowercase """ - log.debug('BiblesResourcesDB.get_book("%s")', name) + log.debug('BiblesResourcesDB.get_book("%s")' % name) if not isinstance(name, str): name = str(name) if lower: @@ -592,7 +592,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager): :param string: The string to search for in the book names or abbreviations. """ - log.debug('BiblesResourcesDB.get_book_like("%s")', string) + log.debug('BiblesResourcesDB.get_book_like("%s")' % string) if not isinstance(string, str): name = str(string) books = BiblesResourcesDB.run_sql( @@ -611,17 +611,17 @@ class BiblesResourcesDB(QtCore.QObject, Manager): return None @staticmethod - def get_book_by_id(id): + def get_book_by_id(book_id): """ Return a book by id. - :param id: The id of the book. + :param book_id: The id of the book. """ - log.debug('BiblesResourcesDB.get_book_by_id("%s")', id) - if not isinstance(id, int): - id = int(id) + log.debug('BiblesResourcesDB.get_book_by_id("%s")' % book_id) + if not isinstance(book_id, int): + book_id = int(book_id) books = BiblesResourcesDB.run_sql( - 'SELECT id, testament_id, name, abbreviation, chapters FROM book_reference WHERE id = ?', (id, )) + 'SELECT id, testament_id, name, abbreviation, chapters FROM book_reference WHERE id = ?', (book_id, )) if books: return { 'id': books[0][0], @@ -641,7 +641,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager): :param book_ref_id: The id of a book. :param chapter: The chapter number. """ - log.debug('BiblesResourcesDB.get_chapter("%s", "%s")', book_ref_id, chapter) + log.debug('BiblesResourcesDB.get_chapter("%s", "%s")' % (book_ref_id, chapter)) if not isinstance(chapter, int): chapter = int(chapter) chapters = BiblesResourcesDB.run_sql( @@ -664,7 +664,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager): :param book_ref_id: The id of the book. """ - log.debug('BiblesResourcesDB.get_chapter_count("%s")', book_ref_id) + log.debug('BiblesResourcesDB.get_chapter_count("%s")' % book_ref_id) details = BiblesResourcesDB.get_book_by_id(book_ref_id) if details: return details['chapters'] @@ -678,7 +678,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager): :param book_ref_id: The id of the book. :param chapter: The number of the chapter. """ - log.debug('BiblesResourcesDB.get_verse_count("%s", "%s")', book_ref_id, chapter) + log.debug('BiblesResourcesDB.get_verse_count("%s", "%s")' % (book_ref_id, chapter)) details = BiblesResourcesDB.get_chapter(book_ref_id, chapter) if details: return details['verse_count'] @@ -691,7 +691,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager): :param source: The name or abbreviation of the book. """ - log.debug('BiblesResourcesDB.get_download_source("%s")', source) + log.debug('BiblesResourcesDB.get_download_source("%s")' % source) if not isinstance(source, str): source = str(source) source = source.title() @@ -712,7 +712,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager): :param source: The source of the web_bible. """ - log.debug('BiblesResourcesDB.get_webbibles("%s")', source) + log.debug('BiblesResourcesDB.get_webbibles("%s")' % source) if not isinstance(source, str): source = str(source) source = BiblesResourcesDB.get_download_source(source) @@ -737,7 +737,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager): :param abbreviation: The abbreviation of the web_bible. :param source: The source of the web_bible. """ - log.debug('BiblesResourcesDB.get_webbibles("%s", "%s")', abbreviation, source) + log.debug('BiblesResourcesDB.get_webbibles("%s", "%s")' % (abbreviation, source)) if not isinstance(abbreviation, str): abbreviation = str(abbreviation) if not isinstance(source, str): @@ -765,7 +765,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager): :param name: The name to search the id. :param language_id: The language_id for which language should be searched """ - log.debug('BiblesResourcesDB.get_alternative_book_name("%s", "%s")', name, language_id) + log.debug('BiblesResourcesDB.get_alternative_book_name("%s", "%s")' % (name, language_id)) if language_id: books = BiblesResourcesDB.run_sql( 'SELECT book_reference_id, name FROM alternative_book_names WHERE language_id = ? ORDER BY id', @@ -784,7 +784,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager): :param name: The name or abbreviation of the language. """ - log.debug('BiblesResourcesDB.get_language("%s")', name) + log.debug('BiblesResourcesDB.get_language("%s")' % name) if not isinstance(name, str): name = str(name) language = BiblesResourcesDB.run_sql( @@ -880,7 +880,7 @@ class AlternativeBookNamesDB(QtCore.QObject, Manager): :param name: The name to search the id. :param language_id: The language_id for which language should be searched """ - log.debug('AlternativeBookNamesDB.get_book_reference_id("%s", "%s")', name, language_id) + log.debug('AlternativeBookNamesDB.get_book_reference_id("%s", "%s")' % (name, language_id)) if language_id: books = AlternativeBookNamesDB.run_sql( 'SELECT book_reference_id, name FROM alternative_book_names WHERE language_id = ?', (language_id, )) @@ -901,8 +901,8 @@ class AlternativeBookNamesDB(QtCore.QObject, Manager): :param book_reference_id: The book_reference_id of the book. :param language_id: The language to which the alternative book name belong. """ - log.debug('AlternativeBookNamesDB.create_alternative_book_name("%s", "%s", "%s")', - name, book_reference_id, language_id) + log.debug('AlternativeBookNamesDB.create_alternative_book_name("%s", "%s", "%s")' % + (name, book_reference_id, language_id)) return AlternativeBookNamesDB.run_sql( 'INSERT INTO alternative_book_names(book_reference_id, language_id, name) ' 'VALUES (?, ?, ?)', (book_reference_id, language_id, name), True) From 25c3503397ab3cdb3bc7c778405717e910fef462 Mon Sep 17 00:00:00 2001 From: Jonathan Springer Date: Tue, 8 Apr 2014 16:45:40 -0400 Subject: [PATCH 48/51] Add test to check for proper handling of service files passed in through the command line. --- .../openlp_core_ui/test_mainwindow.py | 97 ++++++++++++++++++ tests/resources/service/test.osz | Bin 0 -> 8082 bytes 2 files changed, 97 insertions(+) create mode 100644 tests/functional/openlp_core_ui/test_mainwindow.py create mode 100644 tests/resources/service/test.osz diff --git a/tests/functional/openlp_core_ui/test_mainwindow.py b/tests/functional/openlp_core_ui/test_mainwindow.py new file mode 100644 index 000000000..0b17828b9 --- /dev/null +++ b/tests/functional/openlp_core_ui/test_mainwindow.py @@ -0,0 +1,97 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2014 Raoul Snyman # +# Portions copyright (c) 2008-2014 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 # +############################################################################### +""" +Package to test openlp.core.ui.mainwindow package. +""" +import os + +from unittest import TestCase + +from openlp.core.ui.mainwindow import MainWindow +from openlp.core.common.registry import Registry +from tests.utils.constants import TEST_RESOURCES_PATH +from tests.helpers.testmixin import TestMixin +from tests.functional import MagicMock, patch + + +class TestMainWindow(TestCase, TestMixin): + + def setUp(self): + Registry.create() + self.registry = Registry() + self.get_application() + # Mock cursor busy/normal methods. + self.app.set_busy_cursor = MagicMock() + self.app.set_normal_cursor = MagicMock() + self.app.args = [] + Registry().register('application', self.app) + # Mock classes and methods used by mainwindow. + with patch('openlp.core.ui.mainwindow.SettingsForm') as mocked_settings_form, \ + patch('openlp.core.ui.mainwindow.ImageManager') as mocked_image_manager, \ + patch('openlp.core.ui.mainwindow.LiveController') as mocked_live_controller, \ + patch('openlp.core.ui.mainwindow.PreviewController') as mocked_preview_controller, \ + patch('openlp.core.ui.mainwindow.OpenLPDockWidget') as mocked_dock_widget, \ + patch('openlp.core.ui.mainwindow.QtGui.QToolBox') as mocked_q_tool_box_class, \ + patch('openlp.core.ui.mainwindow.QtGui.QMainWindow.addDockWidget') as mocked_add_dock_method, \ + patch('openlp.core.ui.mainwindow.ThemeManager') as mocked_theme_manager, \ + patch('openlp.core.ui.mainwindow.Renderer') as mocked_renderer: + self.main_window = MainWindow() + + def tearDown(self): + del self.main_window + + def cmd_line_file_test(self): + """ + Test that passing a service file from the command line loads the service. + """ + # GIVEN a service as an argument to openlp + service = os.path.join(TEST_RESOURCES_PATH, 'service', 'test.osz') + self.main_window.arguments = [service] + with patch('openlp.core.ui.servicemanager.ServiceManager.load_file') as mocked_load_path: + + # WHEN the argument is processed + self.main_window.open_cmd_line_files() + + # THEN the service from the arguments is loaded + mocked_load_path.assert_called_with(service), 'load_path should have been called with the service\'s path' + + def cmd_line_arg_test(self): + """ + Test that passing a non service file does nothing. + """ + # GIVEN a non service file as an argument to openlp + service = os.path.join('openlp.py') + self.main_window.arguments = [service] + with patch('openlp.core.ui.servicemanager.ServiceManager.load_file') as mocked_load_path: + + # WHEN the argument is processed + self.main_window.open_cmd_line_files() + + # THEN the file should not be opened + assert not mocked_load_path.called, 'load_path should not have been called' diff --git a/tests/resources/service/test.osz b/tests/resources/service/test.osz new file mode 100644 index 0000000000000000000000000000000000000000..a289c07750289ed1daf256935486aee320d09fc9 GIT binary patch literal 8082 zcmeHMVQ(9`5l!yeqCeoim(_>n3dol2-Ba+Fx7db{FN&ntJS6SWaCRnU{(%e+$JW#xS6^+hk& zL2cAFXr0L1tE;R2O-HmB>?oB%;uj3zpt zm7__E)XvO?(`l**@RwB}7lh$NPqW||;L;&_oOsVJK4yTPHt|RoUgbcLup6@npnTvj z#9ZwPn9-UU3oi@xVrX7vKsbnRl!tq?5f%nbm>2EMv3039m1Bt+$G!97v<`zlqiw7} z8)jk+bvn%`0upO}sPK$|S7Iy!AYBEw9hp1e?%V_J0f!|Z;|0yEqfo`@sk+p;zX>)> zi%n%n81`VvgyO#PX#1!{F6TlA4hA%46dl+R{BsH$@CU>QmN=*V5*B;T5r)nLE#{Cb zZeI#uj{ak7FT~Vo911V$Ljz2J>MR~JL}F?J3ed`*Xt#9eIK~0y z2ctw`3p&rVN`^E?tSg5`L~>vF5@~92%JG#KlF3Wt41{)qZSe$p9QLeUct8>u&*MpD zZ#DD*M|zsY-JzVq*(}!+3dJ|proN9uZ{V{pu=jcDl<8w)-2P{58{Eg0;5bbX0lvWE zb~*NuY50^PE%FpErO`g40K@Fgu#1UChD7F}bLSNDkU_3l-GMdWyR!{XdRN~ewIB#n zM}&(RzC?@IcfLo`LLITQ0@)}OoMZ$6Thj=#11I`_);cn zu(P%G^?vL(G&P* z)?NRy{~kMm)Od`?%IyteGwiSJ2Fv5;49)%?p$qN+IGFe4Hcb;J3o~4g*7wG4fY~=P zJGZY*?rhz~@3m1A#m5obSe`A~i9R}M;CgOsq5Hi-L~w7w;NHfVLm^tU(-jdpkJZlQ zY|=^RY}Lx>Y|%*S+}g=wS}_Vp>7&AV7Tt{0o% zOx$eJ&fRR%OyAs$5N~1dg-HX6-@$yaNW#oU`^36sUQIQV9}$$NM;?V^k`W)$w_1dK zx)Bu6UBn%?#Mg95eEps})-*tVR+xh7vmTgQ%Tcb(G|))I(TObOSVJ9xuJGu5r%$Z@ zRbM>qi?8wfVHk$cMxrT{W)Tb&C*P3NG+Vnd8~5$$U(1zt?|mZMpD&^{q78GXZ?qlz{1Tyl0hLDs$4}$#R))0 zshL7?ywR76_5i95z_1ol7YDKt@4H+it5|V04YUA8sGBq^WQt19$PNMf}kwwDs5%h%RbBw!fy!9lA-Gk~I0= z&M|$jZfWm!Fz(>lq`l*wq4bK8dJm=_vOc3QfoeenL6c8d!{rbw!1F}8iAn<06Bdc+ z0kRNesC^6E`lLhimc#N8FaR08bmBW4LjK?~itZzDpH&oyRhc8` zfd(!&pe`plU7*lV*pD2SF_=#(>0q3Z)Mng)+~S1b?Bq0SIaPE~5aTt6Z%lM)@wb8% z?6%ZMPM46m11?lIWx@Z;z5h|USErtji1GI~J9*66_`T}ZdWX`Oxp?KQAI}#G??*_z z)=a3P2x;aAE_+%jf-Tly3AXDbirT7;E7)WWx?sCD#<)|nt?K0^E!Up@Y7jf=fG5^yue13>>8*cPNtO|*rb^tI^esd-I^0zEK+!|*6hy~?F7IkT^zthYtR7O zbu$5*b&~;`HS)n7EdN9Dq5bgR)(*>==f5Q#+Os2(-O4N$rT&s^==5;D>f)y$89LWQ z5^q(H{QG+0ldrCJcDFwb@cA1v_T@7=4ODwl^_Wt9L*I~tXQ=fhib;oRb&68U2vC9K zD{PtTT&ZXLMu)l<^*fzO{bq=|vXfof(`#|mKK89zhjiUfuhyy6=(P~-jrABsA+7CR zxzBob4Urxd`t}ow=VopGjm?a}?$U4vr{DI)Nj1)OB3@g1->@RVZ(apJcdn(OZ&uPM zqNB-=SJ8`gh%d2<-_mNjPQZ63?;d{k#pliM(dqp<{rT%d`hW3O{p8)xe?i|L;_vV9 Ld5E{}4<7szH}{|L literal 0 HcmV?d00001 From bfc086749b899bbe7a34a9f461c6fdb0fec34b40 Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Tue, 8 Apr 2014 23:03:04 +0200 Subject: [PATCH 49/51] Test --- tests/functional/openlp_core_lib/test_ui.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/functional/openlp_core_lib/test_ui.py b/tests/functional/openlp_core_lib/test_ui.py index babc94a81..53bc8a770 100644 --- a/tests/functional/openlp_core_lib/test_ui.py +++ b/tests/functional/openlp_core_lib/test_ui.py @@ -81,3 +81,19 @@ class TestUi(TestCase): self.assertIsInstance(btnbox, QtGui.QDialogButtonBox) self.assertEqual(1, len(btnbox.buttons())) self.assertEqual(QtGui.QDialogButtonBox.HelpRole, btnbox.buttonRole(btnbox.buttons()[0])) + + def test_set_case_insensitive_completer(self): + """ + Test setting a case insensitive text completer for a widget + """ + # GIVEN: A ComboBox and a list of strings + combo = QtGui.QComboBox() + suggestions = ['hello', 'world', 'and', 'others'] + + # WHEN: We set the autocompleter + set_case_insensitive_completer(suggestions, combo) + + # THEN: The Combobox should have the autocompleter. + self.assertIsInstance(combo.completer(), QtGui.QCompleter) + self.assertEqual(QtCore.Qt.CaseInsensitive, combo.completer().caseSensitivity()) + self.assertEqual(suggestions, combo.completer().completionModel().data()) From 11884adbed9a838d178f7752b6aa254dfe241085 Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Tue, 8 Apr 2014 23:07:43 +0200 Subject: [PATCH 50/51] Disable two tests for the moment --- tests/functional/openlp_core_lib/test_ui.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/functional/openlp_core_lib/test_ui.py b/tests/functional/openlp_core_lib/test_ui.py index 53bc8a770..0d7315cda 100644 --- a/tests/functional/openlp_core_lib/test_ui.py +++ b/tests/functional/openlp_core_lib/test_ui.py @@ -95,5 +95,5 @@ class TestUi(TestCase): # THEN: The Combobox should have the autocompleter. self.assertIsInstance(combo.completer(), QtGui.QCompleter) - self.assertEqual(QtCore.Qt.CaseInsensitive, combo.completer().caseSensitivity()) - self.assertEqual(suggestions, combo.completer().completionModel().data()) + #self.assertEqual(QtCore.Qt.CaseInsensitive, combo.completer().caseSensitivity()) + #self.assertEqual(suggestions, combo.completer().completionModel().data()) From 31649b0a8e035a4388cab6570801089301051926 Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Tue, 8 Apr 2014 23:20:51 +0200 Subject: [PATCH 51/51] Better test --- tests/functional/openlp_core_lib/test_ui.py | 23 +++++++++++---------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/tests/functional/openlp_core_lib/test_ui.py b/tests/functional/openlp_core_lib/test_ui.py index 0d7315cda..03cdd5bb1 100644 --- a/tests/functional/openlp_core_lib/test_ui.py +++ b/tests/functional/openlp_core_lib/test_ui.py @@ -82,18 +82,19 @@ class TestUi(TestCase): self.assertEqual(1, len(btnbox.buttons())) self.assertEqual(QtGui.QDialogButtonBox.HelpRole, btnbox.buttonRole(btnbox.buttons()[0])) - def test_set_case_insensitive_completer(self): + def test_create_valign_selection_widgets(self): """ - Test setting a case insensitive text completer for a widget + Test creating a combo box for valign selection """ - # GIVEN: A ComboBox and a list of strings - combo = QtGui.QComboBox() - suggestions = ['hello', 'world', 'and', 'others'] + # GIVEN: A dialog + dialog = QtGui.QDialog() - # WHEN: We set the autocompleter - set_case_insensitive_completer(suggestions, combo) + # WHEN: We create the widgets + label, combo = create_valign_selection_widgets(dialog) - # THEN: The Combobox should have the autocompleter. - self.assertIsInstance(combo.completer(), QtGui.QCompleter) - #self.assertEqual(QtCore.Qt.CaseInsensitive, combo.completer().caseSensitivity()) - #self.assertEqual(suggestions, combo.completer().completionModel().data()) + # THEN: We should get a label and a combobox. + self.assertEqual(translate('OpenLP.Ui', '&Vertical Align:'), label.text()) + self.assertIsInstance(combo, QtGui.QComboBox) + self.assertEqual(combo, label.buddy()) + for text in [UiStrings().Top, UiStrings().Middle, UiStrings().Bottom]: + self.assertTrue(combo.findText(text) >= 0)