diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index 634272a7f..8ae6dac63 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -434,7 +434,7 @@ class ServiceItem(RegistryProperties): if path: self.has_original_files = False self.add_from_command(path, text_image['title'], text_image['image'], - text_image.get('display_title',''), text_image.get('notes', '')) + text_image.get('display_title', ''), text_image.get('notes', '')) else: self.add_from_command(text_image['path'], text_image['title'], text_image['image']) self._new_item() diff --git a/openlp/plugins/presentations/lib/impresscontroller.py b/openlp/plugins/presentations/lib/impresscontroller.py index 0528d4e64..0516c9e97 100644 --- a/openlp/plugins/presentations/lib/impresscontroller.py +++ b/openlp/plugins/presentations/lib/impresscontroller.py @@ -477,8 +477,8 @@ class ImpressDocument(PresentationDocument): def create_titles_and_notes(self): """ - Writes the list of titles (one per slide) - to 'titles.txt' + Writes the list of titles (one per slide) + to 'titles.txt' and the notes to 'slideNotes[x].txt' in the thumbnails directory """ diff --git a/openlp/plugins/presentations/lib/powerpointcontroller.py b/openlp/plugins/presentations/lib/powerpointcontroller.py index bfb775a25..634daa350 100644 --- a/openlp/plugins/presentations/lib/powerpointcontroller.py +++ b/openlp/plugins/presentations/lib/powerpointcontroller.py @@ -400,8 +400,8 @@ class PowerpointDocument(PresentationDocument): def create_titles_and_notes(self): """ - Writes the list of titles (one per slide) - to 'titles.txt' + Writes the list of titles (one per slide) + to 'titles.txt' and the notes to 'slideNotes[x].txt' in the thumbnails directory """ @@ -431,6 +431,7 @@ class PowerpointDocument(PresentationDocument): 'and the presentation will be stopped. ' 'Restart the presentation if you wish to present it.')) + def _get_text_from_shapes(shapes): """ Returns any text extracted from the shapes on a presentation slide. @@ -447,6 +448,7 @@ def _get_text_from_shapes(shapes): if os.name == "nt": try: ppE = win32com.client.getevents("PowerPoint.Application") + class PowerpointEvents(ppE): def OnSlideShowBegin(self, hwnd): #print("SS Begin") @@ -470,4 +472,3 @@ if os.name == "nt": return except pywintypes.com_error: log.debug('COM error trying to get powerpoint events - powerpoint is probably not installed.') - diff --git a/openlp/plugins/presentations/lib/pptviewcontroller.py b/openlp/plugins/presentations/lib/pptviewcontroller.py index 24b954afb..f7fd573f3 100644 --- a/openlp/plugins/presentations/lib/pptviewcontroller.py +++ b/openlp/plugins/presentations/lib/pptviewcontroller.py @@ -160,8 +160,8 @@ class PptviewDocument(PresentationDocument): def create_titles_and_notes(self): """ Extracts the titles and notes from the zipped file - and writes the list of titles (one per slide) - to 'titles.txt' + and writes the list of titles (one per slide) + to 'titles.txt' and the notes to 'slideNotes[x].txt' in the thumbnails directory """ @@ -210,9 +210,9 @@ class PptviewDocument(PresentationDocument): if nodes and len(nodes) > 0: for node in nodes: if len(text) > 0: - text += '\n' + text += '\n' text += node.text - # Let's remove the \n from the titles and + # Let's remove the \n from the titles and # just add one at the end if node_type == 'ctrTitle': text = text.replace('\n', ' ').replace('\x0b', ' ') + '\n' diff --git a/openlp/plugins/presentations/lib/presentationcontroller.py b/openlp/plugins/presentations/lib/presentationcontroller.py index 1175679c8..c64d70016 100644 --- a/openlp/plugins/presentations/lib/presentationcontroller.py +++ b/openlp/plugins/presentations/lib/presentationcontroller.py @@ -295,9 +295,8 @@ class PresentationDocument(object): def get_titles_and_notes(self): """ - Reads the titles from the titles file and - the notes files and returns the contents - in a two lists + Reads the titles from the titles file and + the notes files and returns the content in two lists """ titles = [] notes = [] @@ -337,6 +336,7 @@ class PresentationDocument(object): with open(notes_file, mode='w') as fn: fn.write(note) + class PresentationController(object): """ This class is used to control interactions with presentation applications by creating a runtime environment. @@ -471,6 +471,7 @@ class PresentationController(object): def close_presentation(self): pass + class TextType(object): """ Type Enumeration for Types of Text to request @@ -478,4 +479,3 @@ class TextType(object): Title = 0 SlideText = 1 Notes = 2 - diff --git a/openlp/plugins/remotes/lib/__init__.py b/openlp/plugins/remotes/lib/__init__.py index 9bb82c3cd..56818dcab 100644 --- a/openlp/plugins/remotes/lib/__init__.py +++ b/openlp/plugins/remotes/lib/__init__.py @@ -32,4 +32,4 @@ from .httprouter import HttpRouter from .httpserver import OpenLPServer from .websocket import WebSocketManager -__all__ = ['RemoteTab', 'OpenLPServer', 'HttpRouter','WebSocketManager'] +__all__ = ['RemoteTab', 'OpenLPServer', 'HttpRouter', 'WebSocketManager'] diff --git a/openlp/plugins/remotes/lib/httprouter.py b/openlp/plugins/remotes/lib/httprouter.py index 489d4fc38..3f1131ca1 100644 --- a/openlp/plugins/remotes/lib/httprouter.py +++ b/openlp/plugins/remotes/lib/httprouter.py @@ -503,7 +503,7 @@ class HttpRouter(RegistryProperties): if current_item.is_capable(ItemCapabilities.HasNotes): item['notes'] = str(frame['notes']) if current_item.is_capable(ItemCapabilities.HasThumbnails): - # If the file is under our app directory tree send the + # If the file is under our app directory tree send the # portion after the match data_path = AppLocation.get_data_path() if frame['image'][0:len(data_path)] == data_path: @@ -627,4 +627,3 @@ class HttpRouter(RegistryProperties): item_id = plugin.media_item.create_item_from_id(request_id) plugin.media_item.emit(QtCore.SIGNAL('%s_add_to_service' % plugin_name), [item_id, True]) self.do_http_success() - diff --git a/tests/functional/openlp_core_common/test_applocation.py b/tests/functional/openlp_core_common/test_applocation.py index 1a4ba8e8c..cc2f36c87 100644 --- a/tests/functional/openlp_core_common/test_applocation.py +++ b/tests/functional/openlp_core_common/test_applocation.py @@ -162,9 +162,9 @@ class TestAppLocation(TestCase): patch('openlp.core.common.applocation.os.path.abspath') as mocked_abspath, \ patch('openlp.core.common.applocation.os.path.split') as mocked_split, \ patch('openlp.core.common.applocation.sys') as mocked_sys: - mocked_abspath.return_value = os.path.join('plugins','dir') + mocked_abspath.return_value = os.path.join('plugins', 'dir') mocked_split.return_value = ['openlp'] - mocked_get_frozen_path.return_value = os.path.join('plugins','dir') + mocked_get_frozen_path.return_value = os.path.join('plugins', 'dir') mocked_sys.frozen = 1 mocked_sys.argv = ['openlp'] @@ -172,7 +172,7 @@ class TestAppLocation(TestCase): directory = AppLocation.get_directory(AppLocation.PluginsDir) # THEN: The correct directory should be returned - self.assertEqual(os.path.join('plugins','dir'), directory, 'Directory should be "plugins/dir"') + self.assertEqual(os.path.join('plugins', 'dir'), directory, 'Directory should be "plugins/dir"') def get_frozen_path_in_unfrozen_app_test(self): """ diff --git a/tests/functional/openlp_plugins/presentations/test_impresscontroller.py b/tests/functional/openlp_plugins/presentations/test_impresscontroller.py index 3ce9a43b4..a33315c70 100644 --- a/tests/functional/openlp_plugins/presentations/test_impresscontroller.py +++ b/tests/functional/openlp_plugins/presentations/test_impresscontroller.py @@ -37,6 +37,7 @@ from openlp.plugins.presentations.lib.impresscontroller import \ TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..', 'resources')) + class TestLibModule(TestCase): def setUp(self): diff --git a/tests/functional/openlp_plugins/presentations/test_powerpointcontroller.py b/tests/functional/openlp_plugins/presentations/test_powerpointcontroller.py index 8326eb7e7..9cd8eb97a 100644 --- a/tests/functional/openlp_plugins/presentations/test_powerpointcontroller.py +++ b/tests/functional/openlp_plugins/presentations/test_powerpointcontroller.py @@ -41,7 +41,7 @@ from tests.helpers.testmixin import TestMixin from tests.utils.constants import TEST_RESOURCES_PATH from openlp.plugins.presentations.lib.powerpointcontroller import PowerpointController, PowerpointDocument,\ - _get_text_from_shapes + _get_text_from_shapes class TestPowerpointController(TestCase, TestMixin): @@ -205,7 +205,7 @@ class TestPowerpointDocument(TestCase, TestMixin): def get_text_from_shapes_test(self): """ - Test getting text from powerpoint shapes + Test getting text from powerpoint shapes """ # GIVEN: mocked shapes shape = MagicMock() diff --git a/tests/functional/openlp_plugins/presentations/test_powerpointviewercontroller.py b/tests/functional/openlp_plugins/presentations/test_powerpointviewercontroller.py index 6ae676fcb..ab0632e09 100644 --- a/tests/functional/openlp_plugins/presentations/test_powerpointviewercontroller.py +++ b/tests/functional/openlp_plugins/presentations/test_powerpointviewercontroller.py @@ -40,6 +40,7 @@ from openlp.plugins.presentations.lib.pptviewcontroller import PptviewController TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..', 'resources')) + class TestLibModule(TestCase): def setUp(self): @@ -65,7 +66,7 @@ class TestLibModule(TestCase): def verify_loading_document(self): """ Test loading a document in PowerpointViewer - """ + """ # GIVEN: the filename print(self.file_name) # WHEN: loading the filename @@ -95,7 +96,7 @@ class TestLibModule(TestCase): """ Test PowerpointController.create_titles_and_notes """ - # GIVEN: mocked PresentationController.save_titles_and_notes + # GIVEN: mocked PresentationController.save_titles_and_notes self.doc.save_titles_and_notes = MagicMock() # WHEN reading the titles and notes @@ -127,15 +128,15 @@ class TestLibModule(TestCase): self.doc.save_titles_and_notes.assert_called_once_with(None, None) mocked_exists.assert_any_call('Idontexist.pptx') self.assertEqual(mocked_open.call_count, 0, 'There should be no calls to open a file') - + def create_titles_and_notes_invalid_file_test(self): """ Test PowerpointController.create_titles_and_notes with invalid file """ # GIVEN: mocked PresentationController.save_titles_and_notes and an invalid file with patch('builtins.open', mock_open(read_data='this is a test')) as mocked_open, \ - patch('openlp.plugins.presentations.lib.pptviewcontroller.os.path.exists') as mocked_exists, \ - patch('openlp.plugins.presentations.lib.pptviewcontroller.zipfile.is_zipfile') as mocked_is_zf: + patch('openlp.plugins.presentations.lib.pptviewcontroller.os.path.exists') as mocked_exists, \ + patch('openlp.plugins.presentations.lib.pptviewcontroller.zipfile.is_zipfile') as mocked_is_zf: mocked_is_zf.return_value = False mocked_exists.return_value = True mocked_open.filesize = 10 @@ -148,4 +149,3 @@ class TestLibModule(TestCase): # THEN: self.doc.save_titles_and_notes.assert_called_once_with(None, None) self.assertEqual(mocked_is_zf.call_count, 1, 'is_zipfile should have been called once') - diff --git a/tests/functional/openlp_plugins/presentations/test_presentationcontroller.py b/tests/functional/openlp_plugins/presentations/test_presentationcontroller.py index 19a7403ad..b2dc43f97 100644 --- a/tests/functional/openlp_plugins/presentations/test_presentationcontroller.py +++ b/tests/functional/openlp_plugins/presentations/test_presentationcontroller.py @@ -37,18 +37,17 @@ from tests.functional import MagicMock, patch, mock_open FOLDER_TO_PATCH = 'openlp.plugins.presentations.lib.presentationcontroller.PresentationDocument.get_thumbnail_folder' + class TestPresentationController(TestCase): """ Test the PresentationController. """ - def setUp(self): mocked_plugin = MagicMock() mocked_plugin.settings_section = 'presentations' self.presentation = PresentationController(mocked_plugin) self.document = PresentationDocument(self.presentation, '') - def constructor_test(self): """ Test the Constructor @@ -100,7 +99,6 @@ class TestPresentationController(TestCase): # THEN: No file should have been created self.assertEqual(mocked_open.call_count, 0, 'No file should be created') - def get_titles_and_notes_test(self): """ Test PresentationDocument.get_titles_and_notes method @@ -108,8 +106,8 @@ class TestPresentationController(TestCase): # GIVEN: A mocked open, get_thumbnail_folder and exists with patch('builtins.open', mock_open(read_data='uno\ndos\n')) as mocked_open, \ - patch(FOLDER_TO_PATCH) as mocked_get_thumbnail_folder, \ - patch('openlp.plugins.presentations.lib.presentationcontroller.os.path.exists') as mocked_exists: + patch(FOLDER_TO_PATCH) as mocked_get_thumbnail_folder, \ + patch('openlp.plugins.presentations.lib.presentationcontroller.os.path.exists') as mocked_exists: mocked_get_thumbnail_folder.return_value = 'test' mocked_exists.return_value = True @@ -133,8 +131,8 @@ class TestPresentationController(TestCase): """ # GIVEN: A mocked open, get_thumbnail_folder and exists with patch('builtins.open') as mocked_open, \ - patch(FOLDER_TO_PATCH) as mocked_get_thumbnail_folder, \ - patch('openlp.plugins.presentations.lib.presentationcontroller.os.path.exists') as mocked_exists: + patch(FOLDER_TO_PATCH) as mocked_get_thumbnail_folder, \ + patch('openlp.plugins.presentations.lib.presentationcontroller.os.path.exists') as mocked_exists: mocked_get_thumbnail_folder.return_value = 'test' mocked_exists.return_value = False @@ -155,8 +153,8 @@ class TestPresentationController(TestCase): """ # GIVEN: A mocked open, get_thumbnail_folder and exists with patch('builtins.open') as mocked_open, \ - patch(FOLDER_TO_PATCH) as mocked_get_thumbnail_folder, \ - patch('openlp.plugins.presentations.lib.presentationcontroller.os.path.exists') as mocked_exists: + patch(FOLDER_TO_PATCH) as mocked_get_thumbnail_folder, \ + patch('openlp.plugins.presentations.lib.presentationcontroller.os.path.exists') as mocked_exists: mocked_get_thumbnail_folder.return_value = 'test' mocked_exists.return_value = True mocked_open.side_effect = IOError() @@ -166,4 +164,3 @@ class TestPresentationController(TestCase): # THEN: it should return two empty lists self.assertIs(type(result_titles), list, 'result_titles should be a list') - diff --git a/tests/functional/openlp_plugins/remotes/test_router.py b/tests/functional/openlp_plugins/remotes/test_router.py index a7e305ab4..c0190ecda 100644 --- a/tests/functional/openlp_plugins/remotes/test_router.py +++ b/tests/functional/openlp_plugins/remotes/test_router.py @@ -178,7 +178,7 @@ class TestRouter(TestCase, TestMixin): self.router.html_dir = os.path.normpath('test/dir') self.router.template_vars = MagicMock() with patch('openlp.core.lib.os.path.exists') as mocked_exists, \ - patch('builtins.open', mock_open(read_data='123')): + patch('builtins.open', mock_open(read_data='123')): mocked_exists.return_value = True # WHEN: call serve_file with an existing html file @@ -248,13 +248,13 @@ class TestRouter(TestCase, TestMixin): Registry.create() Registry().register('image_manager', mocked_image_manager) file_name = 'another%20test/slide1.png' - full_path = os.path.normpath(os.path.join('thumbnails',file_name)) + full_path = os.path.normpath(os.path.join('thumbnails', file_name)) width = 120 height = 90 with patch('openlp.core.lib.os.path.exists') as mocked_exists, \ - patch('builtins.open', mock_open(read_data='123')), \ - patch('openlp.plugins.remotes.lib.httprouter.AppLocation') as mocked_location, \ - patch('openlp.plugins.remotes.lib.httprouter.image_to_byte') as mocked_image_to_byte: + patch('builtins.open', mock_open(read_data='123')), \ + patch('openlp.plugins.remotes.lib.httprouter.AppLocation') as mocked_location, \ + patch('openlp.plugins.remotes.lib.httprouter.image_to_byte') as mocked_image_to_byte: mocked_exists.return_value = True mocked_image_to_byte.return_value = '123' mocked_location.get_section_data_path.return_value = ''