From 1759468ea52d30b5f7e5ecbee617c1aed8fe718a Mon Sep 17 00:00:00 2001 From: Felipe Polo-Wood Date: Fri, 1 Nov 2013 11:03:43 -0400 Subject: [PATCH] - Undid superfluous line formatting --- openlp/core/__init__.py | 3 +- openlp/plugins/media/lib/mediaitem.py | 5 +- openlp/plugins/presentations/lib/mediaitem.py | 5 +- openlp/plugins/remotes/lib/httprouter.py | 3 +- .../openlp_core_lib/test_serviceitem.py | 66 +++++++------------ 5 files changed, 28 insertions(+), 54 deletions(-) diff --git a/openlp/core/__init__.py b/openlp/core/__init__.py index 596240ae4..7d198db5e 100644 --- a/openlp/core/__init__.py +++ b/openlp/core/__init__.py @@ -291,8 +291,7 @@ def main(args=None): Settings.set_filename(portable_settings_file) portable_settings = Settings() # Set our data path - data_path = os.path.abspath(os.path.join(application_path, - '..', '..', 'Data',)) + data_path = os.path.abspath(os.path.join(application_path, '..', '..', 'Data',)) log.info('Data path: %s', data_path) # Point to our data path portable_settings.setValue('advanced/data path', data_path) diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index 5e6e424a8..3d2d5b26e 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -163,9 +163,8 @@ class MediaMediaItem(MediaManagerItem): service_item.title = 'webkit' service_item.processor = 'webkit' (path, name) = os.path.split(filename) - service_item.add_from_command(path, name, CLAPPERBOARD) - if self.media_controller.video(DisplayControllerType.Live, - service_item, video_behind_text=True): + 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, diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index df437655d..bb6aa5af1 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -33,9 +33,8 @@ import os from PyQt4 import QtCore, QtGui from openlp.core.common import Settings, UiStrings, translate -from openlp.core.lib import MediaManagerItem, Registry, ItemCapabilities, \ - ServiceItemContext, build_icon, check_item_selected, \ - create_thumb, validate_thumb +from openlp.core.lib import MediaManagerItem, Registry, ItemCapabilities, ServiceItemContext,\ + build_icon, check_item_selected, create_thumb, validate_thumb from openlp.core.lib.ui import critical_error_message_box, create_horizontal_adjusting_combo_box from openlp.core.utils import get_locale_key from openlp.plugins.presentations.lib import MessageListener diff --git a/openlp/plugins/remotes/lib/httprouter.py b/openlp/plugins/remotes/lib/httprouter.py index e42aae723..c820e126c 100644 --- a/openlp/plugins/remotes/lib/httprouter.py +++ b/openlp/plugins/remotes/lib/httprouter.py @@ -465,8 +465,7 @@ class HttpRouter(object): Return the latest display image as a byte stream. """ result = { - 'slide_image': 'data:image/png;base64,' + - str(image_to_byte(self.live_controller.slide_image)) + 'slide_image': 'data:image/png;base64,' + str(image_to_byte(self.live_controller.slide_image)) } self.do_json_header() return json.dumps({'results': result}).encode() diff --git a/tests/functional/openlp_core_lib/test_serviceitem.py b/tests/functional/openlp_core_lib/test_serviceitem.py index 9fe742015..44f624c24 100644 --- a/tests/functional/openlp_core_lib/test_serviceitem.py +++ b/tests/functional/openlp_core_lib/test_serviceitem.py @@ -47,8 +47,7 @@ VERSE = 'The Lord said to {r}Noah{/r}: \n'\ '{r}C{/r}{b}h{/b}{bl}i{/bl}{y}l{/y}{g}d{/g}{pk}'\ 'r{/pk}{o}e{/o}{pp}n{/pp} of the Lord\n' FOOTER = ['Arky Arky (Unknown)', 'Public Domain', 'CCLI 123456'] -TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', - 'resources')) +TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', 'resources')) class TestServiceItem(TestCase): @@ -73,10 +72,8 @@ class TestServiceItem(TestCase): service_item = ServiceItem(None) # THEN: We should get back a valid service item - self.assertTrue(service_item.is_valid, - 'The new service item should be valid') - self.assertTrue(service_item.missing_frames(), - 'There should not be any frames in the service item') + self.assertTrue(service_item.is_valid, 'The new service item should be valid') + self.assertTrue(service_item.missing_frames(), 'There should not be any frames in the service item') def service_item_load_custom_from_service_test(self): """ @@ -91,30 +88,22 @@ class TestServiceItem(TestCase): service_item.set_from_service(line) # THEN: We should get back a valid service item - self.assertTrue(service_item.is_valid, - 'The new service item should be valid') - assert_length(0, service_item._display_frames, - 'The service item should have no display frames') - assert_length(5, service_item.capabilities, - 'There should be 5 default custom item capabilities') + self.assertTrue(service_item.is_valid, 'The new service item should be valid') + assert_length(0, service_item._display_frames, 'The service item should have no display frames') + assert_length(5, service_item.capabilities, 'There should be 5 default custom item capabilities') # WHEN: We render the frames of the service item service_item.render(True) # THEN: The frames should also be valid - self.assertEqual('Test Custom', service_item.get_display_title(), - 'The title should be "Test Custom"') + self.assertEqual('Test Custom', service_item.get_display_title(), 'The title should be "Test Custom"') self.assertEqual(VERSE[:-1], service_item.get_frames()[0]['text'], 'The returned text matches the input, except the last line feed') - self.assertEqual(VERSE.split('\n', 1)[0], - service_item.get_rendered_frame(1), + self.assertEqual(VERSE.split('\n', 1)[0], service_item.get_rendered_frame(1), 'The first line has been returned') - self.assertEqual('Slide 1', service_item.get_frame_title(0), - '"Slide 1" has been returned as the title') - self.assertEqual('Slide 2', service_item.get_frame_title(1), - '"Slide 2" has been returned as the title') - self.assertEqual('', service_item.get_frame_title(2), - 'Blank has been returned as the title of slide 3') + self.assertEqual('Slide 1', service_item.get_frame_title(0), '"Slide 1" has been returned as the title') + self.assertEqual('Slide 2', service_item.get_frame_title(1), '"Slide 2" has been returned as the title') + self.assertEqual('', service_item.get_frame_title(2), 'Blank has been returned as the title of slide 3') def service_item_load_image_from_service_test(self): """ @@ -130,14 +119,12 @@ class TestServiceItem(TestCase): # WHEN: adding an image from a saved Service and mocked exists line = convert_file_service_item(TEST_PATH, 'serviceitem_image_1.osj') - with patch('openlp.core.ui.servicemanager.os.path.exists') as \ - mocked_exists: + with patch('openlp.core.ui.servicemanager.os.path.exists') as mocked_exists: mocked_exists.return_value = True service_item.set_from_service(line, TEST_PATH) # THEN: We should get back a valid service item - self.assertTrue(service_item.is_valid, - 'The new service item should be valid') + self.assertTrue(service_item.is_valid, 'The new service item should be valid') self.assertEqual(os.path.normpath(test_file), os.path.normpath(service_item.get_rendered_frame(0)), 'The first frame should match the path to the image') @@ -149,8 +136,7 @@ class TestServiceItem(TestCase): 'The frame title should match the image name') self.assertEqual(image_name, service_item.get_display_title(), 'The display title should match the first image name') - self.assertTrue(service_item.is_image(), - 'This service item should be of an "image" type') + self.assertTrue(service_item.is_image(), 'This service item should be of an "image" type') self.assertTrue(service_item.is_capable(ItemCapabilities.CanMaintain), 'This service item should be able to be Maintained') self.assertTrue(service_item.is_capable(ItemCapabilities.CanPreview), @@ -184,22 +170,17 @@ class TestServiceItem(TestCase): line = convert_file_service_item(TEST_PATH, 'serviceitem_image_2.osj') line2 = convert_file_service_item(TEST_PATH, 'serviceitem_image_2.osj', 1) - with patch('openlp.core.ui.servicemanager.os.path.exists') as \ - mocked_exists: + with patch('openlp.core.ui.servicemanager.os.path.exists') as mocked_exists: mocked_exists.return_value = True service_item2.set_from_service(line2) service_item.set_from_service(line) # THEN: We should get back a valid service item - # This test is copied from service_item.py, - # but is changed since to conform to - # new layout of service item. The layout use in - # serviceitem_image_2.osd is actually invalid now. - self.assertTrue(service_item.is_valid, - 'The first service item should be valid') - self.assertTrue(service_item2.is_valid, - 'The second service item should be valid') + # This test is copied from service_item.py, but is changed since to conform to + # new layout of service item. The layout use in serviceitem_image_2.osd is actually invalid now. + self.assertTrue(service_item.is_valid, 'The first service item should be valid') + self.assertTrue(service_item2.is_valid, 'The second service item should be valid') self.assertEqual(test_file1, os.path.normpath(service_item.get_rendered_frame(0)), 'The first frame should match the path to the image') @@ -209,10 +190,8 @@ class TestServiceItem(TestCase): # There is a problem with the following two asserts in Windows # and it is not easily fixable (although it looks simple) if os.name != 'nt': - self.assertEqual(frame_array1, service_item.get_frames()[0], - 'The return should match the frame array1') - self.assertEqual(frame_array2, service_item2.get_frames()[0], - 'The return should match the frame array2') + self.assertEqual(frame_array1, service_item.get_frames()[0], 'The return should match the frame array1') + self.assertEqual(frame_array2, service_item2.get_frames()[0], 'The return should match the frame array2') self.assertEqual(test_file1, os.path.normpath( service_item.get_frame_path(0)), 'The frame path should match the full path to the image') @@ -225,8 +204,7 @@ class TestServiceItem(TestCase): 'The 2nd frame title should match the image name') self.assertEqual(service_item.name, service_item.title.lower(), 'The plugin name should match the display title, as there are > 1 Images') - self.assertTrue(service_item.is_image(), - 'This service item should be of an "image" type') + self.assertTrue(service_item.is_image(), 'This service item should be of an "image" type') self.assertTrue(service_item.is_capable(ItemCapabilities.CanMaintain), 'This service item should be able to be Maintained') self.assertTrue(service_item.is_capable(ItemCapabilities.CanPreview),