From 49342f4a6960fb55cca009704166cffb9cee82cd Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Sun, 22 Jun 2014 22:12:59 +0200 Subject: [PATCH 01/17] Improve Powerpoint error handling --- .../presentations/lib/powerpointcontroller.py | 137 ++++++++++++++---- 1 file changed, 107 insertions(+), 30 deletions(-) diff --git a/openlp/plugins/presentations/lib/powerpointcontroller.py b/openlp/plugins/presentations/lib/powerpointcontroller.py index 09fdf2fcc..05d25b98e 100644 --- a/openlp/plugins/presentations/lib/powerpointcontroller.py +++ b/openlp/plugins/presentations/lib/powerpointcontroller.py @@ -40,6 +40,7 @@ if os.name == 'nt': import pywintypes from openlp.core.lib import ScreenList +from openlp.core.lib.ui import UiStrings, critical_error_message_box from .presentationcontroller import PresentationController, PresentationDocument @@ -99,7 +100,7 @@ class PowerpointController(PresentationController): if self.process.Presentations.Count > 0: return self.process.Quit() - except pywintypes.com_error: + except (AttributeError, pywintypes.com_error): pass self.process = None @@ -126,16 +127,23 @@ class PowerpointDocument(PresentationDocument): earlier. """ log.debug('load_presentation') - if not self.controller.process or not self.controller.process.Visible: - self.controller.start_process() try: + if not self.controller.process or not self.controller.process.Visible: + self.controller.start_process() self.controller.process.Presentations.Open(self.file_path, False, False, True) - except pywintypes.com_error: - log.debug('PPT open failed') + self.presentation = self.controller.process.Presentations(self.controller.process.Presentations.Count) + self.create_thumbnails() + # Powerpoint 2013 pops up when loading a file, so we minimize it again + if self.presentation.Application.Version == u'15.0': + try: + self.presentation.Application.WindowState = 2 + except: + log.error('Failed to minimize main powerpoint window') + return True + except pywintypes.com_error as e: + log.error('PPT open failed') + log.error(e) return False - self.presentation = self.controller.process.Presentations(self.controller.process.Presentations.Count) - self.create_thumbnails() - return True def create_thumbnails(self): """ @@ -206,23 +214,33 @@ class PowerpointDocument(PresentationDocument): Unblanks (restores) the presentation. """ log.debug('unblank_screen') - self.presentation.SlideShowSettings.Run() - self.presentation.SlideShowWindow.View.State = 1 - self.presentation.SlideShowWindow.Activate() - if self.presentation.Application.Version == '14.0': - # Unblanking is broken in PowerPoint 2010, need to redisplay - slide = self.presentation.SlideShowWindow.View.CurrentShowPosition - click = self.presentation.SlideShowWindow.View.GetClickIndex() - self.presentation.SlideShowWindow.View.GotoSlide(slide) - if click: - self.presentation.SlideShowWindow.View.GotoClick(click) + try: + self.presentation.SlideShowSettings.Run() + self.presentation.SlideShowWindow.View.State = 1 + self.presentation.SlideShowWindow.Activate() + if self.presentation.Application.Version == '14.0': + # Unblanking is broken in PowerPoint 2010, need to redisplay + slide = self.presentation.SlideShowWindow.View.CurrentShowPosition + click = self.presentation.SlideShowWindow.View.GetClickIndex() + self.presentation.SlideShowWindow.View.GotoSlide(slide) + if click: + self.presentation.SlideShowWindow.View.GotoClick(click) + except pywintypes.com_error as e: + log.error('COM error while in unblank_screen') + log.error(e) + self.show_error_msg() def blank_screen(self): """ Blanks the screen. """ log.debug('blank_screen') - self.presentation.SlideShowWindow.View.State = 3 + try: + self.presentation.SlideShowWindow.View.State = 3 + except pywintypes.com_error as e: + log.error('COM error while in blank_screen') + log.error(e) + self.show_error_msg() def is_blank(self): """ @@ -230,7 +248,12 @@ class PowerpointDocument(PresentationDocument): """ log.debug('is_blank') if self.is_active(): - return self.presentation.SlideShowWindow.View.State == 3 + try: + return self.presentation.SlideShowWindow.View.State == 3 + except pywintypes.com_error as e: + log.error('COM error while in is_blank') + log.error(e) + self.show_error_msg() else: return False @@ -239,7 +262,12 @@ class PowerpointDocument(PresentationDocument): Stops the current presentation and hides the output. """ log.debug('stop_presentation') - self.presentation.SlideShowWindow.View.Exit() + try: + self.presentation.SlideShowWindow.View.Exit() + except pywintypes.com_error as e: + log.error('COM error while in stop_presentation') + log.error(e) + self.show_error_msg() if os.name == 'nt': def start_presentation(self): @@ -259,24 +287,48 @@ class PowerpointDocument(PresentationDocument): ppt_window = self.presentation.SlideShowSettings.Run() if not ppt_window: return - ppt_window.Top = size.y() * 72 / dpi - ppt_window.Height = size.height() * 72 / dpi - ppt_window.Left = size.x() * 72 / dpi - ppt_window.Width = size.width() * 72 / dpi + try: + ppt_window.Top = size.y() * 72 / dpi + ppt_window.Height = size.height() * 72 / dpi + ppt_window.Left = size.x() * 72 / dpi + ppt_window.Width = size.width() * 72 / dpi + except AttributeError as e: + log.error('AttributeError while in start_presentation') + log.error(e) + # Powerpoint 2013 pops up when starting a file, so we minimize it again + if self.presentation.Application.Version == u'15.0': + try: + self.presentation.Application.WindowState = 2 + except: + log.error('Failed to minimize main powerpoint window') def get_slide_number(self): """ Returns the current slide number. """ log.debug('get_slide_number') - return self.presentation.SlideShowWindow.View.CurrentShowPosition + ret = 0 + try: + ret = self.presentation.SlideShowWindow.View.CurrentShowPosition + except pywintypes.com_error as e: + log.error('COM error while in get_slide_number') + log.error(e) + self.show_error_msg() + return ret def get_slide_count(self): """ Returns total number of slides. """ log.debug('get_slide_count') - return self.presentation.Slides.Count + ret = 0 + try: + ret = self.presentation.Slides.Count + except pywintypes.com_error as e: + log.error('COM error while in get_slide_count') + log.error(e) + self.show_error_msg() + return ret def goto_slide(self, slide_no): """ @@ -285,14 +337,25 @@ class PowerpointDocument(PresentationDocument): :param slide_no: The slide the text is required for, starting at 1 """ log.debug('goto_slide') - self.presentation.SlideShowWindow.View.GotoSlide(slide_no) + try: + self.presentation.SlideShowWindow.View.GotoSlide(slide_no) + except pywintypes.com_error as e: + log.error('COM error while in goto_slide') + log.error(e) + self.show_error_msg() def next_step(self): """ Triggers the next effect of slide on the running presentation. """ log.debug('next_step') - self.presentation.SlideShowWindow.View.Next() + try: + self.presentation.SlideShowWindow.View.Next() + except pywintypes.com_error as e: + log.error('COM error while in next_step') + log.error(e) + self.show_error_msg() + return if self.get_slide_number() > self.get_slide_count(): self.previous_step() @@ -301,7 +364,12 @@ class PowerpointDocument(PresentationDocument): Triggers the previous slide on the running presentation. """ log.debug('previous_step') - self.presentation.SlideShowWindow.View.Previous() + try: + self.presentation.SlideShowWindow.View.Previous() + except pywintypes.com_error as e: + log.error('COM error while in previous_step') + log.error(e) + self.show_error_msg() def get_slide_text(self, slide_no): """ @@ -319,6 +387,15 @@ class PowerpointDocument(PresentationDocument): """ return _get_text_from_shapes(self.presentation.Slides(slide_no).NotesPage.Shapes) + def show_error_msg(self): + """ + Stop presentation and display an error message. + """ + self.stop_presentation() + critical_error_message_box(UiStrings().Error, translate('PresentationPlugin.PowerpointDocument', + 'An error occurred in the Powerpoint integration ' + 'and the presentation will be stopped. ' + 'Relstart the presentation if you wish to present it.')) def _get_text_from_shapes(shapes): """ From 7d2f8fa6cd02537fdf961c1c53da17b3bf75c603 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Tue, 1 Jul 2014 22:10:26 +0100 Subject: [PATCH 02/17] Fix setup.py --- openlp/.version | 2 +- openlp/core/utils/__init__.py | 4 ++-- resources/openlp.desktop | 6 ------ setup.py | 6 +++--- 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/openlp/.version b/openlp/.version index 3245d0c77..406870ece 100644 --- a/openlp/.version +++ b/openlp/.version @@ -1 +1 @@ -2.1.0-bzr2234 +2.1.0-bzr2389 diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index add663132..9b024eb84 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -149,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.decode('utf-8') else: - full_version = '%s-bzr%s' % (tag_version, tree_revision) + full_version = '%s-bzr%s' % (tag_version.decode('utf-8'), tree_revision.decode('utf-8')) else: # We're not running the development version, let's use the file. filepath = AppLocation.get_directory(AppLocation.VersionDir) diff --git a/resources/openlp.desktop b/resources/openlp.desktop index b17cbaf96..d585f4022 100755 --- a/resources/openlp.desktop +++ b/resources/openlp.desktop @@ -1,7 +1,5 @@ [Desktop Entry] Categories=AudioVideo; -Comment[de]= -Comment= Exec=openlp %F GenericName[de]=Church lyrics projection GenericName=Church lyrics projection @@ -9,11 +7,7 @@ Icon=openlp MimeType=application/x-openlp-service; Name[de]=OpenLP Name=OpenLP -Path= StartupNotify=true Terminal=false Type=Application -X-DBUS-ServiceName= -X-DBUS-StartupType= X-KDE-SubstituteUID=false -X-KDE-Username= diff --git a/setup.py b/setup.py index fc4a6f89b..fbf53d6d5 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.decode('utf-8') else: - version_string = '%s-bzr%s' % (tag_version, tree_revision) + version_string = '%s-bzr%s' % (tag_version.decode('utf-8'), tree_revision.decode('utf-8')) ver_file = open(VERSION_FILE, 'w') ver_file.write(version_string) except: @@ -152,7 +152,7 @@ using a computer and a data projector.""", 'Operating System :: POSIX :: BSD :: FreeBSD', 'Operating System :: POSIX :: Linux', 'Programming Language :: Python', - 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 3', 'Topic :: Desktop Environment :: Gnome', 'Topic :: Desktop Environment :: K Desktop Environment (KDE)', 'Topic :: Multimedia', From b3041a528764b7cdda0ce7fbfec7ee1f8f1c1135 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Tue, 1 Jul 2014 22:11:13 +0100 Subject: [PATCH 03/17] Fix version --- openlp/.version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/.version b/openlp/.version index 406870ece..3245d0c77 100644 --- a/openlp/.version +++ b/openlp/.version @@ -1 +1 @@ -2.1.0-bzr2389 +2.1.0-bzr2234 From f649f0af3c3c252f4b0c8d310170f8a7ad27f352 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 2 Jul 2014 19:13:23 +0100 Subject: [PATCH 04/17] Fix initialisation --- openlp/core/lib/renderer.py | 1 - openlp/core/ui/maindisplay.py | 5 +---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index 71a1f6058..ab4a5a4df 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -59,7 +59,6 @@ class Renderer(OpenLPMixin, RegistryMixin, RegistryProperties): """ super(Renderer, self).__init__(None) # Need live behaviour if this is also working as a pseudo MainDisplay. - self.is_live = True self.screens = ScreenList() self.theme_level = ThemeLevel.Global self.global_theme_name = '' diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 946299aca..5c905c972 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -66,11 +66,8 @@ class Display(QtGui.QGraphicsView): if hasattr(parent, 'is_live') and parent.is_live: self.is_live = True if self.is_live: - super(Display, self).__init__() - # Overwrite the parent() method. self.parent = lambda: parent - else: - super(Display, self).__init__(parent) + super(Display, self).__init__() self.controller = parent self.screen = {} # FIXME: On Mac OS X (tested on 10.7) the display screen is corrupt with From 4ac921a2e7292f27f837dc264b31436c16bebc1b Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 2 Jul 2014 19:38:10 +0100 Subject: [PATCH 05/17] tests --- .../openlp_core_common/test_registrymixin.py | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 tests/functional/openlp_core_common/test_registrymixin.py diff --git a/tests/functional/openlp_core_common/test_registrymixin.py b/tests/functional/openlp_core_common/test_registrymixin.py new file mode 100644 index 000000000..75e134d5a --- /dev/null +++ b/tests/functional/openlp_core_common/test_registrymixin.py @@ -0,0 +1,76 @@ +# -*- 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.common package. +""" +import os +from unittest import TestCase + +from openlp.core.common import RegistryMixin, Registry + +TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '../', '..', 'resources')) + + +class TestRegistryMixin(TestCase): + + def registry_mixin_missing_test(self): + """ + Test the registry creation and its usage + """ + # GIVEN: A new registry + Registry.create() + + # WHEN: I create a new class + mock_1 = Test1() + + # THEN: The following methods are missing + self.assertEqual(len(Registry().functions_list), 0), 'The function should not be in the dict anymore.' + + def registry_mixin_present_test(self): + """ + Test the registry creation and its usage + """ + # GIVEN: A new registry + Registry.create() + + # WHEN: I create a new class + mock_2 = Test2() + + # THEN: The following bootstrap methods should be present + self.assertEqual(len(Registry().functions_list), 2), 'The bootstrap functions should be in the dict.' + + +class Test1(object): + def __init__(self): + pass + + +class Test2(RegistryMixin): + def __init__(self): + super(Test2, self).__init__(None) \ No newline at end of file From f71c4cc7af7e5544c5e021aff75daaa2ca1691a1 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 2 Jul 2014 19:58:52 +0100 Subject: [PATCH 06/17] remove nonvalid test --- tests/functional/openlp_core_lib/test_renderer.py | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/tests/functional/openlp_core_lib/test_renderer.py b/tests/functional/openlp_core_lib/test_renderer.py index 8814a21a0..8df4816bb 100644 --- a/tests/functional/openlp_core_lib/test_renderer.py +++ b/tests/functional/openlp_core_lib/test_renderer.py @@ -65,16 +65,6 @@ class TestRenderer(TestCase): """ del self.screens - def initial_renderer_test(self): - """ - Test the initial renderer state - """ - # GIVEN: A new renderer instance. - renderer = Renderer() - # WHEN: the default renderer is built. - # THEN: The renderer should be a live controller. - self.assertEqual(renderer.is_live, True, 'The base renderer should be a live controller') - def default_screen_layout_test(self): """ Test the default layout calculations From 3f889e08d4ea72ae940bcb5c174d93c6e423f0a8 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 2 Jul 2014 20:34:28 +0100 Subject: [PATCH 07/17] Fix setup.py --- setup.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/setup.py b/setup.py index fbf53d6d5..28f3658f1 100755 --- a/setup.py +++ b/setup.py @@ -105,6 +105,8 @@ try: tag_version, tag_revision = tags[-1].split() # 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. + tree_revision = tree_revision.strip() + tag_revision = tag_revision.strip() if tree_revision == tag_revision: version_string = tag_version.decode('utf-8') else: From 6847ee2e37e4f4db3a514eed3ad85ed113bf4b9d Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 2 Jul 2014 20:47:54 +0100 Subject: [PATCH 08/17] remove bl --- tests/functional/openlp_core_common/test_registrymixin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/functional/openlp_core_common/test_registrymixin.py b/tests/functional/openlp_core_common/test_registrymixin.py index 75e134d5a..800445637 100644 --- a/tests/functional/openlp_core_common/test_registrymixin.py +++ b/tests/functional/openlp_core_common/test_registrymixin.py @@ -73,4 +73,4 @@ class Test1(object): class Test2(RegistryMixin): def __init__(self): - super(Test2, self).__init__(None) \ No newline at end of file + super(Test2, self).__init__(None) From 12c8663f8e2e6e151d0d5ec1f397fc893822ce64 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 2 Jul 2014 20:52:26 +0100 Subject: [PATCH 09/17] indent --- tests/functional/openlp_core_common/test_registrymixin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/functional/openlp_core_common/test_registrymixin.py b/tests/functional/openlp_core_common/test_registrymixin.py index 800445637..d8636ac94 100644 --- a/tests/functional/openlp_core_common/test_registrymixin.py +++ b/tests/functional/openlp_core_common/test_registrymixin.py @@ -73,4 +73,4 @@ class Test1(object): class Test2(RegistryMixin): def __init__(self): - super(Test2, self).__init__(None) + super(Test2, self).__init__(None) From 79c7c583988c1f19f9183877a6fad6f635d15f58 Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Thu, 3 Jul 2014 13:21:12 +0200 Subject: [PATCH 10/17] Added test for powerpointcontroller --- .../presentations/lib/powerpointcontroller.py | 50 ++++--- .../test_powerpointcontroller.py | 131 ++++++++++++++++++ 2 files changed, 158 insertions(+), 23 deletions(-) create mode 100644 tests/functional/openlp_plugins/presentations/test_powerpointcontroller.py diff --git a/openlp/plugins/presentations/lib/powerpointcontroller.py b/openlp/plugins/presentations/lib/powerpointcontroller.py index 05d25b98e..0f9c2ff35 100644 --- a/openlp/plugins/presentations/lib/powerpointcontroller.py +++ b/openlp/plugins/presentations/lib/powerpointcontroller.py @@ -40,7 +40,8 @@ if os.name == 'nt': import pywintypes from openlp.core.lib import ScreenList -from openlp.core.lib.ui import UiStrings, critical_error_message_box +from openlp.core.lib.ui import UiStrings, critical_error_message_box, translate +from openlp.core.common import trace_error_handler from .presentationcontroller import PresentationController, PresentationDocument @@ -139,10 +140,11 @@ class PowerpointDocument(PresentationDocument): self.presentation.Application.WindowState = 2 except: log.error('Failed to minimize main powerpoint window') + trace_error_handler(log) return True - except pywintypes.com_error as e: + except pywintypes.com_error: log.error('PPT open failed') - log.error(e) + trace_error_handler(log) return False def create_thumbnails(self): @@ -225,9 +227,9 @@ class PowerpointDocument(PresentationDocument): self.presentation.SlideShowWindow.View.GotoSlide(slide) if click: self.presentation.SlideShowWindow.View.GotoClick(click) - except pywintypes.com_error as e: + except pywintypes.com_error: log.error('COM error while in unblank_screen') - log.error(e) + trace_error_handler(log) self.show_error_msg() def blank_screen(self): @@ -237,9 +239,9 @@ class PowerpointDocument(PresentationDocument): log.debug('blank_screen') try: self.presentation.SlideShowWindow.View.State = 3 - except pywintypes.com_error as e: + except pywintypes.com_error: log.error('COM error while in blank_screen') - log.error(e) + trace_error_handler(log) self.show_error_msg() def is_blank(self): @@ -250,9 +252,9 @@ class PowerpointDocument(PresentationDocument): if self.is_active(): try: return self.presentation.SlideShowWindow.View.State == 3 - except pywintypes.com_error as e: + except pywintypes.com_error: log.error('COM error while in is_blank') - log.error(e) + trace_error_handler(log) self.show_error_msg() else: return False @@ -264,9 +266,9 @@ class PowerpointDocument(PresentationDocument): log.debug('stop_presentation') try: self.presentation.SlideShowWindow.View.Exit() - except pywintypes.com_error as e: + except pywintypes.com_error: log.error('COM error while in stop_presentation') - log.error(e) + trace_error_handler(log) self.show_error_msg() if os.name == 'nt': @@ -301,6 +303,7 @@ class PowerpointDocument(PresentationDocument): self.presentation.Application.WindowState = 2 except: log.error('Failed to minimize main powerpoint window') + trace_error_handler(log) def get_slide_number(self): """ @@ -310,9 +313,9 @@ class PowerpointDocument(PresentationDocument): ret = 0 try: ret = self.presentation.SlideShowWindow.View.CurrentShowPosition - except pywintypes.com_error as e: + except pywintypes.com_error: log.error('COM error while in get_slide_number') - log.error(e) + trace_error_handler(log) self.show_error_msg() return ret @@ -324,9 +327,9 @@ class PowerpointDocument(PresentationDocument): ret = 0 try: ret = self.presentation.Slides.Count - except pywintypes.com_error as e: + except pywintypes.com_error: log.error('COM error while in get_slide_count') - log.error(e) + trace_error_handler(log) self.show_error_msg() return ret @@ -339,9 +342,9 @@ class PowerpointDocument(PresentationDocument): log.debug('goto_slide') try: self.presentation.SlideShowWindow.View.GotoSlide(slide_no) - except pywintypes.com_error as e: + except pywintypes.com_error: log.error('COM error while in goto_slide') - log.error(e) + trace_error_handler(log) self.show_error_msg() def next_step(self): @@ -351,9 +354,9 @@ class PowerpointDocument(PresentationDocument): log.debug('next_step') try: self.presentation.SlideShowWindow.View.Next() - except pywintypes.com_error as e: + except pywintypes.com_error: log.error('COM error while in next_step') - log.error(e) + trace_error_handler(log) self.show_error_msg() return if self.get_slide_number() > self.get_slide_count(): @@ -366,9 +369,9 @@ class PowerpointDocument(PresentationDocument): log.debug('previous_step') try: self.presentation.SlideShowWindow.View.Previous() - except pywintypes.com_error as e: + except pywintypes.com_error: log.error('COM error while in previous_step') - log.error(e) + trace_error_handler(log) self.show_error_msg() def get_slide_text(self, slide_no): @@ -392,10 +395,11 @@ class PowerpointDocument(PresentationDocument): Stop presentation and display an error message. """ self.stop_presentation() - critical_error_message_box(UiStrings().Error, translate('PresentationPlugin.PowerpointDocument', + critical_error_message_box(UiStrings().Error, translate('PresentationPlugin.PowerpointDocument', 'An error occurred in the Powerpoint integration ' 'and the presentation will be stopped. ' - 'Relstart the presentation if you wish to present it.')) + 'Restart the presentation if you wish to present it.')) + def _get_text_from_shapes(shapes): """ diff --git a/tests/functional/openlp_plugins/presentations/test_powerpointcontroller.py b/tests/functional/openlp_plugins/presentations/test_powerpointcontroller.py new file mode 100644 index 000000000..da58ef880 --- /dev/null +++ b/tests/functional/openlp_plugins/presentations/test_powerpointcontroller.py @@ -0,0 +1,131 @@ +# -*- 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 # +############################################################################### +""" +Functional tests to test the PowerPointController class and related methods. +""" +import os +if os.name == 'nt': + import pywintypes +import shutil +from unittest import TestCase +from tempfile import mkdtemp + +from tests.functional import patch, MagicMock +from tests.helpers.testmixin import TestMixin + +from openlp.plugins.presentations.lib.powerpointcontroller import PowerpointController, PowerpointDocument + + +class TestPowerpointController(TestCase, TestMixin): + """ + Test the PowerpointController Class + """ + + 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 PowerpointController + """ + # GIVEN: No presentation controller + controller = None + + # WHEN: The presentation controller object is created + controller = PowerpointController(plugin=self.mock_plugin) + + # THEN: The name of the presentation controller should be correct + self.assertEqual('Powerpoint', controller.name, + 'The name of the presentation controller should be correct') + + +class TestPowerpointDocument(TestCase): + """ + Test the PowerpointDocument Class + """ + + def setUp(self): + """ + Set up the patches and mocks need for all tests. + """ + self.powerpoint_document_stop_presentation_patcher = patch( + 'openlp.plugins.presentations.lib.powerpointcontroller.PowerpointDocument.stop_presentation') + self.presentation_document_get_temp_folder_patcher = patch( + 'openlp.plugins.presentations.lib.powerpointcontroller.PresentationDocument.get_temp_folder') + self.presentation_document_setup_patcher = patch( + 'openlp.plugins.presentations.lib.powerpointcontroller.PresentationDocument._setup') + self.mock_powerpoint_document_stop_presentation = self.powerpoint_document_stop_presentation_patcher.start() + self.mock_presentation_document_get_temp_folder = self.presentation_document_get_temp_folder_patcher.start() + self.mock_presentation_document_setup = self.presentation_document_setup_patcher.start() + self.mock_controller = MagicMock() + self.mock_presentation = MagicMock() + self.mock_presentation_document_get_temp_folder.return_value = 'temp folder' + + def tearDown(self): + """ + Stop the patches + """ + self.powerpoint_document_stop_presentation_patcher.stop() + self.presentation_document_get_temp_folder_patcher.stop() + self.presentation_document_setup_patcher.stop() + + def show_error_msg_test(self): + """ + Test the PowerpointDocument.show_error_msg() method gets called on com exception + """ + if os.name == 'nt': + # GIVEN: A PowerpointDocument with mocked controller and presentation + with patch('openlp.plugins.presentations.lib.powerpointcontroller.critical_error_message_box') as \ + mocked_critical_error_message_box: + instance = PowerpointDocument(self.mock_controller, self.mock_presentation) + instance.presentation = MagicMock() + instance.presentation.SlideShowWindow.View.GotoSlide = MagicMock(side_effect=pywintypes.com_error('1')) + + # WHEN: Calling goto_slide which will throw an exception + instance.goto_slide(42) + + # THEN: mocked_critical_error_message_box should have been called + mocked_critical_error_message_box.assert_called_with('Error', 'An error occurred in the Powerpoint ' + 'integration and the presentation will be stopped.' + ' Restart the presentation if you wish to ' + 'present it.') From d59be6ca822e8e1b4b64f62882e4c497f0954350 Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Thu, 3 Jul 2014 18:54:51 +0200 Subject: [PATCH 11/17] Move song import plugins to subfolder --- openlp/plugins/songs/forms/editsongform.py | 2 +- .../plugins/songs/forms/songreviewwidget.py | 2 +- openlp/plugins/songs/lib/importer.py | 34 ++++++------ openlp/plugins/songs/lib/mediaitem.py | 2 +- openlp/plugins/songs/lib/openlyricsexport.py | 2 +- .../songs/lib/{xml.py => openlyricsxml.py} | 0 .../plugins/songs/lib/songimport/__init__.py | 31 +++++++++++ .../lib/{ => songimport}/cclifileimport.py | 0 .../lib/{ => songimport}/dreambeamimport.py | 2 +- .../lib/{ => songimport}/easyslidesimport.py | 2 +- .../songs/lib/{ => songimport}/ewimport.py | 0 .../{ => songimport}/foilpresenterimport.py | 4 +- .../lib/{ => songimport}/mediashoutimport.py | 2 +- .../songs/lib/{ => songimport}/olpimport.py | 0 .../songs/lib/{ => songimport}/oooimport.py | 0 .../lib/{ => songimport}/openlyricsimport.py | 4 +- .../lib/{ => songimport}/opensongimport.py | 2 +- .../lib/{ => songimport}/powersongimport.py | 2 +- .../{ => songimport}/propresenterimport.py | 0 .../songs/lib/{ => songimport}/sofimport.py | 0 .../lib/{ => songimport}/songbeamerimport.py | 2 +- .../songs/lib/{ => songimport}/songimport.py | 2 +- .../lib/{ => songimport}/songproimport.py | 2 +- .../{ => songimport}/songshowplusimport.py | 2 +- .../lib/{ => songimport}/sundayplusimport.py | 2 +- .../worshipassistantimport.py | 2 +- .../worshipcenterproimport.py | 2 +- .../songs/lib/{ => songimport}/wowimport.py | 2 +- .../lib/{ => songimport}/zionworximport.py | 2 +- openlp/plugins/songs/lib/songselect.py | 2 +- openlp/plugins/songs/songsplugin.py | 2 +- .../openlp_plugins/songs/test_ewimport.py | 52 +++++++++---------- .../songs/test_foilpresenterimport.py | 30 +++++------ .../songs/test_openlyricsimport.py | 6 +-- .../songs/test_opensongimport.py | 10 ++-- .../songs/test_songbeamerimport.py | 10 ++-- .../songs/test_songshowplusimport.py | 12 ++--- .../songs/test_worshipcenterproimport.py | 4 +- .../songs/test_zionworximport.py | 6 +-- tests/helpers/songfileimport.py | 12 ++--- 40 files changed, 143 insertions(+), 112 deletions(-) rename openlp/plugins/songs/lib/{xml.py => openlyricsxml.py} (100%) create mode 100644 openlp/plugins/songs/lib/songimport/__init__.py rename openlp/plugins/songs/lib/{ => songimport}/cclifileimport.py (100%) rename openlp/plugins/songs/lib/{ => songimport}/dreambeamimport.py (99%) rename openlp/plugins/songs/lib/{ => songimport}/easyslidesimport.py (99%) rename openlp/plugins/songs/lib/{ => songimport}/ewimport.py (100%) rename openlp/plugins/songs/lib/{ => songimport}/foilpresenterimport.py (99%) rename openlp/plugins/songs/lib/{ => songimport}/mediashoutimport.py (98%) rename openlp/plugins/songs/lib/{ => songimport}/olpimport.py (100%) rename openlp/plugins/songs/lib/{ => songimport}/oooimport.py (100%) rename openlp/plugins/songs/lib/{ => songimport}/openlyricsimport.py (96%) rename openlp/plugins/songs/lib/{ => songimport}/opensongimport.py (99%) rename openlp/plugins/songs/lib/{ => songimport}/powersongimport.py (99%) rename openlp/plugins/songs/lib/{ => songimport}/propresenterimport.py (100%) rename openlp/plugins/songs/lib/{ => songimport}/sofimport.py (100%) rename openlp/plugins/songs/lib/{ => songimport}/songbeamerimport.py (99%) rename openlp/plugins/songs/lib/{ => songimport}/songimport.py (99%) rename openlp/plugins/songs/lib/{ => songimport}/songproimport.py (98%) rename openlp/plugins/songs/lib/{ => songimport}/songshowplusimport.py (99%) rename openlp/plugins/songs/lib/{ => songimport}/sundayplusimport.py (99%) rename openlp/plugins/songs/lib/{ => songimport}/worshipassistantimport.py (99%) rename openlp/plugins/songs/lib/{ => songimport}/worshipcenterproimport.py (98%) rename openlp/plugins/songs/lib/{ => songimport}/wowimport.py (99%) rename openlp/plugins/songs/lib/{ => songimport}/zionworximport.py (98%) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 2125922fe..6b5ccb041 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -44,7 +44,7 @@ from openlp.core.lib.ui import set_case_insensitive_completer, critical_error_me from openlp.plugins.songs.lib import VerseType, clean_song from openlp.plugins.songs.lib.db import Book, Song, Author, AuthorType, Topic, MediaFile from openlp.plugins.songs.lib.ui import SongStrings -from openlp.plugins.songs.lib.xml import SongXML +from openlp.plugins.songs.lib.openlyricsxml import SongXML from openlp.plugins.songs.forms.editsongdialog import Ui_EditSongDialog from openlp.plugins.songs.forms.editverseform import EditVerseForm from openlp.plugins.songs.forms.mediafilesform import MediaFilesForm diff --git a/openlp/plugins/songs/forms/songreviewwidget.py b/openlp/plugins/songs/forms/songreviewwidget.py index 02d7b8774..7f5f9c0c6 100644 --- a/openlp/plugins/songs/forms/songreviewwidget.py +++ b/openlp/plugins/songs/forms/songreviewwidget.py @@ -33,7 +33,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import build_icon from openlp.plugins.songs.lib import VerseType -from openlp.plugins.songs.lib.xml import SongXML +from openlp.plugins.songs.lib.openlyricsxml import SongXML class SongReviewWidget(QtGui.QWidget): diff --git a/openlp/plugins/songs/lib/importer.py b/openlp/plugins/songs/lib/importer.py index 6d01da309..9c0b889ca 100644 --- a/openlp/plugins/songs/lib/importer.py +++ b/openlp/plugins/songs/lib/importer.py @@ -34,23 +34,23 @@ import logging from openlp.core.common import translate, UiStrings from openlp.core.ui.wizard import WizardStrings -from .opensongimport import OpenSongImport -from .easyslidesimport import EasySlidesImport -from .olpimport import OpenLPSongImport -from .openlyricsimport import OpenLyricsImport -from .wowimport import WowImport -from .cclifileimport import CCLIFileImport -from .dreambeamimport import DreamBeamImport -from .powersongimport import PowerSongImport -from .ewimport import EasyWorshipSongImport -from .songbeamerimport import SongBeamerImport -from .songshowplusimport import SongShowPlusImport -from .songproimport import SongProImport -from .sundayplusimport import SundayPlusImport -from .foilpresenterimport import FoilPresenterImport -from .zionworximport import ZionWorxImport -from .propresenterimport import ProPresenterImport -from .worshipassistantimport import WorshipAssistantImport +from .songimport.opensongimport import OpenSongImport +from .songimport.easyslidesimport import EasySlidesImport +from .songimport.olpimport import OpenLPSongImport +from .songimport.openlyricsimport import OpenLyricsImport +from .songimport.wowimport import WowImport +from .songimport.cclifileimport import CCLIFileImport +from .songimport.dreambeamimport import DreamBeamImport +from .songimport.powersongimport import PowerSongImport +from .songimport.ewimport import EasyWorshipSongImport +from .songimport.songbeamerimport import SongBeamerImport +from .songimport.songshowplusimport import SongShowPlusImport +from .songimport.songproimport import SongProImport +from .songimport.sundayplusimport import SundayPlusImport +from .songimport.foilpresenterimport import FoilPresenterImport +from .songimport.zionworximport import ZionWorxImport +from .songimport.propresenterimport import ProPresenterImport +from .songimport.worshipassistantimport import WorshipAssistantImport # Imports that might fail diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index d57c8fbcc..fde103c5f 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -46,7 +46,7 @@ from openlp.plugins.songs.forms.songexportform import SongExportForm from openlp.plugins.songs.lib import VerseType, clean_string, delete_song from openlp.plugins.songs.lib.db import Author, AuthorType, Song, Book, MediaFile from openlp.plugins.songs.lib.ui import SongStrings -from openlp.plugins.songs.lib.xml import OpenLyrics, SongXML +from openlp.plugins.songs.lib.openlyricsxml import OpenLyrics, SongXML log = logging.getLogger(__name__) diff --git a/openlp/plugins/songs/lib/openlyricsexport.py b/openlp/plugins/songs/lib/openlyricsexport.py index 72210e89f..0458b893b 100644 --- a/openlp/plugins/songs/lib/openlyricsexport.py +++ b/openlp/plugins/songs/lib/openlyricsexport.py @@ -37,7 +37,7 @@ from lxml import etree from openlp.core.common import RegistryProperties, check_directory_exists, translate from openlp.core.utils import clean_filename -from openlp.plugins.songs.lib.xml import OpenLyrics +from openlp.plugins.songs.lib.openlyricsxml import OpenLyrics log = logging.getLogger(__name__) diff --git a/openlp/plugins/songs/lib/xml.py b/openlp/plugins/songs/lib/openlyricsxml.py similarity index 100% rename from openlp/plugins/songs/lib/xml.py rename to openlp/plugins/songs/lib/openlyricsxml.py diff --git a/openlp/plugins/songs/lib/songimport/__init__.py b/openlp/plugins/songs/lib/songimport/__init__.py new file mode 100644 index 000000000..f57136ecf --- /dev/null +++ b/openlp/plugins/songs/lib/songimport/__init__.py @@ -0,0 +1,31 @@ +# -*- 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 # +############################################################################### +""" +The :mod:`~openlp.plugins.songs.lib.import` module contains a importers for the Songs plugin. +""" diff --git a/openlp/plugins/songs/lib/cclifileimport.py b/openlp/plugins/songs/lib/songimport/cclifileimport.py similarity index 100% rename from openlp/plugins/songs/lib/cclifileimport.py rename to openlp/plugins/songs/lib/songimport/cclifileimport.py diff --git a/openlp/plugins/songs/lib/dreambeamimport.py b/openlp/plugins/songs/lib/songimport/dreambeamimport.py similarity index 99% rename from openlp/plugins/songs/lib/dreambeamimport.py rename to openlp/plugins/songs/lib/songimport/dreambeamimport.py index 375867aac..e5afd65f4 100644 --- a/openlp/plugins/songs/lib/dreambeamimport.py +++ b/openlp/plugins/songs/lib/songimport/dreambeamimport.py @@ -35,7 +35,7 @@ import logging from lxml import etree, objectify from openlp.core.lib import translate -from openlp.plugins.songs.lib.songimport import SongImport +from openlp.plugins.songs.lib.songimport.songimport import SongImport from openlp.plugins.songs.lib.ui import SongStrings log = logging.getLogger(__name__) diff --git a/openlp/plugins/songs/lib/easyslidesimport.py b/openlp/plugins/songs/lib/songimport/easyslidesimport.py similarity index 99% rename from openlp/plugins/songs/lib/easyslidesimport.py rename to openlp/plugins/songs/lib/songimport/easyslidesimport.py index ca9a9b755..f30ae49e5 100644 --- a/openlp/plugins/songs/lib/easyslidesimport.py +++ b/openlp/plugins/songs/lib/songimport/easyslidesimport.py @@ -33,7 +33,7 @@ import re from lxml import etree, objectify from openlp.plugins.songs.lib import VerseType -from openlp.plugins.songs.lib.songimport import SongImport +from openlp.plugins.songs.lib.songimport.songimport import SongImport log = logging.getLogger(__name__) diff --git a/openlp/plugins/songs/lib/ewimport.py b/openlp/plugins/songs/lib/songimport/ewimport.py similarity index 100% rename from openlp/plugins/songs/lib/ewimport.py rename to openlp/plugins/songs/lib/songimport/ewimport.py diff --git a/openlp/plugins/songs/lib/foilpresenterimport.py b/openlp/plugins/songs/lib/songimport/foilpresenterimport.py similarity index 99% rename from openlp/plugins/songs/lib/foilpresenterimport.py rename to openlp/plugins/songs/lib/songimport/foilpresenterimport.py index 2b31718c2..67911de76 100644 --- a/openlp/plugins/songs/lib/foilpresenterimport.py +++ b/openlp/plugins/songs/lib/songimport/foilpresenterimport.py @@ -99,10 +99,10 @@ from lxml import etree, objectify from openlp.core.lib import translate from openlp.core.ui.wizard import WizardStrings from openlp.plugins.songs.lib import clean_song, VerseType -from openlp.plugins.songs.lib.songimport import SongImport +from openlp.plugins.songs.lib.songimport.songimport import SongImport from openlp.plugins.songs.lib.db import Author, Book, Song, Topic from openlp.plugins.songs.lib.ui import SongStrings -from openlp.plugins.songs.lib.xml import SongXML +from openlp.plugins.songs.lib.openlyricsxml import SongXML log = logging.getLogger(__name__) diff --git a/openlp/plugins/songs/lib/mediashoutimport.py b/openlp/plugins/songs/lib/songimport/mediashoutimport.py similarity index 98% rename from openlp/plugins/songs/lib/mediashoutimport.py rename to openlp/plugins/songs/lib/songimport/mediashoutimport.py index 99850e950..8eab61a96 100644 --- a/openlp/plugins/songs/lib/mediashoutimport.py +++ b/openlp/plugins/songs/lib/songimport/mediashoutimport.py @@ -33,7 +33,7 @@ a MediaShout database into the OpenLP database. import pyodbc from openlp.core.lib import translate -from openlp.plugins.songs.lib.songimport import SongImport +from openlp.plugins.songs.lib.songimport.songimport import SongImport VERSE_TAGS = ['V', 'C', 'B', 'O', 'P', 'I', 'E'] diff --git a/openlp/plugins/songs/lib/olpimport.py b/openlp/plugins/songs/lib/songimport/olpimport.py similarity index 100% rename from openlp/plugins/songs/lib/olpimport.py rename to openlp/plugins/songs/lib/songimport/olpimport.py diff --git a/openlp/plugins/songs/lib/oooimport.py b/openlp/plugins/songs/lib/songimport/oooimport.py similarity index 100% rename from openlp/plugins/songs/lib/oooimport.py rename to openlp/plugins/songs/lib/songimport/oooimport.py diff --git a/openlp/plugins/songs/lib/openlyricsimport.py b/openlp/plugins/songs/lib/songimport/openlyricsimport.py similarity index 96% rename from openlp/plugins/songs/lib/openlyricsimport.py rename to openlp/plugins/songs/lib/songimport/openlyricsimport.py index 031c5ba72..74329bfd8 100644 --- a/openlp/plugins/songs/lib/openlyricsimport.py +++ b/openlp/plugins/songs/lib/songimport/openlyricsimport.py @@ -37,9 +37,9 @@ import os from lxml import etree from openlp.core.ui.wizard import WizardStrings -from openlp.plugins.songs.lib.songimport import SongImport +from openlp.plugins.songs.lib.songimport.songimport import SongImport from openlp.plugins.songs.lib.ui import SongStrings -from openlp.plugins.songs.lib.xml import OpenLyrics, OpenLyricsError +from openlp.plugins.songs.lib.openlyricsxml import OpenLyrics, OpenLyricsError log = logging.getLogger(__name__) diff --git a/openlp/plugins/songs/lib/opensongimport.py b/openlp/plugins/songs/lib/songimport/opensongimport.py similarity index 99% rename from openlp/plugins/songs/lib/opensongimport.py rename to openlp/plugins/songs/lib/songimport/opensongimport.py index 3d9733dd8..a52b67b0f 100644 --- a/openlp/plugins/songs/lib/opensongimport.py +++ b/openlp/plugins/songs/lib/songimport/opensongimport.py @@ -35,7 +35,7 @@ from lxml.etree import Error, LxmlError from openlp.core.common import translate from openlp.plugins.songs.lib import VerseType -from openlp.plugins.songs.lib.songimport import SongImport +from openlp.plugins.songs.lib.songimport.songimport import SongImport from openlp.plugins.songs.lib.ui import SongStrings log = logging.getLogger(__name__) diff --git a/openlp/plugins/songs/lib/powersongimport.py b/openlp/plugins/songs/lib/songimport/powersongimport.py similarity index 99% rename from openlp/plugins/songs/lib/powersongimport.py rename to openlp/plugins/songs/lib/songimport/powersongimport.py index cd568bc2c..1cad5e33e 100644 --- a/openlp/plugins/songs/lib/powersongimport.py +++ b/openlp/plugins/songs/lib/songimport/powersongimport.py @@ -35,7 +35,7 @@ import fnmatch import os from openlp.core.common import translate -from openlp.plugins.songs.lib.songimport import SongImport +from openlp.plugins.songs.lib.songimport.songimport import SongImport log = logging.getLogger(__name__) diff --git a/openlp/plugins/songs/lib/propresenterimport.py b/openlp/plugins/songs/lib/songimport/propresenterimport.py similarity index 100% rename from openlp/plugins/songs/lib/propresenterimport.py rename to openlp/plugins/songs/lib/songimport/propresenterimport.py diff --git a/openlp/plugins/songs/lib/sofimport.py b/openlp/plugins/songs/lib/songimport/sofimport.py similarity index 100% rename from openlp/plugins/songs/lib/sofimport.py rename to openlp/plugins/songs/lib/songimport/sofimport.py diff --git a/openlp/plugins/songs/lib/songbeamerimport.py b/openlp/plugins/songs/lib/songimport/songbeamerimport.py similarity index 99% rename from openlp/plugins/songs/lib/songbeamerimport.py rename to openlp/plugins/songs/lib/songimport/songbeamerimport.py index 9c5e74c06..fbd016cda 100644 --- a/openlp/plugins/songs/lib/songbeamerimport.py +++ b/openlp/plugins/songs/lib/songimport/songbeamerimport.py @@ -36,7 +36,7 @@ import os import re from openlp.plugins.songs.lib import VerseType -from openlp.plugins.songs.lib.songimport import SongImport +from openlp.plugins.songs.lib.songimport.songimport import SongImport log = logging.getLogger(__name__) diff --git a/openlp/plugins/songs/lib/songimport.py b/openlp/plugins/songs/lib/songimport/songimport.py similarity index 99% rename from openlp/plugins/songs/lib/songimport.py rename to openlp/plugins/songs/lib/songimport/songimport.py index b8fcc604b..5382efbe5 100644 --- a/openlp/plugins/songs/lib/songimport.py +++ b/openlp/plugins/songs/lib/songimport/songimport.py @@ -39,7 +39,7 @@ from openlp.core.ui.wizard import WizardStrings from openlp.plugins.songs.lib import clean_song, VerseType from openlp.plugins.songs.lib.db import Song, Author, Topic, Book, MediaFile from openlp.plugins.songs.lib.ui import SongStrings -from openlp.plugins.songs.lib.xml import SongXML +from openlp.plugins.songs.lib.openlyricsxml import SongXML log = logging.getLogger(__name__) diff --git a/openlp/plugins/songs/lib/songproimport.py b/openlp/plugins/songs/lib/songimport/songproimport.py similarity index 98% rename from openlp/plugins/songs/lib/songproimport.py rename to openlp/plugins/songs/lib/songimport/songproimport.py index 86411a499..853a1d9eb 100644 --- a/openlp/plugins/songs/lib/songproimport.py +++ b/openlp/plugins/songs/lib/songimport/songproimport.py @@ -33,7 +33,7 @@ songs into the OpenLP database. import re from openlp.plugins.songs.lib import strip_rtf -from openlp.plugins.songs.lib.songimport import SongImport +from openlp.plugins.songs.lib.songimport.songimport import SongImport class SongProImport(SongImport): diff --git a/openlp/plugins/songs/lib/songshowplusimport.py b/openlp/plugins/songs/lib/songimport/songshowplusimport.py similarity index 99% rename from openlp/plugins/songs/lib/songshowplusimport.py rename to openlp/plugins/songs/lib/songimport/songshowplusimport.py index aebded029..352e55d96 100644 --- a/openlp/plugins/songs/lib/songshowplusimport.py +++ b/openlp/plugins/songs/lib/songimport/songshowplusimport.py @@ -38,7 +38,7 @@ import struct from openlp.core.ui.wizard import WizardStrings from openlp.plugins.songs.lib import VerseType, retrieve_windows_encoding -from openlp.plugins.songs.lib.songimport import SongImport +from openlp.plugins.songs.lib.songimport.songimport import SongImport TITLE = 1 AUTHOR = 2 diff --git a/openlp/plugins/songs/lib/sundayplusimport.py b/openlp/plugins/songs/lib/songimport/sundayplusimport.py similarity index 99% rename from openlp/plugins/songs/lib/sundayplusimport.py rename to openlp/plugins/songs/lib/songimport/sundayplusimport.py index 5c5f73047..fded3bca3 100644 --- a/openlp/plugins/songs/lib/sundayplusimport.py +++ b/openlp/plugins/songs/lib/songimport/sundayplusimport.py @@ -32,7 +32,7 @@ import re from openlp.plugins.songs.lib import VerseType, retrieve_windows_encoding from openlp.plugins.songs.lib import strip_rtf -from openlp.plugins.songs.lib.songimport import SongImport +from openlp.plugins.songs.lib.songimport.songimport import SongImport HOTKEY_TO_VERSE_TYPE = { '1': 'v1', diff --git a/openlp/plugins/songs/lib/worshipassistantimport.py b/openlp/plugins/songs/lib/songimport/worshipassistantimport.py similarity index 99% rename from openlp/plugins/songs/lib/worshipassistantimport.py rename to openlp/plugins/songs/lib/songimport/worshipassistantimport.py index 772fe8622..412a17c35 100644 --- a/openlp/plugins/songs/lib/worshipassistantimport.py +++ b/openlp/plugins/songs/lib/songimport/worshipassistantimport.py @@ -37,7 +37,7 @@ import re from openlp.core.common import translate from openlp.plugins.songs.lib import VerseType -from openlp.plugins.songs.lib.songimport import SongImport +from openlp.plugins.songs.lib.songimport.songimport import SongImport log = logging.getLogger(__name__) diff --git a/openlp/plugins/songs/lib/worshipcenterproimport.py b/openlp/plugins/songs/lib/songimport/worshipcenterproimport.py similarity index 98% rename from openlp/plugins/songs/lib/worshipcenterproimport.py rename to openlp/plugins/songs/lib/songimport/worshipcenterproimport.py index b24d2ae83..b6c32a8c0 100644 --- a/openlp/plugins/songs/lib/worshipcenterproimport.py +++ b/openlp/plugins/songs/lib/songimport/worshipcenterproimport.py @@ -35,7 +35,7 @@ import logging import pyodbc from openlp.core.common import translate -from openlp.plugins.songs.lib.songimport import SongImport +from openlp.plugins.songs.lib.songimport.songimport import SongImport log = logging.getLogger(__name__) diff --git a/openlp/plugins/songs/lib/wowimport.py b/openlp/plugins/songs/lib/songimport/wowimport.py similarity index 99% rename from openlp/plugins/songs/lib/wowimport.py rename to openlp/plugins/songs/lib/songimport/wowimport.py index c92b0ee2a..c135ca620 100644 --- a/openlp/plugins/songs/lib/wowimport.py +++ b/openlp/plugins/songs/lib/songimport/wowimport.py @@ -34,7 +34,7 @@ import os import logging from openlp.core.common import translate -from openlp.plugins.songs.lib.songimport import SongImport +from openlp.plugins.songs.lib.songimport.songimport import SongImport BLOCK_TYPES = ('V', 'C', 'B') diff --git a/openlp/plugins/songs/lib/zionworximport.py b/openlp/plugins/songs/lib/songimport/zionworximport.py similarity index 98% rename from openlp/plugins/songs/lib/zionworximport.py rename to openlp/plugins/songs/lib/songimport/zionworximport.py index dfdc2373d..8d939f244 100644 --- a/openlp/plugins/songs/lib/zionworximport.py +++ b/openlp/plugins/songs/lib/songimport/zionworximport.py @@ -34,7 +34,7 @@ import csv import logging from openlp.core.common import translate -from openlp.plugins.songs.lib.songimport import SongImport +from openlp.plugins.songs.lib.songimport.songimport import SongImport log = logging.getLogger(__name__) diff --git a/openlp/plugins/songs/lib/songselect.py b/openlp/plugins/songs/lib/songselect.py index 6fd084a47..61b02a66e 100644 --- a/openlp/plugins/songs/lib/songselect.py +++ b/openlp/plugins/songs/lib/songselect.py @@ -38,7 +38,7 @@ from html.parser import HTMLParser from bs4 import BeautifulSoup, NavigableString from openlp.plugins.songs.lib import Song, VerseType, clean_song, Author -from openlp.plugins.songs.lib.xml import SongXML +from openlp.plugins.songs.lib.openlyricsxml import SongXML USER_AGENT = 'Mozilla/5.0 (Linux; U; Android 4.0.3; en-us; GT-I9000 ' \ 'Build/IML74K) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 ' \ diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py index 79fc282a6..c97e3835f 100644 --- a/openlp/plugins/songs/songsplugin.py +++ b/openlp/plugins/songs/songsplugin.py @@ -49,7 +49,7 @@ from openlp.plugins.songs.lib import clean_song, upgrade from openlp.plugins.songs.lib.db import init_schema, Song from openlp.plugins.songs.lib.mediaitem import SongSearch from openlp.plugins.songs.lib.importer import SongFormat -from openlp.plugins.songs.lib.olpimport import OpenLPSongImport +from openlp.plugins.songs.lib.songimport.olpimport import OpenLPSongImport from openlp.plugins.songs.lib.mediaitem import SongMediaItem from openlp.plugins.songs.lib.songstab import SongsTab diff --git a/tests/functional/openlp_plugins/songs/test_ewimport.py b/tests/functional/openlp_plugins/songs/test_ewimport.py index ea557711b..c28dc72aa 100644 --- a/tests/functional/openlp_plugins/songs/test_ewimport.py +++ b/tests/functional/openlp_plugins/songs/test_ewimport.py @@ -35,7 +35,7 @@ from unittest import TestCase from tests.functional import MagicMock, patch -from openlp.plugins.songs.lib.ewimport import EasyWorshipSongImport, FieldDescEntry, FieldType +from openlp.plugins.songs.lib.songimport.ewimport import EasyWorshipSongImport, FieldDescEntry, FieldType TEST_PATH = os.path.abspath( os.path.join(os.path.dirname(__file__), '..', '..', '..', 'resources', 'easyworshipsongs')) @@ -178,7 +178,7 @@ class TestEasyWorshipSongImport(TestCase): Test creating an instance of the EasyWorship file importer """ # GIVEN: A mocked out SongImport class, and a mocked out "manager" - with patch('openlp.plugins.songs.lib.ewimport.SongImport'): + with patch('openlp.plugins.songs.lib.songimport.ewimport.SongImport'): mocked_manager = MagicMock() # WHEN: An importer object is created @@ -192,7 +192,7 @@ class TestEasyWorshipSongImport(TestCase): Test finding an existing field in a given list using the :mod:`find_field` """ # GIVEN: A mocked out SongImport class, a mocked out "manager" and a list of field descriptions. - with patch('openlp.plugins.songs.lib.ewimport.SongImport'): + with patch('openlp.plugins.songs.lib.songimport.ewimport.SongImport'): mocked_manager = MagicMock() importer = EasyWorshipSongImport(mocked_manager, filenames=[]) importer.field_descriptions = TEST_FIELD_DESCS @@ -210,7 +210,7 @@ class TestEasyWorshipSongImport(TestCase): Test finding an non-existing field in a given list using the :mod:`find_field` """ # GIVEN: A mocked out SongImport class, a mocked out "manager" and a list of field descriptions - with patch('openlp.plugins.songs.lib.ewimport.SongImport'): + with patch('openlp.plugins.songs.lib.songimport.ewimport.SongImport'): mocked_manager = MagicMock() importer = EasyWorshipSongImport(mocked_manager, filenames=[]) importer.field_descriptions = TEST_FIELD_DESCS @@ -228,8 +228,8 @@ 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: + with patch('openlp.plugins.songs.lib.songimport.ewimport.SongImport'), \ + patch('openlp.plugins.songs.lib.songimport.ewimport.struct') as mocked_struct: mocked_manager = MagicMock() importer = EasyWorshipSongImport(mocked_manager, filenames=[]) @@ -246,7 +246,7 @@ class TestEasyWorshipSongImport(TestCase): Test the :mod:`get_field` module """ # 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'): + with patch('openlp.plugins.songs.lib.songimport.ewimport.SongImport'): mocked_manager = MagicMock() importer = EasyWorshipSongImport(mocked_manager, filenames=[]) importer.encoding = TEST_DATA_ENCODING @@ -269,7 +269,7 @@ class TestEasyWorshipSongImport(TestCase): """ for test_results in GET_MEMO_FIELD_TEST_RESULTS: # GIVEN: A mocked out SongImport class, a mocked out "manager", a mocked out memo_file and an encoding - with patch('openlp.plugins.songs.lib.ewimport.SongImport'): + with patch('openlp.plugins.songs.lib.songimport.ewimport.SongImport'): mocked_manager = MagicMock() mocked_memo_file = MagicMock() importer = EasyWorshipSongImport(mocked_manager, filenames=[]) @@ -300,8 +300,8 @@ class TestEasyWorshipSongImport(TestCase): Test the :mod:`do_import` module opens the correct files """ # 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: + with patch('openlp.plugins.songs.lib.songimport.ewimport.SongImport'), \ + patch('openlp.plugins.songs.lib.songimport.ewimport.os.path') as mocked_os_path: mocked_manager = MagicMock() importer = EasyWorshipSongImport(mocked_manager, filenames=[]) mocked_os_path.isfile.side_effect = [True, False] @@ -319,8 +319,8 @@ class TestEasyWorshipSongImport(TestCase): Test the :mod:`do_import` module produces an error when Songs.MB not found. """ # 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: + with patch('openlp.plugins.songs.lib.songimport.ewimport.SongImport'), \ + patch('openlp.plugins.songs.lib.songimport.ewimport.os.path') as mocked_os_path: mocked_manager = MagicMock() importer = EasyWorshipSongImport(mocked_manager, filenames=[]) importer.log_error = MagicMock() @@ -339,8 +339,8 @@ class TestEasyWorshipSongImport(TestCase): Test the :mod:`do_import` module handles invalid database files correctly """ # 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: + with patch('openlp.plugins.songs.lib.songimport.ewimport.SongImport'), \ + patch('openlp.plugins.songs.lib.songimport.ewimport.os.path') as mocked_os_path: mocked_manager = MagicMock() importer = EasyWorshipSongImport(mocked_manager, filenames=[]) mocked_os_path.isfile.return_value = True @@ -358,10 +358,10 @@ class TestEasyWorshipSongImport(TestCase): Test the :mod:`do_import` module handles invalid memo files correctly """ # 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, \ + with patch('openlp.plugins.songs.lib.songimport.ewimport.SongImport'), \ + patch('openlp.plugins.songs.lib.songimport.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.songimport.ewimport.struct') as mocked_struct: mocked_manager = MagicMock() importer = EasyWorshipSongImport(mocked_manager, filenames=[]) mocked_os_path.isfile.return_value = True @@ -385,10 +385,10 @@ class TestEasyWorshipSongImport(TestCase): Test the :mod:`do_import` converts the code page to the encoding correctly """ # 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('builtins.open'), patch('openlp.plugins.songs.lib.ewimport.struct') as mocked_struct, \ - patch('openlp.plugins.songs.lib.ewimport.retrieve_windows_encoding') as \ + with patch('openlp.plugins.songs.lib.songimport.ewimport.SongImport'), \ + patch('openlp.plugins.songs.lib.songimport.ewimport.os.path') as mocked_os_path, \ + patch('builtins.open'), patch('openlp.plugins.songs.lib.songimport.ewimport.struct') as mocked_struct, \ + patch('openlp.plugins.songs.lib.songimport.ewimport.retrieve_windows_encoding') as \ mocked_retrieve_windows_encoding: mocked_manager = MagicMock() importer = EasyWorshipSongImport(mocked_manager, filenames=[]) @@ -413,8 +413,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 \ + with patch('openlp.plugins.songs.lib.songimport.ewimport.SongImport'), \ + patch('openlp.plugins.songs.lib.songimport.ewimport.retrieve_windows_encoding') as \ mocked_retrieve_windows_encoding: mocked_retrieve_windows_encoding.return_value = 'cp1252' mocked_manager = MagicMock() @@ -469,8 +469,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') \ + with patch('openlp.plugins.songs.lib.songimport.ewimport.SongImport'), \ + patch('openlp.plugins.songs.lib.songimport.ewimport.retrieve_windows_encoding') \ as mocked_retrieve_windows_encoding: mocked_retrieve_windows_encoding.return_value = 'cp1252' mocked_manager = MagicMock() @@ -509,7 +509,7 @@ class TestEasyWorshipSongImport(TestCase): """ # GIVEN: A mocked out SongImport class, a mocked out "manager" and mocked out "author" method. - with patch('openlp.plugins.songs.lib.ewimport.SongImport'): + with patch('openlp.plugins.songs.lib.songimport.ewimport.SongImport'): mocked_manager = MagicMock() mocked_add_author = MagicMock() importer = EasyWorshipSongImportLogger(mocked_manager) diff --git a/tests/functional/openlp_plugins/songs/test_foilpresenterimport.py b/tests/functional/openlp_plugins/songs/test_foilpresenterimport.py index 61206b9fa..15247a361 100644 --- a/tests/functional/openlp_plugins/songs/test_foilpresenterimport.py +++ b/tests/functional/openlp_plugins/songs/test_foilpresenterimport.py @@ -34,7 +34,7 @@ import os from unittest import TestCase from tests.functional import patch, MagicMock -from openlp.plugins.songs.lib.foilpresenterimport import FoilPresenter +from openlp.plugins.songs.lib.songimport.foilpresenterimport import FoilPresenter TEST_PATH = os.path.abspath( os.path.join(os.path.dirname(__file__), '..', '..', '..', '/resources/foilpresentersongs')) @@ -57,27 +57,27 @@ class TestFoilPresenter(TestCase): # _process_topics def setUp(self): - self.child_patcher = patch('openlp.plugins.songs.lib.foilpresenterimport.FoilPresenter._child') - self.clean_song_patcher = patch('openlp.plugins.songs.lib.foilpresenterimport.clean_song') - self.objectify_patcher = patch('openlp.plugins.songs.lib.foilpresenterimport.objectify') + self.child_patcher = patch('openlp.plugins.songs.lib.songimport.foilpresenterimport.FoilPresenter._child') + self.clean_song_patcher = patch('openlp.plugins.songs.lib.songimport.foilpresenterimport.clean_song') + self.objectify_patcher = patch('openlp.plugins.songs.lib.songimport.foilpresenterimport.objectify') self.process_authors_patcher = \ - patch('openlp.plugins.songs.lib.foilpresenterimport.FoilPresenter._process_authors') + patch('openlp.plugins.songs.lib.songimport.foilpresenterimport.FoilPresenter._process_authors') self.process_cclinumber_patcher = \ - patch('openlp.plugins.songs.lib.foilpresenterimport.FoilPresenter._process_cclinumber') + patch('openlp.plugins.songs.lib.songimport.foilpresenterimport.FoilPresenter._process_cclinumber') self.process_comments_patcher = \ - patch('openlp.plugins.songs.lib.foilpresenterimport.FoilPresenter._process_comments') + patch('openlp.plugins.songs.lib.songimport.foilpresenterimport.FoilPresenter._process_comments') self.process_lyrics_patcher = \ - patch('openlp.plugins.songs.lib.foilpresenterimport.FoilPresenter._process_lyrics') + patch('openlp.plugins.songs.lib.songimport.foilpresenterimport.FoilPresenter._process_lyrics') self.process_songbooks_patcher = \ - patch('openlp.plugins.songs.lib.foilpresenterimport.FoilPresenter._process_songbooks') + patch('openlp.plugins.songs.lib.songimport.foilpresenterimport.FoilPresenter._process_songbooks') self.process_titles_patcher = \ - patch('openlp.plugins.songs.lib.foilpresenterimport.FoilPresenter._process_titles') + patch('openlp.plugins.songs.lib.songimport.foilpresenterimport.FoilPresenter._process_titles') self.process_topics_patcher = \ - patch('openlp.plugins.songs.lib.foilpresenterimport.FoilPresenter._process_topics') - self.re_patcher = patch('openlp.plugins.songs.lib.foilpresenterimport.re') - self.song_patcher = patch('openlp.plugins.songs.lib.foilpresenterimport.Song') - self.song_xml_patcher = patch('openlp.plugins.songs.lib.foilpresenterimport.SongXML') - self.translate_patcher = patch('openlp.plugins.songs.lib.foilpresenterimport.translate') + patch('openlp.plugins.songs.lib.songimport.foilpresenterimport.FoilPresenter._process_topics') + self.re_patcher = patch('openlp.plugins.songs.lib.songimport.foilpresenterimport.re') + self.song_patcher = patch('openlp.plugins.songs.lib.songimport.foilpresenterimport.Song') + self.song_xml_patcher = patch('openlp.plugins.songs.lib.songimport.foilpresenterimport.SongXML') + self.translate_patcher = patch('openlp.plugins.songs.lib.songimport.foilpresenterimport.translate') self.mocked_child = self.child_patcher.start() self.mocked_clean_song = self.clean_song_patcher.start() diff --git a/tests/functional/openlp_plugins/songs/test_openlyricsimport.py b/tests/functional/openlp_plugins/songs/test_openlyricsimport.py index 93ecafb78..2166b950c 100644 --- a/tests/functional/openlp_plugins/songs/test_openlyricsimport.py +++ b/tests/functional/openlp_plugins/songs/test_openlyricsimport.py @@ -34,8 +34,8 @@ import os from unittest import TestCase from tests.functional import MagicMock, patch -from openlp.plugins.songs.lib.openlyricsimport import OpenLyricsImport -from openlp.plugins.songs.lib.songimport import SongImport +from openlp.plugins.songs.lib.songimport.openlyricsimport import OpenLyricsImport +from openlp.plugins.songs.lib.songimport.songimport import SongImport TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..', 'resources', 'openlyricssongs')) @@ -69,7 +69,7 @@ class TestOpenLyricsImport(TestCase): Test creating an instance of the OpenLyrics file importer """ # GIVEN: A mocked out SongImport class, and a mocked out "manager" - with patch('openlp.plugins.songs.lib.songbeamerimport.SongImport'): + with patch('openlp.plugins.songs.lib.songimport.openlyricsimport.SongImport'): mocked_manager = MagicMock() # WHEN: An importer object is created diff --git a/tests/functional/openlp_plugins/songs/test_opensongimport.py b/tests/functional/openlp_plugins/songs/test_opensongimport.py index 96d6bff0b..8e7fee0af 100644 --- a/tests/functional/openlp_plugins/songs/test_opensongimport.py +++ b/tests/functional/openlp_plugins/songs/test_opensongimport.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- + # -*- coding: utf-8 -*- # vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### @@ -34,7 +34,7 @@ import os from unittest import TestCase from tests.helpers.songfileimport import SongImportTestHelper -from openlp.plugins.songs.lib.opensongimport import OpenSongImport +from openlp.plugins.songs.lib.songimport.opensongimport import OpenSongImport from tests.functional import patch, MagicMock TEST_PATH = os.path.abspath( @@ -69,7 +69,7 @@ class TestOpenSongImport(TestCase): Test creating an instance of the OpenSong file importer """ # GIVEN: A mocked out SongImport class, and a mocked out "manager" - with patch('openlp.plugins.songs.lib.opensongimport.SongImport'): + with patch('openlp.plugins.songs.lib.songimport.opensongimport.SongImport'): mocked_manager = MagicMock() # WHEN: An importer object is created @@ -83,7 +83,7 @@ class TestOpenSongImport(TestCase): Test OpenSongImport.do_import handles different invalid import_source values """ # GIVEN: A mocked out SongImport class, and a mocked out "manager" - with patch('openlp.plugins.songs.lib.opensongimport.SongImport'): + with patch('openlp.plugins.songs.lib.songimport.opensongimport.SongImport'): mocked_manager = MagicMock() mocked_import_wizard = MagicMock() importer = OpenSongImport(mocked_manager, filenames=[]) @@ -104,7 +104,7 @@ class TestOpenSongImport(TestCase): Test OpenSongImport.do_import handles different invalid import_source values """ # GIVEN: A mocked out SongImport class, and a mocked out "manager" - with patch('openlp.plugins.songs.lib.opensongimport.SongImport'): + with patch('openlp.plugins.songs.lib.songimport.opensongimport.SongImport'): mocked_manager = MagicMock() mocked_import_wizard = MagicMock() importer = OpenSongImport(mocked_manager, filenames=[]) diff --git a/tests/functional/openlp_plugins/songs/test_songbeamerimport.py b/tests/functional/openlp_plugins/songs/test_songbeamerimport.py index a69d4a86c..9ca0ab790 100644 --- a/tests/functional/openlp_plugins/songs/test_songbeamerimport.py +++ b/tests/functional/openlp_plugins/songs/test_songbeamerimport.py @@ -34,7 +34,7 @@ import os from unittest import TestCase from tests.functional import MagicMock, patch -from openlp.plugins.songs.lib.songbeamerimport import SongBeamerImport +from openlp.plugins.songs.lib.songimport.songbeamerimport import SongBeamerImport from openlp.plugins.songs.lib import VerseType TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), @@ -64,7 +64,7 @@ class TestSongBeamerImport(TestCase): Test creating an instance of the SongBeamer file importer """ # GIVEN: A mocked out SongImport class, and a mocked out "manager" - with patch('openlp.plugins.songs.lib.songbeamerimport.SongImport'): + with patch('openlp.plugins.songs.lib.songimport.songbeamerimport.SongImport'): mocked_manager = MagicMock() # WHEN: An importer object is created @@ -78,7 +78,7 @@ class TestSongBeamerImport(TestCase): Test SongBeamerImport.do_import handles different invalid import_source values """ # GIVEN: A mocked out SongImport class, and a mocked out "manager" - with patch('openlp.plugins.songs.lib.songbeamerimport.SongImport'): + with patch('openlp.plugins.songs.lib.songimport.songbeamerimport.SongImport'): mocked_manager = MagicMock() mocked_import_wizard = MagicMock() importer = SongBeamerImport(mocked_manager, filenames=[]) @@ -99,7 +99,7 @@ class TestSongBeamerImport(TestCase): Test SongBeamerImport.do_import handles different invalid import_source values """ # GIVEN: A mocked out SongImport class, and a mocked out "manager" - with patch('openlp.plugins.songs.lib.songbeamerimport.SongImport'): + with patch('openlp.plugins.songs.lib.songimport.songbeamerimport.SongImport'): mocked_manager = MagicMock() mocked_import_wizard = MagicMock() importer = SongBeamerImport(mocked_manager, filenames=[]) @@ -122,7 +122,7 @@ class TestSongBeamerImport(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.songbeamerimport.SongImport'): + with patch('openlp.plugins.songs.lib.songimport.songbeamerimport.SongImport'): for song_file in SONG_TEST_DATA: mocked_manager = MagicMock() mocked_import_wizard = MagicMock() diff --git a/tests/functional/openlp_plugins/songs/test_songshowplusimport.py b/tests/functional/openlp_plugins/songs/test_songshowplusimport.py index dfee265e3..8d6a42287 100644 --- a/tests/functional/openlp_plugins/songs/test_songshowplusimport.py +++ b/tests/functional/openlp_plugins/songs/test_songshowplusimport.py @@ -35,7 +35,7 @@ from unittest import TestCase from tests.helpers.songfileimport import SongImportTestHelper from openlp.plugins.songs.lib import VerseType -from openlp.plugins.songs.lib.songshowplusimport import SongShowPlusImport +from openlp.plugins.songs.lib.songimport.songshowplusimport import SongShowPlusImport from tests.functional import patch, MagicMock TEST_PATH = os.path.abspath( @@ -70,7 +70,7 @@ class TestSongShowPlusImport(TestCase): Test creating an instance of the SongShow Plus file importer """ # GIVEN: A mocked out SongImport class, and a mocked out "manager" - with patch('openlp.plugins.songs.lib.songshowplusimport.SongImport'): + with patch('openlp.plugins.songs.lib.songimport.songshowplusimport.SongImport'): mocked_manager = MagicMock() # WHEN: An importer object is created @@ -84,7 +84,7 @@ class TestSongShowPlusImport(TestCase): Test SongShowPlusImport.do_import handles different invalid import_source values """ # GIVEN: A mocked out SongImport class, and a mocked out "manager" - with patch('openlp.plugins.songs.lib.songshowplusimport.SongImport'): + with patch('openlp.plugins.songs.lib.songimport.songshowplusimport.SongImport'): mocked_manager = MagicMock() mocked_import_wizard = MagicMock() importer = SongShowPlusImport(mocked_manager, filenames=[]) @@ -105,7 +105,7 @@ class TestSongShowPlusImport(TestCase): Test SongShowPlusImport.do_import handles different invalid import_source values """ # GIVEN: A mocked out SongImport class, and a mocked out "manager" - with patch('openlp.plugins.songs.lib.songshowplusimport.SongImport'): + with patch('openlp.plugins.songs.lib.songimport.songshowplusimport.SongImport'): mocked_manager = MagicMock() mocked_import_wizard = MagicMock() importer = SongShowPlusImport(mocked_manager, filenames=[]) @@ -126,7 +126,7 @@ class TestSongShowPlusImport(TestCase): Test to_openlp_verse_tag method by simulating adding a verse """ # GIVEN: A mocked out SongImport class, and a mocked out "manager" - with patch('openlp.plugins.songs.lib.songshowplusimport.SongImport'): + with patch('openlp.plugins.songs.lib.songimport.songshowplusimport.SongImport'): mocked_manager = MagicMock() importer = SongShowPlusImport(mocked_manager, filenames=[]) @@ -154,7 +154,7 @@ class TestSongShowPlusImport(TestCase): Test to_openlp_verse_tag method by simulating adding a verse to the verse order """ # GIVEN: A mocked out SongImport class, and a mocked out "manager" - with patch('openlp.plugins.songs.lib.songshowplusimport.SongImport'): + with patch('openlp.plugins.songs.lib.songimport.songshowplusimport.SongImport'): mocked_manager = MagicMock() importer = SongShowPlusImport(mocked_manager, filenames=[]) diff --git a/tests/functional/openlp_plugins/songs/test_worshipcenterproimport.py b/tests/functional/openlp_plugins/songs/test_worshipcenterproimport.py index 9a58a6c2b..263397cc9 100644 --- a/tests/functional/openlp_plugins/songs/test_worshipcenterproimport.py +++ b/tests/functional/openlp_plugins/songs/test_worshipcenterproimport.py @@ -37,7 +37,7 @@ if os.name != 'nt': import pyodbc -from openlp.plugins.songs.lib.worshipcenterproimport import WorshipCenterProImport +from openlp.plugins.songs.lib.songimport.worshipcenterproimport import WorshipCenterProImport from tests.functional import patch, MagicMock @@ -141,7 +141,7 @@ class TestWorshipCenterProSongImport(TestCase): Test creating an instance of the WorshipCenter Pro file importer """ # GIVEN: A mocked out SongImport class, and a mocked out "manager" - with patch('openlp.plugins.songs.lib.worshipcenterproimport.SongImport'): + with patch('openlp.plugins.songs.lib.songimport.worshipcenterproimport.SongImport'): mocked_manager = MagicMock() # WHEN: An importer object is created diff --git a/tests/functional/openlp_plugins/songs/test_zionworximport.py b/tests/functional/openlp_plugins/songs/test_zionworximport.py index c5669e9c8..a3f5bb20b 100644 --- a/tests/functional/openlp_plugins/songs/test_zionworximport.py +++ b/tests/functional/openlp_plugins/songs/test_zionworximport.py @@ -33,8 +33,8 @@ This module contains tests for the ZionWorx song importer. from unittest import TestCase from tests.functional import MagicMock, patch -from openlp.plugins.songs.lib.zionworximport import ZionWorxImport -from openlp.plugins.songs.lib.songimport import SongImport +from openlp.plugins.songs.lib.songimport.zionworximport import ZionWorxImport +from openlp.plugins.songs.lib.songimport.songimport import SongImport class TestZionWorxImport(TestCase): @@ -46,7 +46,7 @@ class TestZionWorxImport(TestCase): Test creating an instance of the ZionWorx file importer """ # GIVEN: A mocked out SongImport class, and a mocked out "manager" - with patch('openlp.plugins.songs.lib.zionworximport.SongImport'): + with patch('openlp.plugins.songs.lib.songimport.zionworximport.SongImport'): mocked_manager = MagicMock() # WHEN: An importer object is created diff --git a/tests/helpers/songfileimport.py b/tests/helpers/songfileimport.py index 80b2ee268..0b0e3515d 100644 --- a/tests/helpers/songfileimport.py +++ b/tests/helpers/songfileimport.py @@ -43,7 +43,7 @@ class SongImportTestHelper(TestCase): def __init__(self, *args, **kwargs): super(SongImportTestHelper, self).__init__(*args, **kwargs) self.importer_module = __import__( - 'openlp.plugins.songs.lib.%s' % self.importer_module_name, fromlist=[self.importer_class_name]) + 'openlp.plugins.songs.lib.songimport.%s' % self.importer_module_name, fromlist=[self.importer_class_name]) self.importer_class = getattr(self.importer_module, self.importer_class_name) def setUp(self): @@ -51,14 +51,14 @@ class SongImportTestHelper(TestCase): Patch and set up the mocks required. """ self.add_copyright_patcher = patch( - 'openlp.plugins.songs.lib.%s.%s.add_copyright' % (self.importer_module_name, self.importer_class_name)) + 'openlp.plugins.songs.lib.songimport.%s.%s.add_copyright' % (self.importer_module_name, self.importer_class_name)) self.add_verse_patcher = patch( - 'openlp.plugins.songs.lib.%s.%s.add_verse' % (self.importer_module_name, self.importer_class_name)) + 'openlp.plugins.songs.lib.songimport.%s.%s.add_verse' % (self.importer_module_name, self.importer_class_name)) self.finish_patcher = patch( - 'openlp.plugins.songs.lib.%s.%s.finish' % (self.importer_module_name, self.importer_class_name)) + 'openlp.plugins.songs.lib.songimport.%s.%s.finish' % (self.importer_module_name, self.importer_class_name)) self.add_author_patcher = patch( - 'openlp.plugins.songs.lib.%s.%s.add_author' % (self.importer_module_name, self.importer_class_name)) - self.song_import_patcher = patch('openlp.plugins.songs.lib.%s.SongImport' % self.importer_module_name) + 'openlp.plugins.songs.lib.songimport.%s.%s.add_author' % (self.importer_module_name, self.importer_class_name)) + self.song_import_patcher = patch('openlp.plugins.songs.lib.songimport.%s.SongImport' % self.importer_module_name) self.mocked_add_copyright = self.add_copyright_patcher.start() self.mocked_add_verse = self.add_verse_patcher.start() self.mocked_finish = self.finish_patcher.start() From 3b7d5f53babe6856d1b51e7e566071ed8a026269 Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Thu, 3 Jul 2014 19:57:13 +0200 Subject: [PATCH 12/17] PEP8 --- openlp/plugins/songs/lib/songimport/__init__.py | 2 +- .../openlp_plugins/songs/test_opensongimport.py | 2 +- .../songs/test_worshipcenterproimport.py | 12 ++++++------ tests/helpers/songfileimport.py | 12 ++++++++---- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/openlp/plugins/songs/lib/songimport/__init__.py b/openlp/plugins/songs/lib/songimport/__init__.py index f57136ecf..da302572e 100644 --- a/openlp/plugins/songs/lib/songimport/__init__.py +++ b/openlp/plugins/songs/lib/songimport/__init__.py @@ -27,5 +27,5 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### """ -The :mod:`~openlp.plugins.songs.lib.import` module contains a importers for the Songs plugin. +The :mod:`~openlp.plugins.songs.lib.import` module contains importers for the Songs plugin. """ diff --git a/tests/functional/openlp_plugins/songs/test_opensongimport.py b/tests/functional/openlp_plugins/songs/test_opensongimport.py index 8e7fee0af..09fad7bc3 100644 --- a/tests/functional/openlp_plugins/songs/test_opensongimport.py +++ b/tests/functional/openlp_plugins/songs/test_opensongimport.py @@ -1,4 +1,4 @@ - # -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- # vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### diff --git a/tests/functional/openlp_plugins/songs/test_worshipcenterproimport.py b/tests/functional/openlp_plugins/songs/test_worshipcenterproimport.py index 263397cc9..27c688aa0 100644 --- a/tests/functional/openlp_plugins/songs/test_worshipcenterproimport.py +++ b/tests/functional/openlp_plugins/songs/test_worshipcenterproimport.py @@ -156,9 +156,9 @@ class TestWorshipCenterProSongImport(TestCase): """ # GIVEN: A mocked out SongImport class, a mocked out pyodbc module, a mocked out translate method, # 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: + with patch('openlp.plugins.songs.lib.songimport.worshipcenterproimport.SongImport'), \ + patch('openlp.plugins.songs.lib.songimport.worshipcenterproimport.pyodbc.connect') as mocked_pyodbc_connect, \ + patch('openlp.plugins.songs.lib.songimport.worshipcenterproimport.translate') as mocked_translate: mocked_manager = MagicMock() mocked_log_error = MagicMock() mocked_translate.return_value = 'Translated Text' @@ -185,9 +185,9 @@ class TestWorshipCenterProSongImport(TestCase): """ # GIVEN: A mocked out SongImport class, a mocked out pyodbc module with a simulated recordset, a mocked out # 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: + with patch('openlp.plugins.songs.lib.songimport.worshipcenterproimport.SongImport'), \ + patch('openlp.plugins.songs.lib.songimport.worshipcenterproimport.pyodbc') as mocked_pyodbc, \ + patch('openlp.plugins.songs.lib.songimport.worshipcenterproimport.translate') as mocked_translate: mocked_manager = MagicMock() mocked_import_wizard = MagicMock() mocked_add_verse = MagicMock() diff --git a/tests/helpers/songfileimport.py b/tests/helpers/songfileimport.py index 0b0e3515d..003ade543 100644 --- a/tests/helpers/songfileimport.py +++ b/tests/helpers/songfileimport.py @@ -51,14 +51,18 @@ class SongImportTestHelper(TestCase): Patch and set up the mocks required. """ self.add_copyright_patcher = patch( - 'openlp.plugins.songs.lib.songimport.%s.%s.add_copyright' % (self.importer_module_name, self.importer_class_name)) + 'openlp.plugins.songs.lib.songimport.%s.%s.add_copyright' % (self.importer_module_name, + self.importer_class_name)) self.add_verse_patcher = patch( - 'openlp.plugins.songs.lib.songimport.%s.%s.add_verse' % (self.importer_module_name, self.importer_class_name)) + 'openlp.plugins.songs.lib.songimport.%s.%s.add_verse' % (self.importer_module_name, + self.importer_class_name)) self.finish_patcher = patch( 'openlp.plugins.songs.lib.songimport.%s.%s.finish' % (self.importer_module_name, self.importer_class_name)) self.add_author_patcher = patch( - 'openlp.plugins.songs.lib.songimport.%s.%s.add_author' % (self.importer_module_name, self.importer_class_name)) - self.song_import_patcher = patch('openlp.plugins.songs.lib.songimport.%s.SongImport' % self.importer_module_name) + 'openlp.plugins.songs.lib.songimport.%s.%s.add_author' % (self.importer_module_name, + self.importer_class_name)) + self.song_import_patcher = patch('openlp.plugins.songs.lib.songimport.%s.SongImport' % + self.importer_module_name) self.mocked_add_copyright = self.add_copyright_patcher.start() self.mocked_add_verse = self.add_verse_patcher.start() self.mocked_finish = self.finish_patcher.start() From c9b47e8e6f89ffd12905ee55cb50680557c22cb9 Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Thu, 3 Jul 2014 19:57:46 +0200 Subject: [PATCH 13/17] PEP8 --- .../openlp_plugins/songs/test_worshipcenterproimport.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/functional/openlp_plugins/songs/test_worshipcenterproimport.py b/tests/functional/openlp_plugins/songs/test_worshipcenterproimport.py index 27c688aa0..0558ad195 100644 --- a/tests/functional/openlp_plugins/songs/test_worshipcenterproimport.py +++ b/tests/functional/openlp_plugins/songs/test_worshipcenterproimport.py @@ -157,7 +157,8 @@ class TestWorshipCenterProSongImport(TestCase): # GIVEN: A mocked out SongImport class, a mocked out pyodbc module, a mocked out translate method, # a mocked "manager" and a mocked out log_error method. with patch('openlp.plugins.songs.lib.songimport.worshipcenterproimport.SongImport'), \ - patch('openlp.plugins.songs.lib.songimport.worshipcenterproimport.pyodbc.connect') as mocked_pyodbc_connect, \ + patch('openlp.plugins.songs.lib.songimport.worshipcenterproimport.pyodbc.connect') \ + as mocked_pyodbc_connect, \ patch('openlp.plugins.songs.lib.songimport.worshipcenterproimport.translate') as mocked_translate: mocked_manager = MagicMock() mocked_log_error = MagicMock() From 686f8d243746404c7e3dd70c979b25c531798a78 Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Fri, 4 Jul 2014 11:31:06 +0200 Subject: [PATCH 14/17] More renaming --- openlp/plugins/songs/lib/importer.py | 54 +++++++++---------- .../lib/{songimport => importers}/__init__.py | 0 .../cclifile.py} | 0 .../dreambeam.py} | 2 +- .../easyslides.py} | 2 +- .../ewimport.py => importers/easyworship.py} | 0 .../foilpresenter.py} | 2 +- .../mediashout.py} | 2 +- .../olpimport.py => importers/openlp.py} | 0 .../openlyrics.py} | 2 +- .../oooimport.py => importers/openoffice.py} | 2 +- .../opensong.py} | 2 +- .../powersong.py} | 4 +- .../propresenter.py} | 0 .../songbeamer.py} | 2 +- .../{songimport => importers}/songimport.py | 0 .../songproimport.py => importers/songpro.py} | 2 +- .../songshowplus.py} | 2 +- .../songsoffellowship.py} | 8 +-- .../sundayplus.py} | 2 +- .../wordsofworship.py} | 4 +- .../worshipassistant.py} | 4 +- .../worshipcenterpro.py} | 2 +- .../zionworx.py} | 2 +- openlp/plugins/songs/songsplugin.py | 2 +- .../openlp_plugins/songs/test_ewimport.py | 52 +++++++++--------- .../songs/test_foilpresenterimport.py | 30 +++++------ .../songs/test_openlyricsimport.py | 6 +-- .../songs/test_opensongimport.py | 10 ++-- .../songs/test_propresenterimport.py | 2 +- .../songs/test_songbeamerimport.py | 10 ++-- .../songs/test_songshowplusimport.py | 14 ++--- .../songs/test_worshipassistantimport.py | 2 +- .../songs/test_worshipcenterproimport.py | 16 +++--- .../songs/test_zionworximport.py | 6 +-- tests/helpers/songfileimport.py | 12 ++--- 36 files changed, 131 insertions(+), 131 deletions(-) rename openlp/plugins/songs/lib/{songimport => importers}/__init__.py (100%) rename openlp/plugins/songs/lib/{songimport/cclifileimport.py => importers/cclifile.py} (100%) rename openlp/plugins/songs/lib/{songimport/dreambeamimport.py => importers/dreambeam.py} (99%) rename openlp/plugins/songs/lib/{songimport/easyslidesimport.py => importers/easyslides.py} (99%) rename openlp/plugins/songs/lib/{songimport/ewimport.py => importers/easyworship.py} (100%) rename openlp/plugins/songs/lib/{songimport/foilpresenterimport.py => importers/foilpresenter.py} (99%) rename openlp/plugins/songs/lib/{songimport/mediashoutimport.py => importers/mediashout.py} (98%) rename openlp/plugins/songs/lib/{songimport/olpimport.py => importers/openlp.py} (100%) rename openlp/plugins/songs/lib/{songimport/openlyricsimport.py => importers/openlyrics.py} (98%) rename openlp/plugins/songs/lib/{songimport/oooimport.py => importers/openoffice.py} (99%) rename openlp/plugins/songs/lib/{songimport/opensongimport.py => importers/opensong.py} (99%) rename openlp/plugins/songs/lib/{songimport/powersongimport.py => importers/powersong.py} (98%) rename openlp/plugins/songs/lib/{songimport/propresenterimport.py => importers/propresenter.py} (100%) rename openlp/plugins/songs/lib/{songimport/songbeamerimport.py => importers/songbeamer.py} (99%) rename openlp/plugins/songs/lib/{songimport => importers}/songimport.py (100%) rename openlp/plugins/songs/lib/{songimport/songproimport.py => importers/songpro.py} (98%) rename openlp/plugins/songs/lib/{songimport/songshowplusimport.py => importers/songshowplus.py} (99%) rename openlp/plugins/songs/lib/{songimport/sofimport.py => importers/songsoffellowship.py} (98%) rename openlp/plugins/songs/lib/{songimport/sundayplusimport.py => importers/sundayplus.py} (99%) rename openlp/plugins/songs/lib/{songimport/wowimport.py => importers/wordsofworship.py} (98%) rename openlp/plugins/songs/lib/{songimport/worshipassistantimport.py => importers/worshipassistant.py} (98%) rename openlp/plugins/songs/lib/{songimport/worshipcenterproimport.py => importers/worshipcenterpro.py} (98%) rename openlp/plugins/songs/lib/{songimport/zionworximport.py => importers/zionworx.py} (98%) diff --git a/openlp/plugins/songs/lib/importer.py b/openlp/plugins/songs/lib/importer.py index 9c0b889ca..bb622bcf9 100644 --- a/openlp/plugins/songs/lib/importer.py +++ b/openlp/plugins/songs/lib/importer.py @@ -34,23 +34,23 @@ import logging from openlp.core.common import translate, UiStrings from openlp.core.ui.wizard import WizardStrings -from .songimport.opensongimport import OpenSongImport -from .songimport.easyslidesimport import EasySlidesImport -from .songimport.olpimport import OpenLPSongImport -from .songimport.openlyricsimport import OpenLyricsImport -from .songimport.wowimport import WowImport -from .songimport.cclifileimport import CCLIFileImport -from .songimport.dreambeamimport import DreamBeamImport -from .songimport.powersongimport import PowerSongImport -from .songimport.ewimport import EasyWorshipSongImport -from .songimport.songbeamerimport import SongBeamerImport -from .songimport.songshowplusimport import SongShowPlusImport -from .songimport.songproimport import SongProImport -from .songimport.sundayplusimport import SundayPlusImport -from .songimport.foilpresenterimport import FoilPresenterImport -from .songimport.zionworximport import ZionWorxImport -from .songimport.propresenterimport import ProPresenterImport -from .songimport.worshipassistantimport import WorshipAssistantImport +from .importers.opensong import OpenSongImport +from .importers.easyslides import EasySlidesImport +from .importers.openlp import OpenLPSongImport +from .importers.openlyrics import OpenLyricsImport +from .importers.wordsofworship import WordsOfWorshipImport +from .importers.cclifile import CCLIFileImport +from .importers.dreambeam import DreamBeamImport +from .importers.powersong import PowerSongImport +from .importers.easyworship import EasyWorshipSongImport +from .importers.songbeamer import SongBeamerImport +from .importers.songshowplus import SongShowPlusImport +from .importers.songpro import SongProImport +from .importers.sundayplus import SundayPlusImport +from .importers.foilpresenter import FoilPresenterImport +from .importers.zionworx import ZionWorxImport +from .importers.propresenter import ProPresenterImport +from .importers.worshipassistant import WorshipAssistantImport # Imports that might fail @@ -58,13 +58,13 @@ log = logging.getLogger(__name__) try: - from .sofimport import SofImport + from .importers.songsoffellowship import SongsOfFellowshipImport HAS_SOF = True except ImportError: - log.exception('Error importing %s', 'SofImport') + log.exception('Error importing %s', 'SongsOfFellowshipImport') HAS_SOF = False try: - from .oooimport import OooImport + from .importers.openoffice import OpenOfficeImport HAS_OOO = True except ImportError: log.exception('Error importing %s', 'OooImport') @@ -72,14 +72,14 @@ except ImportError: HAS_MEDIASHOUT = False if os.name == 'nt': try: - from .mediashoutimport import MediaShoutImport + from .importers.mediashout import MediaShoutImport HAS_MEDIASHOUT = True except ImportError: log.exception('Error importing %s', 'MediaShoutImport') HAS_WORSHIPCENTERPRO = False if os.name == 'nt': try: - from .worshipcenterproimport import WorshipCenterProImport + from .importers.worshipcenterpro import WorshipCenterProImport HAS_WORSHIPCENTERPRO = True except ImportError: log.exception('Error importing %s', 'WorshipCenterProImport') @@ -109,7 +109,7 @@ class SongFormat(object): Name of the format, e.g. ``'OpenLyrics'`` ``'prefix'`` - Prefix for Qt objects. Use mixedCase, e.g. ``'open_lyrics'`` + Prefix for Qt objects. Use mixedCase, e.g. ``'openLyrics'`` See ``SongImportForm.add_file_select_item()`` Optional attributes for each song format: @@ -190,7 +190,7 @@ class SongFormat(object): OpenLyrics: { 'class': OpenLyricsImport, 'name': 'OpenLyrics', - 'prefix': 'open_lyrics', + 'prefix': 'openLyrics', 'filter': '%s (*.xml)' % translate('SongsPlugin.ImportWizardForm', 'OpenLyrics Files'), 'comboBoxText': translate('SongsPlugin.ImportWizardForm', 'OpenLyrics or OpenLP 2.0 Exported Song') }, @@ -318,7 +318,7 @@ class SongFormat(object): 'filter': '%s (*.ptf)' % translate('SongsPlugin.ImportWizardForm', 'SundayPlus Song Files') }, WordsOfWorship: { - 'class': WowImport, + 'class': WordsOfWorshipImport, 'name': 'Words of Worship', 'prefix': 'wordsOfWorship', 'filter': '%s (*.wsg *.wow-song)' % translate('SongsPlugin.ImportWizardForm', 'Words Of Worship Song Files') @@ -423,10 +423,10 @@ class SongFormat(object): SongFormat.set(SongFormat.SongsOfFellowship, 'availability', HAS_SOF) if HAS_SOF: - SongFormat.set(SongFormat.SongsOfFellowship, 'class', SofImport) + SongFormat.set(SongFormat.SongsOfFellowship, 'class', SongsOfFellowshipImport) SongFormat.set(SongFormat.Generic, 'availability', HAS_OOO) if HAS_OOO: - SongFormat.set(SongFormat.Generic, 'class', OooImport) + SongFormat.set(SongFormat.Generic, 'class', OpenOfficeImport) SongFormat.set(SongFormat.MediaShout, 'availability', HAS_MEDIASHOUT) if HAS_MEDIASHOUT: SongFormat.set(SongFormat.MediaShout, 'class', MediaShoutImport) diff --git a/openlp/plugins/songs/lib/songimport/__init__.py b/openlp/plugins/songs/lib/importers/__init__.py similarity index 100% rename from openlp/plugins/songs/lib/songimport/__init__.py rename to openlp/plugins/songs/lib/importers/__init__.py diff --git a/openlp/plugins/songs/lib/songimport/cclifileimport.py b/openlp/plugins/songs/lib/importers/cclifile.py similarity index 100% rename from openlp/plugins/songs/lib/songimport/cclifileimport.py rename to openlp/plugins/songs/lib/importers/cclifile.py diff --git a/openlp/plugins/songs/lib/songimport/dreambeamimport.py b/openlp/plugins/songs/lib/importers/dreambeam.py similarity index 99% rename from openlp/plugins/songs/lib/songimport/dreambeamimport.py rename to openlp/plugins/songs/lib/importers/dreambeam.py index e5afd65f4..38aab4ae7 100644 --- a/openlp/plugins/songs/lib/songimport/dreambeamimport.py +++ b/openlp/plugins/songs/lib/importers/dreambeam.py @@ -35,7 +35,7 @@ import logging from lxml import etree, objectify from openlp.core.lib import translate -from openlp.plugins.songs.lib.songimport.songimport import SongImport +from openlp.plugins.songs.lib.importers.songimport import SongImport from openlp.plugins.songs.lib.ui import SongStrings log = logging.getLogger(__name__) diff --git a/openlp/plugins/songs/lib/songimport/easyslidesimport.py b/openlp/plugins/songs/lib/importers/easyslides.py similarity index 99% rename from openlp/plugins/songs/lib/songimport/easyslidesimport.py rename to openlp/plugins/songs/lib/importers/easyslides.py index f30ae49e5..93e7fc4db 100644 --- a/openlp/plugins/songs/lib/songimport/easyslidesimport.py +++ b/openlp/plugins/songs/lib/importers/easyslides.py @@ -33,7 +33,7 @@ import re from lxml import etree, objectify from openlp.plugins.songs.lib import VerseType -from openlp.plugins.songs.lib.songimport.songimport import SongImport +from openlp.plugins.songs.lib.importers.songimport import SongImport log = logging.getLogger(__name__) diff --git a/openlp/plugins/songs/lib/songimport/ewimport.py b/openlp/plugins/songs/lib/importers/easyworship.py similarity index 100% rename from openlp/plugins/songs/lib/songimport/ewimport.py rename to openlp/plugins/songs/lib/importers/easyworship.py diff --git a/openlp/plugins/songs/lib/songimport/foilpresenterimport.py b/openlp/plugins/songs/lib/importers/foilpresenter.py similarity index 99% rename from openlp/plugins/songs/lib/songimport/foilpresenterimport.py rename to openlp/plugins/songs/lib/importers/foilpresenter.py index 67911de76..482fbc06a 100644 --- a/openlp/plugins/songs/lib/songimport/foilpresenterimport.py +++ b/openlp/plugins/songs/lib/importers/foilpresenter.py @@ -99,7 +99,7 @@ from lxml import etree, objectify from openlp.core.lib import translate from openlp.core.ui.wizard import WizardStrings from openlp.plugins.songs.lib import clean_song, VerseType -from openlp.plugins.songs.lib.songimport.songimport import SongImport +from openlp.plugins.songs.lib.importers.songimport import SongImport from openlp.plugins.songs.lib.db import Author, Book, Song, Topic from openlp.plugins.songs.lib.ui import SongStrings from openlp.plugins.songs.lib.openlyricsxml import SongXML diff --git a/openlp/plugins/songs/lib/songimport/mediashoutimport.py b/openlp/plugins/songs/lib/importers/mediashout.py similarity index 98% rename from openlp/plugins/songs/lib/songimport/mediashoutimport.py rename to openlp/plugins/songs/lib/importers/mediashout.py index 8eab61a96..d82304fae 100644 --- a/openlp/plugins/songs/lib/songimport/mediashoutimport.py +++ b/openlp/plugins/songs/lib/importers/mediashout.py @@ -33,7 +33,7 @@ a MediaShout database into the OpenLP database. import pyodbc from openlp.core.lib import translate -from openlp.plugins.songs.lib.songimport.songimport import SongImport +from openlp.plugins.songs.lib.importers.songimport import SongImport VERSE_TAGS = ['V', 'C', 'B', 'O', 'P', 'I', 'E'] diff --git a/openlp/plugins/songs/lib/songimport/olpimport.py b/openlp/plugins/songs/lib/importers/openlp.py similarity index 100% rename from openlp/plugins/songs/lib/songimport/olpimport.py rename to openlp/plugins/songs/lib/importers/openlp.py diff --git a/openlp/plugins/songs/lib/songimport/openlyricsimport.py b/openlp/plugins/songs/lib/importers/openlyrics.py similarity index 98% rename from openlp/plugins/songs/lib/songimport/openlyricsimport.py rename to openlp/plugins/songs/lib/importers/openlyrics.py index 74329bfd8..78fcbf2af 100644 --- a/openlp/plugins/songs/lib/songimport/openlyricsimport.py +++ b/openlp/plugins/songs/lib/importers/openlyrics.py @@ -37,7 +37,7 @@ import os from lxml import etree from openlp.core.ui.wizard import WizardStrings -from openlp.plugins.songs.lib.songimport.songimport import SongImport +from openlp.plugins.songs.lib.importers.songimport import SongImport from openlp.plugins.songs.lib.ui import SongStrings from openlp.plugins.songs.lib.openlyricsxml import OpenLyrics, OpenLyricsError diff --git a/openlp/plugins/songs/lib/songimport/oooimport.py b/openlp/plugins/songs/lib/importers/openoffice.py similarity index 99% rename from openlp/plugins/songs/lib/songimport/oooimport.py rename to openlp/plugins/songs/lib/importers/openoffice.py index 0e388b54f..0e499f7ae 100644 --- a/openlp/plugins/songs/lib/songimport/oooimport.py +++ b/openlp/plugins/songs/lib/importers/openoffice.py @@ -52,7 +52,7 @@ except ImportError: PAGE_BOTH = 6 -class OooImport(SongImport): +class OpenOfficeImport(SongImport): """ Import songs from Impress/Powerpoint docs using Impress """ diff --git a/openlp/plugins/songs/lib/songimport/opensongimport.py b/openlp/plugins/songs/lib/importers/opensong.py similarity index 99% rename from openlp/plugins/songs/lib/songimport/opensongimport.py rename to openlp/plugins/songs/lib/importers/opensong.py index a52b67b0f..e1502a903 100644 --- a/openlp/plugins/songs/lib/songimport/opensongimport.py +++ b/openlp/plugins/songs/lib/importers/opensong.py @@ -35,7 +35,7 @@ from lxml.etree import Error, LxmlError from openlp.core.common import translate from openlp.plugins.songs.lib import VerseType -from openlp.plugins.songs.lib.songimport.songimport import SongImport +from openlp.plugins.songs.lib.importers.songimport import SongImport from openlp.plugins.songs.lib.ui import SongStrings log = logging.getLogger(__name__) diff --git a/openlp/plugins/songs/lib/songimport/powersongimport.py b/openlp/plugins/songs/lib/importers/powersong.py similarity index 98% rename from openlp/plugins/songs/lib/songimport/powersongimport.py rename to openlp/plugins/songs/lib/importers/powersong.py index 1cad5e33e..89c847ab0 100644 --- a/openlp/plugins/songs/lib/songimport/powersongimport.py +++ b/openlp/plugins/songs/lib/importers/powersong.py @@ -35,7 +35,7 @@ import fnmatch import os from openlp.core.common import translate -from openlp.plugins.songs.lib.songimport.songimport import SongImport +from openlp.plugins.songs.lib.importers.songimport import SongImport log = logging.getLogger(__name__) @@ -90,7 +90,7 @@ class PowerSongImport(SongImport): """ Receive either a list of files or a folder (unicode) to import. """ - from .importer import SongFormat + from openlp.plugins.songs.lib.importer import SongFormat ps_string = SongFormat.get(SongFormat.PowerSong, 'name') if isinstance(self.import_source, str): if os.path.isdir(self.import_source): diff --git a/openlp/plugins/songs/lib/songimport/propresenterimport.py b/openlp/plugins/songs/lib/importers/propresenter.py similarity index 100% rename from openlp/plugins/songs/lib/songimport/propresenterimport.py rename to openlp/plugins/songs/lib/importers/propresenter.py diff --git a/openlp/plugins/songs/lib/songimport/songbeamerimport.py b/openlp/plugins/songs/lib/importers/songbeamer.py similarity index 99% rename from openlp/plugins/songs/lib/songimport/songbeamerimport.py rename to openlp/plugins/songs/lib/importers/songbeamer.py index fbd016cda..4c5873e2a 100644 --- a/openlp/plugins/songs/lib/songimport/songbeamerimport.py +++ b/openlp/plugins/songs/lib/importers/songbeamer.py @@ -36,7 +36,7 @@ import os import re from openlp.plugins.songs.lib import VerseType -from openlp.plugins.songs.lib.songimport.songimport import SongImport +from openlp.plugins.songs.lib.importers.songimport import SongImport log = logging.getLogger(__name__) diff --git a/openlp/plugins/songs/lib/songimport/songimport.py b/openlp/plugins/songs/lib/importers/songimport.py similarity index 100% rename from openlp/plugins/songs/lib/songimport/songimport.py rename to openlp/plugins/songs/lib/importers/songimport.py diff --git a/openlp/plugins/songs/lib/songimport/songproimport.py b/openlp/plugins/songs/lib/importers/songpro.py similarity index 98% rename from openlp/plugins/songs/lib/songimport/songproimport.py rename to openlp/plugins/songs/lib/importers/songpro.py index 853a1d9eb..52d702097 100644 --- a/openlp/plugins/songs/lib/songimport/songproimport.py +++ b/openlp/plugins/songs/lib/importers/songpro.py @@ -33,7 +33,7 @@ songs into the OpenLP database. import re from openlp.plugins.songs.lib import strip_rtf -from openlp.plugins.songs.lib.songimport.songimport import SongImport +from openlp.plugins.songs.lib.importers.songimport import SongImport class SongProImport(SongImport): diff --git a/openlp/plugins/songs/lib/songimport/songshowplusimport.py b/openlp/plugins/songs/lib/importers/songshowplus.py similarity index 99% rename from openlp/plugins/songs/lib/songimport/songshowplusimport.py rename to openlp/plugins/songs/lib/importers/songshowplus.py index 352e55d96..d53cc33f1 100644 --- a/openlp/plugins/songs/lib/songimport/songshowplusimport.py +++ b/openlp/plugins/songs/lib/importers/songshowplus.py @@ -38,7 +38,7 @@ import struct from openlp.core.ui.wizard import WizardStrings from openlp.plugins.songs.lib import VerseType, retrieve_windows_encoding -from openlp.plugins.songs.lib.songimport.songimport import SongImport +from openlp.plugins.songs.lib.importers.songimport import SongImport TITLE = 1 AUTHOR = 2 diff --git a/openlp/plugins/songs/lib/songimport/sofimport.py b/openlp/plugins/songs/lib/importers/songsoffellowship.py similarity index 98% rename from openlp/plugins/songs/lib/songimport/sofimport.py rename to openlp/plugins/songs/lib/importers/songsoffellowship.py index e44034648..c1ef8666f 100644 --- a/openlp/plugins/songs/lib/songimport/sofimport.py +++ b/openlp/plugins/songs/lib/importers/songsoffellowship.py @@ -37,13 +37,13 @@ import logging import os import re -from .oooimport import OooImport +from .openoffice import OpenOfficeImport log = logging.getLogger(__name__) if os.name == 'nt': - from .oooimport import PAGE_BEFORE, PAGE_AFTER, PAGE_BOTH + from .openoffice import PAGE_BEFORE, PAGE_AFTER, PAGE_BOTH RuntimeException = Exception else: try: @@ -62,7 +62,7 @@ except ImportError: ITALIC = 2 -class SofImport(OooImport): +class SongsOfFellowshipImport(OpenOfficeImport): """ Import songs provided on disks with the Songs of Fellowship music books VOLS1_2.RTF, sof3words.rtf and sof4words.rtf @@ -83,7 +83,7 @@ class SofImport(OooImport): Initialise the class. Requires a songmanager class which is passed to SongImport for writing song to disk """ - OooImport.__init__(self, manager, **kwargs) + OpenOfficeImport.__init__(self, manager, **kwargs) self.song = False def process_ooo_document(self): diff --git a/openlp/plugins/songs/lib/songimport/sundayplusimport.py b/openlp/plugins/songs/lib/importers/sundayplus.py similarity index 99% rename from openlp/plugins/songs/lib/songimport/sundayplusimport.py rename to openlp/plugins/songs/lib/importers/sundayplus.py index fded3bca3..b664efb54 100644 --- a/openlp/plugins/songs/lib/songimport/sundayplusimport.py +++ b/openlp/plugins/songs/lib/importers/sundayplus.py @@ -32,7 +32,7 @@ import re from openlp.plugins.songs.lib import VerseType, retrieve_windows_encoding from openlp.plugins.songs.lib import strip_rtf -from openlp.plugins.songs.lib.songimport.songimport import SongImport +from openlp.plugins.songs.lib.importers.songimport import SongImport HOTKEY_TO_VERSE_TYPE = { '1': 'v1', diff --git a/openlp/plugins/songs/lib/songimport/wowimport.py b/openlp/plugins/songs/lib/importers/wordsofworship.py similarity index 98% rename from openlp/plugins/songs/lib/songimport/wowimport.py rename to openlp/plugins/songs/lib/importers/wordsofworship.py index c135ca620..ce80c19ce 100644 --- a/openlp/plugins/songs/lib/songimport/wowimport.py +++ b/openlp/plugins/songs/lib/importers/wordsofworship.py @@ -34,14 +34,14 @@ import os import logging from openlp.core.common import translate -from openlp.plugins.songs.lib.songimport.songimport import SongImport +from openlp.plugins.songs.lib.importers.songimport import SongImport BLOCK_TYPES = ('V', 'C', 'B') log = logging.getLogger(__name__) -class WowImport(SongImport): +class WordsOfWorshipImport(SongImport): """ The :class:`WowImport` class provides the ability to import song files from Words of Worship. diff --git a/openlp/plugins/songs/lib/songimport/worshipassistantimport.py b/openlp/plugins/songs/lib/importers/worshipassistant.py similarity index 98% rename from openlp/plugins/songs/lib/songimport/worshipassistantimport.py rename to openlp/plugins/songs/lib/importers/worshipassistant.py index 412a17c35..6ddc71159 100644 --- a/openlp/plugins/songs/lib/songimport/worshipassistantimport.py +++ b/openlp/plugins/songs/lib/importers/worshipassistant.py @@ -27,7 +27,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### """ -The :mod:`worshipassistantimport` module provides the functionality for importing +The :mod:`worshipassistant` module provides the functionality for importing Worship Assistant songs into the OpenLP database. """ import chardet @@ -37,7 +37,7 @@ import re from openlp.core.common import translate from openlp.plugins.songs.lib import VerseType -from openlp.plugins.songs.lib.songimport.songimport import SongImport +from openlp.plugins.songs.lib.importers.songimport import SongImport log = logging.getLogger(__name__) diff --git a/openlp/plugins/songs/lib/songimport/worshipcenterproimport.py b/openlp/plugins/songs/lib/importers/worshipcenterpro.py similarity index 98% rename from openlp/plugins/songs/lib/songimport/worshipcenterproimport.py rename to openlp/plugins/songs/lib/importers/worshipcenterpro.py index b6c32a8c0..817bd8cae 100644 --- a/openlp/plugins/songs/lib/songimport/worshipcenterproimport.py +++ b/openlp/plugins/songs/lib/importers/worshipcenterpro.py @@ -35,7 +35,7 @@ import logging import pyodbc from openlp.core.common import translate -from openlp.plugins.songs.lib.songimport.songimport import SongImport +from openlp.plugins.songs.lib.importers.songimport import SongImport log = logging.getLogger(__name__) diff --git a/openlp/plugins/songs/lib/songimport/zionworximport.py b/openlp/plugins/songs/lib/importers/zionworx.py similarity index 98% rename from openlp/plugins/songs/lib/songimport/zionworximport.py rename to openlp/plugins/songs/lib/importers/zionworx.py index 8d939f244..0b97aee26 100644 --- a/openlp/plugins/songs/lib/songimport/zionworximport.py +++ b/openlp/plugins/songs/lib/importers/zionworx.py @@ -34,7 +34,7 @@ import csv import logging from openlp.core.common import translate -from openlp.plugins.songs.lib.songimport.songimport import SongImport +from openlp.plugins.songs.lib.importers.songimport import SongImport log = logging.getLogger(__name__) diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py index c97e3835f..5cbedc994 100644 --- a/openlp/plugins/songs/songsplugin.py +++ b/openlp/plugins/songs/songsplugin.py @@ -49,7 +49,7 @@ from openlp.plugins.songs.lib import clean_song, upgrade from openlp.plugins.songs.lib.db import init_schema, Song from openlp.plugins.songs.lib.mediaitem import SongSearch from openlp.plugins.songs.lib.importer import SongFormat -from openlp.plugins.songs.lib.songimport.olpimport import OpenLPSongImport +from openlp.plugins.songs.lib.importers.openlp import OpenLPSongImport from openlp.plugins.songs.lib.mediaitem import SongMediaItem from openlp.plugins.songs.lib.songstab import SongsTab diff --git a/tests/functional/openlp_plugins/songs/test_ewimport.py b/tests/functional/openlp_plugins/songs/test_ewimport.py index c28dc72aa..f441084e7 100644 --- a/tests/functional/openlp_plugins/songs/test_ewimport.py +++ b/tests/functional/openlp_plugins/songs/test_ewimport.py @@ -35,7 +35,7 @@ from unittest import TestCase from tests.functional import MagicMock, patch -from openlp.plugins.songs.lib.songimport.ewimport import EasyWorshipSongImport, FieldDescEntry, FieldType +from openlp.plugins.songs.lib.importers.easyworship import EasyWorshipSongImport, FieldDescEntry, FieldType TEST_PATH = os.path.abspath( os.path.join(os.path.dirname(__file__), '..', '..', '..', 'resources', 'easyworshipsongs')) @@ -178,7 +178,7 @@ class TestEasyWorshipSongImport(TestCase): Test creating an instance of the EasyWorship file importer """ # GIVEN: A mocked out SongImport class, and a mocked out "manager" - with patch('openlp.plugins.songs.lib.songimport.ewimport.SongImport'): + with patch('openlp.plugins.songs.lib.importers.easyworship.SongImport'): mocked_manager = MagicMock() # WHEN: An importer object is created @@ -192,7 +192,7 @@ class TestEasyWorshipSongImport(TestCase): Test finding an existing field in a given list using the :mod:`find_field` """ # GIVEN: A mocked out SongImport class, a mocked out "manager" and a list of field descriptions. - with patch('openlp.plugins.songs.lib.songimport.ewimport.SongImport'): + with patch('openlp.plugins.songs.lib.importers.easyworship.SongImport'): mocked_manager = MagicMock() importer = EasyWorshipSongImport(mocked_manager, filenames=[]) importer.field_descriptions = TEST_FIELD_DESCS @@ -210,7 +210,7 @@ class TestEasyWorshipSongImport(TestCase): Test finding an non-existing field in a given list using the :mod:`find_field` """ # GIVEN: A mocked out SongImport class, a mocked out "manager" and a list of field descriptions - with patch('openlp.plugins.songs.lib.songimport.ewimport.SongImport'): + with patch('openlp.plugins.songs.lib.importers.easyworship.SongImport'): mocked_manager = MagicMock() importer = EasyWorshipSongImport(mocked_manager, filenames=[]) importer.field_descriptions = TEST_FIELD_DESCS @@ -228,8 +228,8 @@ 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.songimport.ewimport.SongImport'), \ - patch('openlp.plugins.songs.lib.songimport.ewimport.struct') as mocked_struct: + with patch('openlp.plugins.songs.lib.importers.easyworship.SongImport'), \ + patch('openlp.plugins.songs.lib.importers.easyworship.struct') as mocked_struct: mocked_manager = MagicMock() importer = EasyWorshipSongImport(mocked_manager, filenames=[]) @@ -246,7 +246,7 @@ class TestEasyWorshipSongImport(TestCase): Test the :mod:`get_field` module """ # 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.songimport.ewimport.SongImport'): + with patch('openlp.plugins.songs.lib.importers.easyworship.SongImport'): mocked_manager = MagicMock() importer = EasyWorshipSongImport(mocked_manager, filenames=[]) importer.encoding = TEST_DATA_ENCODING @@ -269,7 +269,7 @@ class TestEasyWorshipSongImport(TestCase): """ for test_results in GET_MEMO_FIELD_TEST_RESULTS: # GIVEN: A mocked out SongImport class, a mocked out "manager", a mocked out memo_file and an encoding - with patch('openlp.plugins.songs.lib.songimport.ewimport.SongImport'): + with patch('openlp.plugins.songs.lib.importers.easyworship.SongImport'): mocked_manager = MagicMock() mocked_memo_file = MagicMock() importer = EasyWorshipSongImport(mocked_manager, filenames=[]) @@ -300,8 +300,8 @@ class TestEasyWorshipSongImport(TestCase): Test the :mod:`do_import` module opens the correct files """ # GIVEN: A mocked out SongImport class, a mocked out "manager" - with patch('openlp.plugins.songs.lib.songimport.ewimport.SongImport'), \ - patch('openlp.plugins.songs.lib.songimport.ewimport.os.path') as mocked_os_path: + with patch('openlp.plugins.songs.lib.importers.easyworship.SongImport'), \ + patch('openlp.plugins.songs.lib.importers.easyworship.os.path') as mocked_os_path: mocked_manager = MagicMock() importer = EasyWorshipSongImport(mocked_manager, filenames=[]) mocked_os_path.isfile.side_effect = [True, False] @@ -319,8 +319,8 @@ class TestEasyWorshipSongImport(TestCase): Test the :mod:`do_import` module produces an error when Songs.MB not found. """ # GIVEN: A mocked out SongImport class, a mocked out "manager" - with patch('openlp.plugins.songs.lib.songimport.ewimport.SongImport'), \ - patch('openlp.plugins.songs.lib.songimport.ewimport.os.path') as mocked_os_path: + with patch('openlp.plugins.songs.lib.importers.easyworship.SongImport'), \ + patch('openlp.plugins.songs.lib.importers.easyworship.os.path') as mocked_os_path: mocked_manager = MagicMock() importer = EasyWorshipSongImport(mocked_manager, filenames=[]) importer.log_error = MagicMock() @@ -339,8 +339,8 @@ class TestEasyWorshipSongImport(TestCase): Test the :mod:`do_import` module handles invalid database files correctly """ # GIVEN: A mocked out SongImport class, os.path and a mocked out "manager" - with patch('openlp.plugins.songs.lib.songimport.ewimport.SongImport'), \ - patch('openlp.plugins.songs.lib.songimport.ewimport.os.path') as mocked_os_path: + with patch('openlp.plugins.songs.lib.importers.easyworship.SongImport'), \ + patch('openlp.plugins.songs.lib.importers.easyworship.os.path') as mocked_os_path: mocked_manager = MagicMock() importer = EasyWorshipSongImport(mocked_manager, filenames=[]) mocked_os_path.isfile.return_value = True @@ -358,10 +358,10 @@ class TestEasyWorshipSongImport(TestCase): Test the :mod:`do_import` module handles invalid memo files correctly """ # GIVEN: A mocked out SongImport class, a mocked out "manager" - with patch('openlp.plugins.songs.lib.songimport.ewimport.SongImport'), \ - patch('openlp.plugins.songs.lib.songimport.ewimport.os.path') as mocked_os_path, \ + with patch('openlp.plugins.songs.lib.importers.easyworship.SongImport'), \ + patch('openlp.plugins.songs.lib.importers.easyworship.os.path') as mocked_os_path, \ patch('builtins.open') as mocked_open, \ - patch('openlp.plugins.songs.lib.songimport.ewimport.struct') as mocked_struct: + patch('openlp.plugins.songs.lib.importers.easyworship.struct') as mocked_struct: mocked_manager = MagicMock() importer = EasyWorshipSongImport(mocked_manager, filenames=[]) mocked_os_path.isfile.return_value = True @@ -385,10 +385,10 @@ class TestEasyWorshipSongImport(TestCase): Test the :mod:`do_import` converts the code page to the encoding correctly """ # GIVEN: A mocked out SongImport class, a mocked out "manager" - with patch('openlp.plugins.songs.lib.songimport.ewimport.SongImport'), \ - patch('openlp.plugins.songs.lib.songimport.ewimport.os.path') as mocked_os_path, \ - patch('builtins.open'), patch('openlp.plugins.songs.lib.songimport.ewimport.struct') as mocked_struct, \ - patch('openlp.plugins.songs.lib.songimport.ewimport.retrieve_windows_encoding') as \ + with patch('openlp.plugins.songs.lib.importers.easyworship.SongImport'), \ + patch('openlp.plugins.songs.lib.importers.easyworship.os.path') as mocked_os_path, \ + patch('builtins.open'), patch('openlp.plugins.songs.lib.importers.easyworship.struct') as mocked_struct, \ + patch('openlp.plugins.songs.lib.importers.easyworship.retrieve_windows_encoding') as \ mocked_retrieve_windows_encoding: mocked_manager = MagicMock() importer = EasyWorshipSongImport(mocked_manager, filenames=[]) @@ -413,8 +413,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.songimport.ewimport.SongImport'), \ - patch('openlp.plugins.songs.lib.songimport.ewimport.retrieve_windows_encoding') as \ + with patch('openlp.plugins.songs.lib.importers.easyworship.SongImport'), \ + patch('openlp.plugins.songs.lib.importers.easyworship.retrieve_windows_encoding') as \ mocked_retrieve_windows_encoding: mocked_retrieve_windows_encoding.return_value = 'cp1252' mocked_manager = MagicMock() @@ -469,8 +469,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.songimport.ewimport.SongImport'), \ - patch('openlp.plugins.songs.lib.songimport.ewimport.retrieve_windows_encoding') \ + with patch('openlp.plugins.songs.lib.importers.easyworship.SongImport'), \ + patch('openlp.plugins.songs.lib.importers.easyworship.retrieve_windows_encoding') \ as mocked_retrieve_windows_encoding: mocked_retrieve_windows_encoding.return_value = 'cp1252' mocked_manager = MagicMock() @@ -509,7 +509,7 @@ class TestEasyWorshipSongImport(TestCase): """ # GIVEN: A mocked out SongImport class, a mocked out "manager" and mocked out "author" method. - with patch('openlp.plugins.songs.lib.songimport.ewimport.SongImport'): + with patch('openlp.plugins.songs.lib.importers.easyworship.SongImport'): mocked_manager = MagicMock() mocked_add_author = MagicMock() importer = EasyWorshipSongImportLogger(mocked_manager) diff --git a/tests/functional/openlp_plugins/songs/test_foilpresenterimport.py b/tests/functional/openlp_plugins/songs/test_foilpresenterimport.py index 15247a361..3886443ca 100644 --- a/tests/functional/openlp_plugins/songs/test_foilpresenterimport.py +++ b/tests/functional/openlp_plugins/songs/test_foilpresenterimport.py @@ -34,7 +34,7 @@ import os from unittest import TestCase from tests.functional import patch, MagicMock -from openlp.plugins.songs.lib.songimport.foilpresenterimport import FoilPresenter +from openlp.plugins.songs.lib.importers.foilpresenter import FoilPresenter TEST_PATH = os.path.abspath( os.path.join(os.path.dirname(__file__), '..', '..', '..', '/resources/foilpresentersongs')) @@ -57,27 +57,27 @@ class TestFoilPresenter(TestCase): # _process_topics def setUp(self): - self.child_patcher = patch('openlp.plugins.songs.lib.songimport.foilpresenterimport.FoilPresenter._child') - self.clean_song_patcher = patch('openlp.plugins.songs.lib.songimport.foilpresenterimport.clean_song') - self.objectify_patcher = patch('openlp.plugins.songs.lib.songimport.foilpresenterimport.objectify') + self.child_patcher = patch('openlp.plugins.songs.lib.importers.foilpresenter.FoilPresenter._child') + self.clean_song_patcher = patch('openlp.plugins.songs.lib.importers.foilpresenter.clean_song') + self.objectify_patcher = patch('openlp.plugins.songs.lib.importers.foilpresenter.objectify') self.process_authors_patcher = \ - patch('openlp.plugins.songs.lib.songimport.foilpresenterimport.FoilPresenter._process_authors') + patch('openlp.plugins.songs.lib.importers.foilpresenter.FoilPresenter._process_authors') self.process_cclinumber_patcher = \ - patch('openlp.plugins.songs.lib.songimport.foilpresenterimport.FoilPresenter._process_cclinumber') + patch('openlp.plugins.songs.lib.importers.foilpresenter.FoilPresenter._process_cclinumber') self.process_comments_patcher = \ - patch('openlp.plugins.songs.lib.songimport.foilpresenterimport.FoilPresenter._process_comments') + patch('openlp.plugins.songs.lib.importers.foilpresenter.FoilPresenter._process_comments') self.process_lyrics_patcher = \ - patch('openlp.plugins.songs.lib.songimport.foilpresenterimport.FoilPresenter._process_lyrics') + patch('openlp.plugins.songs.lib.importers.foilpresenter.FoilPresenter._process_lyrics') self.process_songbooks_patcher = \ - patch('openlp.plugins.songs.lib.songimport.foilpresenterimport.FoilPresenter._process_songbooks') + patch('openlp.plugins.songs.lib.importers.foilpresenter.FoilPresenter._process_songbooks') self.process_titles_patcher = \ - patch('openlp.plugins.songs.lib.songimport.foilpresenterimport.FoilPresenter._process_titles') + patch('openlp.plugins.songs.lib.importers.foilpresenter.FoilPresenter._process_titles') self.process_topics_patcher = \ - patch('openlp.plugins.songs.lib.songimport.foilpresenterimport.FoilPresenter._process_topics') - self.re_patcher = patch('openlp.plugins.songs.lib.songimport.foilpresenterimport.re') - self.song_patcher = patch('openlp.plugins.songs.lib.songimport.foilpresenterimport.Song') - self.song_xml_patcher = patch('openlp.plugins.songs.lib.songimport.foilpresenterimport.SongXML') - self.translate_patcher = patch('openlp.plugins.songs.lib.songimport.foilpresenterimport.translate') + patch('openlp.plugins.songs.lib.importers.foilpresenter.FoilPresenter._process_topics') + self.re_patcher = patch('openlp.plugins.songs.lib.importers.foilpresenter.re') + self.song_patcher = patch('openlp.plugins.songs.lib.importers.foilpresenter.Song') + self.song_xml_patcher = patch('openlp.plugins.songs.lib.importers.foilpresenter.SongXML') + self.translate_patcher = patch('openlp.plugins.songs.lib.importers.foilpresenter.translate') self.mocked_child = self.child_patcher.start() self.mocked_clean_song = self.clean_song_patcher.start() diff --git a/tests/functional/openlp_plugins/songs/test_openlyricsimport.py b/tests/functional/openlp_plugins/songs/test_openlyricsimport.py index 2166b950c..25db3e9e4 100644 --- a/tests/functional/openlp_plugins/songs/test_openlyricsimport.py +++ b/tests/functional/openlp_plugins/songs/test_openlyricsimport.py @@ -34,8 +34,8 @@ import os from unittest import TestCase from tests.functional import MagicMock, patch -from openlp.plugins.songs.lib.songimport.openlyricsimport import OpenLyricsImport -from openlp.plugins.songs.lib.songimport.songimport import SongImport +from openlp.plugins.songs.lib.importers.openlyrics import OpenLyricsImport +from openlp.plugins.songs.lib.importers.songimport import SongImport TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..', 'resources', 'openlyricssongs')) @@ -69,7 +69,7 @@ class TestOpenLyricsImport(TestCase): Test creating an instance of the OpenLyrics file importer """ # GIVEN: A mocked out SongImport class, and a mocked out "manager" - with patch('openlp.plugins.songs.lib.songimport.openlyricsimport.SongImport'): + with patch('openlp.plugins.songs.lib.importers.openlyrics.SongImport'): mocked_manager = MagicMock() # WHEN: An importer object is created diff --git a/tests/functional/openlp_plugins/songs/test_opensongimport.py b/tests/functional/openlp_plugins/songs/test_opensongimport.py index 09fad7bc3..07b275f98 100644 --- a/tests/functional/openlp_plugins/songs/test_opensongimport.py +++ b/tests/functional/openlp_plugins/songs/test_opensongimport.py @@ -34,7 +34,7 @@ import os from unittest import TestCase from tests.helpers.songfileimport import SongImportTestHelper -from openlp.plugins.songs.lib.songimport.opensongimport import OpenSongImport +from openlp.plugins.songs.lib.importers.opensong import OpenSongImport from tests.functional import patch, MagicMock TEST_PATH = os.path.abspath( @@ -45,7 +45,7 @@ class TestOpenSongFileImport(SongImportTestHelper): def __init__(self, *args, **kwargs): self.importer_class_name = 'OpenSongImport' - self.importer_module_name = 'opensongimport' + self.importer_module_name = 'opensong' super(TestOpenSongFileImport, self).__init__(*args, **kwargs) def test_song_import(self): @@ -69,7 +69,7 @@ class TestOpenSongImport(TestCase): Test creating an instance of the OpenSong file importer """ # GIVEN: A mocked out SongImport class, and a mocked out "manager" - with patch('openlp.plugins.songs.lib.songimport.opensongimport.SongImport'): + with patch('openlp.plugins.songs.lib.importers.opensong.SongImport'): mocked_manager = MagicMock() # WHEN: An importer object is created @@ -83,7 +83,7 @@ class TestOpenSongImport(TestCase): Test OpenSongImport.do_import handles different invalid import_source values """ # GIVEN: A mocked out SongImport class, and a mocked out "manager" - with patch('openlp.plugins.songs.lib.songimport.opensongimport.SongImport'): + with patch('openlp.plugins.songs.lib.importers.opensong.SongImport'): mocked_manager = MagicMock() mocked_import_wizard = MagicMock() importer = OpenSongImport(mocked_manager, filenames=[]) @@ -104,7 +104,7 @@ class TestOpenSongImport(TestCase): Test OpenSongImport.do_import handles different invalid import_source values """ # GIVEN: A mocked out SongImport class, and a mocked out "manager" - with patch('openlp.plugins.songs.lib.songimport.opensongimport.SongImport'): + with patch('openlp.plugins.songs.lib.importers.opensong.SongImport'): mocked_manager = MagicMock() mocked_import_wizard = MagicMock() importer = OpenSongImport(mocked_manager, filenames=[]) diff --git a/tests/functional/openlp_plugins/songs/test_propresenterimport.py b/tests/functional/openlp_plugins/songs/test_propresenterimport.py index 10e2defc6..bc313e250 100644 --- a/tests/functional/openlp_plugins/songs/test_propresenterimport.py +++ b/tests/functional/openlp_plugins/songs/test_propresenterimport.py @@ -43,7 +43,7 @@ class TestProPresenterFileImport(SongImportTestHelper): def __init__(self, *args, **kwargs): self.importer_class_name = 'ProPresenterImport' - self.importer_module_name = 'propresenterimport' + self.importer_module_name = 'propresenter' super(TestProPresenterFileImport, self).__init__(*args, **kwargs) def test_song_import(self): diff --git a/tests/functional/openlp_plugins/songs/test_songbeamerimport.py b/tests/functional/openlp_plugins/songs/test_songbeamerimport.py index 9ca0ab790..3d872ae65 100644 --- a/tests/functional/openlp_plugins/songs/test_songbeamerimport.py +++ b/tests/functional/openlp_plugins/songs/test_songbeamerimport.py @@ -34,7 +34,7 @@ import os from unittest import TestCase from tests.functional import MagicMock, patch -from openlp.plugins.songs.lib.songimport.songbeamerimport import SongBeamerImport +from openlp.plugins.songs.lib.importers.songbeamer import SongBeamerImport from openlp.plugins.songs.lib import VerseType TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), @@ -64,7 +64,7 @@ class TestSongBeamerImport(TestCase): Test creating an instance of the SongBeamer file importer """ # GIVEN: A mocked out SongImport class, and a mocked out "manager" - with patch('openlp.plugins.songs.lib.songimport.songbeamerimport.SongImport'): + with patch('openlp.plugins.songs.lib.importers.songbeamer.SongImport'): mocked_manager = MagicMock() # WHEN: An importer object is created @@ -78,7 +78,7 @@ class TestSongBeamerImport(TestCase): Test SongBeamerImport.do_import handles different invalid import_source values """ # GIVEN: A mocked out SongImport class, and a mocked out "manager" - with patch('openlp.plugins.songs.lib.songimport.songbeamerimport.SongImport'): + with patch('openlp.plugins.songs.lib.importers.songbeamer.SongImport'): mocked_manager = MagicMock() mocked_import_wizard = MagicMock() importer = SongBeamerImport(mocked_manager, filenames=[]) @@ -99,7 +99,7 @@ class TestSongBeamerImport(TestCase): Test SongBeamerImport.do_import handles different invalid import_source values """ # GIVEN: A mocked out SongImport class, and a mocked out "manager" - with patch('openlp.plugins.songs.lib.songimport.songbeamerimport.SongImport'): + with patch('openlp.plugins.songs.lib.importers.songbeamer.SongImport'): mocked_manager = MagicMock() mocked_import_wizard = MagicMock() importer = SongBeamerImport(mocked_manager, filenames=[]) @@ -122,7 +122,7 @@ class TestSongBeamerImport(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.songimport.songbeamerimport.SongImport'): + with patch('openlp.plugins.songs.lib.importers.songbeamer.SongImport'): for song_file in SONG_TEST_DATA: mocked_manager = MagicMock() mocked_import_wizard = MagicMock() diff --git a/tests/functional/openlp_plugins/songs/test_songshowplusimport.py b/tests/functional/openlp_plugins/songs/test_songshowplusimport.py index 8d6a42287..77e1196bc 100644 --- a/tests/functional/openlp_plugins/songs/test_songshowplusimport.py +++ b/tests/functional/openlp_plugins/songs/test_songshowplusimport.py @@ -35,7 +35,7 @@ from unittest import TestCase from tests.helpers.songfileimport import SongImportTestHelper from openlp.plugins.songs.lib import VerseType -from openlp.plugins.songs.lib.songimport.songshowplusimport import SongShowPlusImport +from openlp.plugins.songs.lib.importers.songshowplus import SongShowPlusImport from tests.functional import patch, MagicMock TEST_PATH = os.path.abspath( @@ -46,7 +46,7 @@ class TestSongShowPlusFileImport(SongImportTestHelper): def __init__(self, *args, **kwargs): self.importer_class_name = 'SongShowPlusImport' - self.importer_module_name = 'songshowplusimport' + self.importer_module_name = 'songshowplus' super(TestSongShowPlusFileImport, self).__init__(*args, **kwargs) def test_song_import(self): @@ -70,7 +70,7 @@ class TestSongShowPlusImport(TestCase): Test creating an instance of the SongShow Plus file importer """ # GIVEN: A mocked out SongImport class, and a mocked out "manager" - with patch('openlp.plugins.songs.lib.songimport.songshowplusimport.SongImport'): + with patch('openlp.plugins.songs.lib.importers.songshowplus.SongImport'): mocked_manager = MagicMock() # WHEN: An importer object is created @@ -84,7 +84,7 @@ class TestSongShowPlusImport(TestCase): Test SongShowPlusImport.do_import handles different invalid import_source values """ # GIVEN: A mocked out SongImport class, and a mocked out "manager" - with patch('openlp.plugins.songs.lib.songimport.songshowplusimport.SongImport'): + with patch('openlp.plugins.songs.lib.importers.songshowplus.SongImport'): mocked_manager = MagicMock() mocked_import_wizard = MagicMock() importer = SongShowPlusImport(mocked_manager, filenames=[]) @@ -105,7 +105,7 @@ class TestSongShowPlusImport(TestCase): Test SongShowPlusImport.do_import handles different invalid import_source values """ # GIVEN: A mocked out SongImport class, and a mocked out "manager" - with patch('openlp.plugins.songs.lib.songimport.songshowplusimport.SongImport'): + with patch('openlp.plugins.songs.lib.importers.songshowplus.SongImport'): mocked_manager = MagicMock() mocked_import_wizard = MagicMock() importer = SongShowPlusImport(mocked_manager, filenames=[]) @@ -126,7 +126,7 @@ class TestSongShowPlusImport(TestCase): Test to_openlp_verse_tag method by simulating adding a verse """ # GIVEN: A mocked out SongImport class, and a mocked out "manager" - with patch('openlp.plugins.songs.lib.songimport.songshowplusimport.SongImport'): + with patch('openlp.plugins.songs.lib.importers.songshowplus.SongImport'): mocked_manager = MagicMock() importer = SongShowPlusImport(mocked_manager, filenames=[]) @@ -154,7 +154,7 @@ class TestSongShowPlusImport(TestCase): Test to_openlp_verse_tag method by simulating adding a verse to the verse order """ # GIVEN: A mocked out SongImport class, and a mocked out "manager" - with patch('openlp.plugins.songs.lib.songimport.songshowplusimport.SongImport'): + with patch('openlp.plugins.songs.lib.importers.songshowplus.SongImport'): mocked_manager = MagicMock() importer = SongShowPlusImport(mocked_manager, filenames=[]) diff --git a/tests/functional/openlp_plugins/songs/test_worshipassistantimport.py b/tests/functional/openlp_plugins/songs/test_worshipassistantimport.py index c0c5c7416..63ead5b30 100644 --- a/tests/functional/openlp_plugins/songs/test_worshipassistantimport.py +++ b/tests/functional/openlp_plugins/songs/test_worshipassistantimport.py @@ -43,7 +43,7 @@ class TestWorshipAssistantFileImport(SongImportTestHelper): def __init__(self, *args, **kwargs): self.importer_class_name = 'WorshipAssistantImport' - self.importer_module_name = 'worshipassistantimport' + self.importer_module_name = 'worshipassistant' super(TestWorshipAssistantFileImport, self).__init__(*args, **kwargs) def test_song_import(self): diff --git a/tests/functional/openlp_plugins/songs/test_worshipcenterproimport.py b/tests/functional/openlp_plugins/songs/test_worshipcenterproimport.py index 0558ad195..cd51e3384 100644 --- a/tests/functional/openlp_plugins/songs/test_worshipcenterproimport.py +++ b/tests/functional/openlp_plugins/songs/test_worshipcenterproimport.py @@ -37,7 +37,7 @@ if os.name != 'nt': import pyodbc -from openlp.plugins.songs.lib.songimport.worshipcenterproimport import WorshipCenterProImport +from openlp.plugins.songs.lib.importers.worshipcenterpro import WorshipCenterProImport from tests.functional import patch, MagicMock @@ -141,7 +141,7 @@ class TestWorshipCenterProSongImport(TestCase): Test creating an instance of the WorshipCenter Pro file importer """ # GIVEN: A mocked out SongImport class, and a mocked out "manager" - with patch('openlp.plugins.songs.lib.songimport.worshipcenterproimport.SongImport'): + with patch('openlp.plugins.songs.lib.importers.worshipcenterpro.SongImport'): mocked_manager = MagicMock() # WHEN: An importer object is created @@ -156,10 +156,10 @@ class TestWorshipCenterProSongImport(TestCase): """ # GIVEN: A mocked out SongImport class, a mocked out pyodbc module, a mocked out translate method, # a mocked "manager" and a mocked out log_error method. - with patch('openlp.plugins.songs.lib.songimport.worshipcenterproimport.SongImport'), \ - patch('openlp.plugins.songs.lib.songimport.worshipcenterproimport.pyodbc.connect') \ + with patch('openlp.plugins.songs.lib.importers.worshipcenterpro.SongImport'), \ + patch('openlp.plugins.songs.lib.importers.worshipcenterpro.pyodbc.connect') \ as mocked_pyodbc_connect, \ - patch('openlp.plugins.songs.lib.songimport.worshipcenterproimport.translate') as mocked_translate: + patch('openlp.plugins.songs.lib.importers.worshipcenterpro.translate') as mocked_translate: mocked_manager = MagicMock() mocked_log_error = MagicMock() mocked_translate.return_value = 'Translated Text' @@ -186,9 +186,9 @@ class TestWorshipCenterProSongImport(TestCase): """ # GIVEN: A mocked out SongImport class, a mocked out pyodbc module with a simulated recordset, a mocked out # translate method, a mocked "manager", add_verse method & mocked_finish method. - with patch('openlp.plugins.songs.lib.songimport.worshipcenterproimport.SongImport'), \ - patch('openlp.plugins.songs.lib.songimport.worshipcenterproimport.pyodbc') as mocked_pyodbc, \ - patch('openlp.plugins.songs.lib.songimport.worshipcenterproimport.translate') as mocked_translate: + with patch('openlp.plugins.songs.lib.importers.worshipcenterpro.SongImport'), \ + patch('openlp.plugins.songs.lib.importers.worshipcenterpro.pyodbc') as mocked_pyodbc, \ + patch('openlp.plugins.songs.lib.importers.worshipcenterpro.translate') as mocked_translate: mocked_manager = MagicMock() mocked_import_wizard = MagicMock() mocked_add_verse = MagicMock() diff --git a/tests/functional/openlp_plugins/songs/test_zionworximport.py b/tests/functional/openlp_plugins/songs/test_zionworximport.py index a3f5bb20b..faedc7005 100644 --- a/tests/functional/openlp_plugins/songs/test_zionworximport.py +++ b/tests/functional/openlp_plugins/songs/test_zionworximport.py @@ -33,8 +33,8 @@ This module contains tests for the ZionWorx song importer. from unittest import TestCase from tests.functional import MagicMock, patch -from openlp.plugins.songs.lib.songimport.zionworximport import ZionWorxImport -from openlp.plugins.songs.lib.songimport.songimport import SongImport +from openlp.plugins.songs.lib.importers.zionworx import ZionWorxImport +from openlp.plugins.songs.lib.importers.songimport import SongImport class TestZionWorxImport(TestCase): @@ -46,7 +46,7 @@ class TestZionWorxImport(TestCase): Test creating an instance of the ZionWorx file importer """ # GIVEN: A mocked out SongImport class, and a mocked out "manager" - with patch('openlp.plugins.songs.lib.songimport.zionworximport.SongImport'): + with patch('openlp.plugins.songs.lib.importers.zionworx.SongImport'): mocked_manager = MagicMock() # WHEN: An importer object is created diff --git a/tests/helpers/songfileimport.py b/tests/helpers/songfileimport.py index 003ade543..6fae4d31d 100644 --- a/tests/helpers/songfileimport.py +++ b/tests/helpers/songfileimport.py @@ -43,7 +43,7 @@ class SongImportTestHelper(TestCase): def __init__(self, *args, **kwargs): super(SongImportTestHelper, self).__init__(*args, **kwargs) self.importer_module = __import__( - 'openlp.plugins.songs.lib.songimport.%s' % self.importer_module_name, fromlist=[self.importer_class_name]) + 'openlp.plugins.songs.lib.importers.%s' % self.importer_module_name, fromlist=[self.importer_class_name]) self.importer_class = getattr(self.importer_module, self.importer_class_name) def setUp(self): @@ -51,17 +51,17 @@ class SongImportTestHelper(TestCase): Patch and set up the mocks required. """ self.add_copyright_patcher = patch( - 'openlp.plugins.songs.lib.songimport.%s.%s.add_copyright' % (self.importer_module_name, + 'openlp.plugins.songs.lib.importers.%s.%s.add_copyright' % (self.importer_module_name, self.importer_class_name)) self.add_verse_patcher = patch( - 'openlp.plugins.songs.lib.songimport.%s.%s.add_verse' % (self.importer_module_name, + 'openlp.plugins.songs.lib.importers.%s.%s.add_verse' % (self.importer_module_name, self.importer_class_name)) self.finish_patcher = patch( - 'openlp.plugins.songs.lib.songimport.%s.%s.finish' % (self.importer_module_name, self.importer_class_name)) + 'openlp.plugins.songs.lib.importers.%s.%s.finish' % (self.importer_module_name, self.importer_class_name)) self.add_author_patcher = patch( - 'openlp.plugins.songs.lib.songimport.%s.%s.add_author' % (self.importer_module_name, + 'openlp.plugins.songs.lib.importers.%s.%s.add_author' % (self.importer_module_name, self.importer_class_name)) - self.song_import_patcher = patch('openlp.plugins.songs.lib.songimport.%s.SongImport' % + self.song_import_patcher = patch('openlp.plugins.songs.lib.importers.%s.SongImport' % self.importer_module_name) self.mocked_add_copyright = self.add_copyright_patcher.start() self.mocked_add_verse = self.add_verse_patcher.start() From f089e7522e762f4ccb1a26f66bea19dd8c61801e Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Fri, 4 Jul 2014 11:35:10 +0200 Subject: [PATCH 15/17] Cleanups --- openlp/plugins/songs/lib/importers/dreambeam.py | 3 +-- openlp/plugins/songs/lib/importers/easyworship.py | 3 +-- openlp/plugins/songs/lib/importers/mediashout.py | 2 +- openlp/plugins/songs/lib/importers/openlp.py | 2 +- openlp/plugins/songs/lib/importers/openlyrics.py | 2 +- openlp/plugins/songs/lib/importers/powersong.py | 2 +- openlp/plugins/songs/lib/importers/propresenter.py | 2 +- openlp/plugins/songs/lib/importers/songbeamer.py | 2 +- openlp/plugins/songs/lib/importers/songpro.py | 2 +- openlp/plugins/songs/lib/importers/songshowplus.py | 2 +- openlp/plugins/songs/lib/importers/wordsofworship.py | 5 ++--- openlp/plugins/songs/lib/importers/zionworx.py | 3 +-- 12 files changed, 13 insertions(+), 17 deletions(-) diff --git a/openlp/plugins/songs/lib/importers/dreambeam.py b/openlp/plugins/songs/lib/importers/dreambeam.py index 38aab4ae7..458961df0 100644 --- a/openlp/plugins/songs/lib/importers/dreambeam.py +++ b/openlp/plugins/songs/lib/importers/dreambeam.py @@ -27,8 +27,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### """ -The :mod:`dreambeamimport` module provides the functionality for importing -DreamBeam songs into the OpenLP database. +The :mod:`dreambeam` module provides the functionality for importing DreamBeam songs into the OpenLP database. """ import logging diff --git a/openlp/plugins/songs/lib/importers/easyworship.py b/openlp/plugins/songs/lib/importers/easyworship.py index c56e1dba1..761f83f59 100644 --- a/openlp/plugins/songs/lib/importers/easyworship.py +++ b/openlp/plugins/songs/lib/importers/easyworship.py @@ -27,8 +27,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### """ -The :mod:`ewimport` module provides the functionality for importing -EasyWorship song databases into the current installation database. +The :mod:`easyworship` module provides the functionality for importing EasyWorship song databases into OpenLP. """ import os diff --git a/openlp/plugins/songs/lib/importers/mediashout.py b/openlp/plugins/songs/lib/importers/mediashout.py index d82304fae..19d1b1d9d 100644 --- a/openlp/plugins/songs/lib/importers/mediashout.py +++ b/openlp/plugins/songs/lib/importers/mediashout.py @@ -27,7 +27,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### """ -The :mod:`mediashoutimport` module provides the functionality for importing +The :mod:`mediashout` module provides the functionality for importing a MediaShout database into the OpenLP database. """ import pyodbc diff --git a/openlp/plugins/songs/lib/importers/openlp.py b/openlp/plugins/songs/lib/importers/openlp.py index f4b066ef0..1a27e8d69 100644 --- a/openlp/plugins/songs/lib/importers/openlp.py +++ b/openlp/plugins/songs/lib/importers/openlp.py @@ -27,7 +27,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### """ -The :mod:`olpimport` module provides the functionality for importing OpenLP +The :mod:`openlp` module provides the functionality for importing OpenLP song databases into the current installation database. """ import logging diff --git a/openlp/plugins/songs/lib/importers/openlyrics.py b/openlp/plugins/songs/lib/importers/openlyrics.py index 78fcbf2af..9bb20dbf4 100644 --- a/openlp/plugins/songs/lib/importers/openlyrics.py +++ b/openlp/plugins/songs/lib/importers/openlyrics.py @@ -27,7 +27,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### """ -The :mod:`openlyricsimport` module provides the functionality for importing +The :mod:`openlyrics` module provides the functionality for importing songs which are saved as OpenLyrics files. """ diff --git a/openlp/plugins/songs/lib/importers/powersong.py b/openlp/plugins/songs/lib/importers/powersong.py index 89c847ab0..5aa0038f4 100644 --- a/openlp/plugins/songs/lib/importers/powersong.py +++ b/openlp/plugins/songs/lib/importers/powersong.py @@ -27,7 +27,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### """ -The :mod:`powersongimport` module provides the functionality for importing +The :mod:`powersong` module provides the functionality for importing PowerSong songs into the OpenLP database. """ import logging diff --git a/openlp/plugins/songs/lib/importers/propresenter.py b/openlp/plugins/songs/lib/importers/propresenter.py index 6ce3c0819..3bf7f9cd8 100644 --- a/openlp/plugins/songs/lib/importers/propresenter.py +++ b/openlp/plugins/songs/lib/importers/propresenter.py @@ -27,7 +27,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### """ -The :mod:`propresenterimport` module provides the functionality for importing +The :mod:`propresenter` module provides the functionality for importing ProPresenter song files into the current installation database. """ diff --git a/openlp/plugins/songs/lib/importers/songbeamer.py b/openlp/plugins/songs/lib/importers/songbeamer.py index 4c5873e2a..9a7429f02 100644 --- a/openlp/plugins/songs/lib/importers/songbeamer.py +++ b/openlp/plugins/songs/lib/importers/songbeamer.py @@ -27,7 +27,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### """ -The :mod:`songbeamerimport` module provides the functionality for importing SongBeamer songs into the OpenLP database. +The :mod:`songbeamer` module provides the functionality for importing SongBeamer songs into the OpenLP database. """ import chardet import codecs diff --git a/openlp/plugins/songs/lib/importers/songpro.py b/openlp/plugins/songs/lib/importers/songpro.py index 52d702097..efe1a85ea 100644 --- a/openlp/plugins/songs/lib/importers/songpro.py +++ b/openlp/plugins/songs/lib/importers/songpro.py @@ -27,7 +27,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### """ -The :mod:`songproimport` module provides the functionality for importing SongPro +The :mod:`songpro` module provides the functionality for importing SongPro songs into the OpenLP database. """ import re diff --git a/openlp/plugins/songs/lib/importers/songshowplus.py b/openlp/plugins/songs/lib/importers/songshowplus.py index d53cc33f1..6c9feab68 100644 --- a/openlp/plugins/songs/lib/importers/songshowplus.py +++ b/openlp/plugins/songs/lib/importers/songshowplus.py @@ -27,7 +27,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### """ -The :mod:`songshowplusimport` module provides the functionality for importing SongShow Plus songs into the OpenLP +The :mod:`songshowplus` module provides the functionality for importing SongShow Plus songs into the OpenLP database. """ import chardet diff --git a/openlp/plugins/songs/lib/importers/wordsofworship.py b/openlp/plugins/songs/lib/importers/wordsofworship.py index ce80c19ce..1b398c604 100644 --- a/openlp/plugins/songs/lib/importers/wordsofworship.py +++ b/openlp/plugins/songs/lib/importers/wordsofworship.py @@ -27,7 +27,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### """ -The :mod:`wowimport` module provides the functionality for importing Words of +The :mod:`wordsofworship` module provides the functionality for importing Words of Worship songs into the OpenLP database. """ import os @@ -43,8 +43,7 @@ log = logging.getLogger(__name__) class WordsOfWorshipImport(SongImport): """ - The :class:`WowImport` class provides the ability to import song files from - Words of Worship. + The :class:`WordsOfWorshipImport` class provides the ability to import song files from Words of Worship. **Words Of Worship Song File Format:** diff --git a/openlp/plugins/songs/lib/importers/zionworx.py b/openlp/plugins/songs/lib/importers/zionworx.py index 0b97aee26..ed3c41f3a 100644 --- a/openlp/plugins/songs/lib/importers/zionworx.py +++ b/openlp/plugins/songs/lib/importers/zionworx.py @@ -27,8 +27,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### """ -The :mod:`zionworximport` module provides the functionality for importing -ZionWorx songs into the OpenLP database. +The :mod:`zionworx` module provides the functionality for importing ZionWorx songs into the OpenLP database. """ import csv import logging From 0fb445e1177e38d6082fd06814bed888f89735ef Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Fri, 4 Jul 2014 11:36:54 +0200 Subject: [PATCH 16/17] PEP8 --- tests/helpers/songfileimport.py | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/tests/helpers/songfileimport.py b/tests/helpers/songfileimport.py index 6fae4d31d..18e7914b9 100644 --- a/tests/helpers/songfileimport.py +++ b/tests/helpers/songfileimport.py @@ -42,25 +42,22 @@ class SongImportTestHelper(TestCase): """ def __init__(self, *args, **kwargs): super(SongImportTestHelper, self).__init__(*args, **kwargs) - self.importer_module = __import__( - 'openlp.plugins.songs.lib.importers.%s' % self.importer_module_name, fromlist=[self.importer_class_name]) + self.importer_module = __import__('openlp.plugins.songs.lib.importers.%s' % + self.importer_module_name, fromlist=[self.importer_class_name]) self.importer_class = getattr(self.importer_module, self.importer_class_name) def setUp(self): """ Patch and set up the mocks required. """ - self.add_copyright_patcher = patch( - 'openlp.plugins.songs.lib.importers.%s.%s.add_copyright' % (self.importer_module_name, - self.importer_class_name)) - self.add_verse_patcher = patch( - 'openlp.plugins.songs.lib.importers.%s.%s.add_verse' % (self.importer_module_name, - self.importer_class_name)) - self.finish_patcher = patch( - 'openlp.plugins.songs.lib.importers.%s.%s.finish' % (self.importer_module_name, self.importer_class_name)) - self.add_author_patcher = patch( - 'openlp.plugins.songs.lib.importers.%s.%s.add_author' % (self.importer_module_name, - self.importer_class_name)) + self.add_copyright_patcher = patch('openlp.plugins.songs.lib.importers.%s.%s.add_copyright' % + (self.importer_module_name, self.importer_class_name)) + self.add_verse_patcher = patch('openlp.plugins.songs.lib.importers.%s.%s.add_verse' % + (self.importer_module_name, self.importer_class_name)) + self.finish_patcher = patch('openlp.plugins.songs.lib.importers.%s.%s.finish' % + (self.importer_module_name, self.importer_class_name)) + self.add_author_patcher = patch('openlp.plugins.songs.lib.importers.%s.%s.add_author' % + (self.importer_module_name, self.importer_class_name)) self.song_import_patcher = patch('openlp.plugins.songs.lib.importers.%s.SongImport' % self.importer_module_name) self.mocked_add_copyright = self.add_copyright_patcher.start() From 2938df5e022ed3aa2f1240742196ec14c701fb3e Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 6 Jul 2014 16:19:12 +0100 Subject: [PATCH 17/17] remove german --- resources/openlp.desktop | 2 -- 1 file changed, 2 deletions(-) diff --git a/resources/openlp.desktop b/resources/openlp.desktop index d585f4022..9f92f9d87 100755 --- a/resources/openlp.desktop +++ b/resources/openlp.desktop @@ -1,11 +1,9 @@ [Desktop Entry] Categories=AudioVideo; Exec=openlp %F -GenericName[de]=Church lyrics projection GenericName=Church lyrics projection Icon=openlp MimeType=application/x-openlp-service; -Name[de]=OpenLP Name=OpenLP StartupNotify=true Terminal=false