From 13374f1002d9014f2471e0749ace17e6049983df Mon Sep 17 00:00:00 2001 From: "Jeffrey S. Smith" Date: Mon, 2 Sep 2013 23:07:29 -0500 Subject: [PATCH 01/49] Add preliminary ProPresenter song import support --- openlp/plugins/songs/lib/__init__.py | 2 + openlp/plugins/songs/lib/importer.py | 26 +++++++--- openlp/plugins/songs/lib/ppimport.py | 73 ++++++++++++++++++++++++++++ 3 files changed, 93 insertions(+), 8 deletions(-) create mode 100644 openlp/plugins/songs/lib/ppimport.py diff --git a/openlp/plugins/songs/lib/__init__.py b/openlp/plugins/songs/lib/__init__.py index 271a94710..5918dd330 100644 --- a/openlp/plugins/songs/lib/__init__.py +++ b/openlp/plugins/songs/lib/__init__.py @@ -538,6 +538,8 @@ def strip_rtf(text, default_encoding=None): out.append('\xA0') elif char in '{}\\' and not ignorable: out.append(char) + elif char in '\r\n' and not ignorable: + out.append(SPECIAL_CHARS['par']) elif char == '-' and not ignorable: out.append('\u00AD') elif char == '_' and not ignorable: diff --git a/openlp/plugins/songs/lib/importer.py b/openlp/plugins/songs/lib/importer.py index 8e7a9f36e..f760bd8cd 100644 --- a/openlp/plugins/songs/lib/importer.py +++ b/openlp/plugins/songs/lib/importer.py @@ -49,6 +49,7 @@ from .songproimport import SongProImport from .sundayplusimport import SundayPlusImport from .foilpresenterimport import FoilPresenterImport from .zionworximport import ZionWorxImport +from .ppimport import ProPresenterImport # Imports that might fail @@ -157,14 +158,15 @@ class SongFormat(object): MediaShout = 8 OpenSong = 9 PowerSong = 10 - SongBeamer = 11 - SongPro = 12 - SongShowPlus = 13 - SongsOfFellowship = 14 - SundayPlus = 15 - WordsOfWorship = 16 - WorshipCenterPro = 17 - ZionWorx = 18 + ProPresenter = 11 + SongBeamer = 12 + SongPro = 13 + SongShowPlus = 14 + SongsOfFellowship = 15 + SundayPlus = 16 + WordsOfWorship = 17 + WorshipCenterPro = 18 + ZionWorx = 19 # Set optional attribute defaults __defaults__ = { @@ -262,6 +264,13 @@ class SongFormat(object): 'invalidSourceMsg': translate('SongsPlugin.ImportWizardForm', 'You need to specify a valid PowerSong 1.0 database folder.') }, + ProPresenter: { + 'class': ProPresenterImport, + 'name': 'ProPresenter', + 'prefix': 'proPresenter', + 'filter': '%s (*.pro4)' % translate('SongsPlugin.ImportWizardForm', + 'ProPresenter Song Files') + }, SongBeamer: { 'class': SongBeamerImport, 'name': 'SongBeamer', @@ -347,6 +356,7 @@ class SongFormat(object): SongFormat.MediaShout, SongFormat.OpenSong, SongFormat.PowerSong, + SongFormat.ProPresenter, SongFormat.SongBeamer, SongFormat.SongPro, SongFormat.SongShowPlus, diff --git a/openlp/plugins/songs/lib/ppimport.py b/openlp/plugins/songs/lib/ppimport.py new file mode 100644 index 000000000..11ba9d2e7 --- /dev/null +++ b/openlp/plugins/songs/lib/ppimport.py @@ -0,0 +1,73 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2013 Raoul Snyman # +# Portions copyright (c) 2008-2013 Tim Bentley, Gerald Britton, Jonathan # +# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, # +# 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:`ppimport` module provides the functionality for importing +ProPresenter song files into the current installation database. +""" + +import os +import base64 +from lxml import objectify + +from openlp.core.ui.wizard import WizardStrings +from openlp.plugins.songs.lib import strip_rtf +from .songimport import SongImport + +class ProPresenterImport(SongImport): + """ + The :class:`ProPresenterImport` class provides OpenLP with the + ability to import ProPresenter song files. + """ + def doImport(self): + self.import_wizard.progress_bar.setMaximum(len(self.import_source)) + for file_path in self.import_source: + if self.stop_import_flag: + return + self.import_wizard.increment_progress_bar( + WizardStrings.ImportingType % os.path.basename(file_path)) + root = objectify.parse(open(file_path, 'rb')).getroot() + self.processSong(root) + + def processSong(self, root): + self.setDefaults() + self.title = root.get('CCLISongTitle') + self.copyright = root.get('CCLICopyrightInfo') + self.comments = root.get('notes') + self.ccliNumber = root.get('CCLILicenseNumber') + for author_key in ['author', 'artist', 'CCLIArtistCredits']: + author = root.get(author_key) + if len(author) > 0: + self.parse_author(author) + for slide in root.slides.RVDisplaySlide: + RTFData = slide.displayElements.RVTextElement.get('RTFData') + rtf = base64.standard_b64decode(RTFData) + words, encoding = strip_rtf(rtf.decode()) + self.addVerse(words) + if not self.finish(): + self.logError(self.import_source) From d10507e250551c4af7c35278d8062599369cfd2a Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Wed, 21 May 2014 16:47:44 +0200 Subject: [PATCH 02/49] Small string fixes --- openlp/core/ui/themeform.py | 6 +++--- openlp/plugins/songs/lib/cclifileimport.py | 3 +-- openlp/plugins/songs/lib/db.py | 8 ++++---- openlp/plugins/songs/lib/xml.py | 2 +- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/openlp/core/ui/themeform.py b/openlp/core/ui/themeform.py index 321071c49..46fd227dd 100644 --- a/openlp/core/ui/themeform.py +++ b/openlp/core/ui/themeform.py @@ -18,11 +18,11 @@ # Software Foundation; version 2 of the License. # # # # This program is distributed in the hope that it will be useful, but WITHOUT # -# AN_y WARRANT_y; without even the implied warranty of MERCHANTABILIT_y or # +# 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 # +# 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 # ############################################################################### @@ -179,7 +179,7 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard, RegistryProperties): if self.page(self.currentId()) == self.background_page and \ self.theme.background_type == background_image and is_not_image_file(self.theme.background_filename): QtGui.QMessageBox.critical(self, translate('OpenLP.ThemeWizard', 'Background Image Empty'), - translate('OpenLP.ThemeWizard', '_you have not selected a ' + translate('OpenLP.ThemeWizard', 'You have not selected a ' 'background image. Please select one before continuing.')) return False else: diff --git a/openlp/plugins/songs/lib/cclifileimport.py b/openlp/plugins/songs/lib/cclifileimport.py index 5c1fbdcb2..eda235ca1 100644 --- a/openlp/plugins/songs/lib/cclifileimport.py +++ b/openlp/plugins/songs/lib/cclifileimport.py @@ -63,7 +63,6 @@ class CCLIFileImport(SongImport): for filename in self.import_source: filename = str(filename) log.debug('Importing CCLI File: %s', filename) - lines = [] if os.path.isfile(filename): detect_file = open(filename, 'r') detect_content = detect_file.read(2048) @@ -250,7 +249,7 @@ class CCLIFileImport(SongImport): # e.g. For use solely with the SongSelect Terms of Use. All rights Reserved. www.ccli.com CCLI Licence number of user - # e.g. CCL-Liedlizenznummer: 14 / CCLI License No. 14 + # e.g. CCLI-Liedlizenznummer: 14 / CCLI License No. 14 """ log.debug('TXT file text: %s', text_list) diff --git a/openlp/plugins/songs/lib/db.py b/openlp/plugins/songs/lib/db.py index 91649c951..80b6580ba 100644 --- a/openlp/plugins/songs/lib/db.py +++ b/openlp/plugins/songs/lib/db.py @@ -74,10 +74,10 @@ class AuthorType(object): WordsAndMusic = 'words+music' Translation = 'translation' Types = { - Words: translate('OpenLP.Ui', 'Words'), - Music: translate('OpenLP.Ui', 'Music'), - WordsAndMusic: translate('OpenLP.Ui', 'Words and Music'), - Translation: translate('OpenLP.Ui', 'Translation') + Words: translate('SongsPlugin.AuthorType', 'Words'), + Music: translate('SongsPlugin.AuthorType', 'Music'), + WordsAndMusic: translate('SongsPlugin.AuthorType', 'Words and Music'), + Translation: translate('SongsPlugin.AuthorType', 'Translation') } diff --git a/openlp/plugins/songs/lib/xml.py b/openlp/plugins/songs/lib/xml.py index 87e5da21e..9219f6062 100644 --- a/openlp/plugins/songs/lib/xml.py +++ b/openlp/plugins/songs/lib/xml.py @@ -664,7 +664,7 @@ class OpenLyrics(object): # OpenLyrics 0.8 uses
for new lines. Append text from "lines" element to verse text. if version > '0.7': text = self._process_lines_mixed_content(element) - # OpenLyrics version <= 0.7 contais elements to represent lines. First child element is tested. + # OpenLyrics version <= 0.7 contains elements to represent lines. First child element is tested. else: # Loop over the "line" elements removing comments and chords. for line in element: From 2466a7d8fab3263d71e6e80fbe53ca7ac023d042 Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Wed, 21 May 2014 17:09:44 +0200 Subject: [PATCH 03/49] Add hints for author types --- openlp/plugins/songs/lib/db.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/openlp/plugins/songs/lib/db.py b/openlp/plugins/songs/lib/db.py index 80b6580ba..7b06d947d 100644 --- a/openlp/plugins/songs/lib/db.py +++ b/openlp/plugins/songs/lib/db.py @@ -74,10 +74,10 @@ class AuthorType(object): WordsAndMusic = 'words+music' Translation = 'translation' Types = { - Words: translate('SongsPlugin.AuthorType', 'Words'), - Music: translate('SongsPlugin.AuthorType', 'Music'), - WordsAndMusic: translate('SongsPlugin.AuthorType', 'Words and Music'), - Translation: translate('SongsPlugin.AuthorType', 'Translation') + Words: translate('SongsPlugin.AuthorType', 'Words', 'Author who wrote the lyrics of a song'), + Music: translate('SongsPlugin.AuthorType', 'Music', 'Author who wrote the music of a song'), + WordsAndMusic: translate('SongsPlugin.AuthorType', 'Author who wrote both lyrics and music of a song'), + Translation: translate('SongsPlugin.AuthorType', 'Translation', 'Author who translated the song') } From 854149408f5628b2cd195e4fccebdfedf53798d6 Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Wed, 21 May 2014 17:31:25 +0200 Subject: [PATCH 04/49] Add test --- tests/functional/openlp_core_lib/test_ui.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/functional/openlp_core_lib/test_ui.py b/tests/functional/openlp_core_lib/test_ui.py index f1b8ee17a..7f9aba9ab 100644 --- a/tests/functional/openlp_core_lib/test_ui.py +++ b/tests/functional/openlp_core_lib/test_ui.py @@ -197,3 +197,17 @@ class TestUi(TestCase): # THEN: The index should have changed self.assertEqual(2, combo.currentIndex()) + + def test_create_widget_action(self): + """ + Test creating an action for a widget + """ + # GIVEN: A button + button = QtGui.QPushButton() + + # WHEN: We call the function + action = create_widget_action(button, 'some action') + + # THEN: The action should be returned + self.assertIsInstance(action, QtGui.QAction) + self.assertEqual(action.objectName(), 'some action') From 49a48c6463a13b747617025546c0f79e40e3728e Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Wed, 21 May 2014 19:20:44 +0200 Subject: [PATCH 05/49] more string fixes --- openlp/core/ui/formattingtagform.py | 7 +++---- openlp/plugins/bibles/lib/csvbible.py | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/openlp/core/ui/formattingtagform.py b/openlp/core/ui/formattingtagform.py index be4247bc1..4f3d5d251 100644 --- a/openlp/core/ui/formattingtagform.py +++ b/openlp/core/ui/formattingtagform.py @@ -91,10 +91,9 @@ class FormattingTagForm(QtGui.QDialog, Ui_FormattingTagDialog, FormattingTagCont """ new_row = self.tag_table_widget.rowCount() self.tag_table_widget.insertRow(new_row) - self.tag_table_widget.setItem(new_row, 0, - QtGui.QTableWidgetItem(translate('OpenLP.FormattingTagForm', 'New Tag%s') - % str(new_row))) - self.tag_table_widget.setItem(new_row, 1, QtGui.QTableWidgetItem('n%s' % str(new_row))) + self.tag_table_widget.setItem(new_row, 0, QtGui.QTableWidgetItem(translate('OpenLP.FormattingTagForm', + 'New Tag %d' % new_row))) + self.tag_table_widget.setItem(new_row, 1, QtGui.QTableWidgetItem('n%d' % new_row)) self.tag_table_widget.setItem(new_row, 2, QtGui.QTableWidgetItem(translate('OpenLP.FormattingTagForm', ''))) self.tag_table_widget.setItem(new_row, 3, QtGui.QTableWidgetItem('')) diff --git a/openlp/plugins/bibles/lib/csvbible.py b/openlp/plugins/bibles/lib/csvbible.py index c7d37cb7b..9bffb25fe 100644 --- a/openlp/plugins/bibles/lib/csvbible.py +++ b/openlp/plugins/bibles/lib/csvbible.py @@ -149,7 +149,7 @@ class CSVBible(BibleDB): book_ptr = book.name self.wizard.increment_progress_bar( translate('BiblesPlugin.CSVBible', - 'Importing verses from %s... Importing verses from ...') % book.name) + 'Importing verses from %s...' % book.name, 'Importing verses from ...')) self.session.commit() try: verse_text = str(line[3], details['encoding']) From b882f7e1f1f68d1d145491509038257d6df71e1f Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Wed, 21 May 2014 19:42:32 +0200 Subject: [PATCH 06/49] Typo --- scripts/translation_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/translation_utils.py b/scripts/translation_utils.py index ad3edcaa3..13e6a0ed3 100755 --- a/scripts/translation_utils.py +++ b/scripts/translation_utils.py @@ -194,7 +194,7 @@ def download_translations(): password = getpass(' Transifex password: ') # First get the list of languages url = SERVER_URL + 'resource/ents/' - base64string = base64.encodbytes('%s:%s' % (username, password))[:-1] + base64string = base64.encodebytes('%s:%s' % (username, password))[:-1] auth_header = 'Basic %s' % base64string request = urllib.request.Request(url + '?details') request.add_header('Authorization', auth_header) From de528e7c41307580dffa06e1f369af163d2eeca4 Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Wed, 21 May 2014 21:57:06 +0200 Subject: [PATCH 07/49] Add setup.cfg with pep8 config --- setup.cfg | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 setup.cfg diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 000000000..7b4bf5a3c --- /dev/null +++ b/setup.cfg @@ -0,0 +1,3 @@ +[pep8] +exclude=resources.py,vlc.py +max-line-length = 120 From eb5f0b7dd4817ce3026345dc731df9c197b309c4 Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Thu, 22 May 2014 13:52:53 +0200 Subject: [PATCH 08/49] Fixes for translation utils --- scripts/translation_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/translation_utils.py b/scripts/translation_utils.py index 13e6a0ed3..2e9dffb12 100755 --- a/scripts/translation_utils.py +++ b/scripts/translation_utils.py @@ -175,7 +175,7 @@ def run(command): process = QtCore.QProcess() process.start(command) while process.waitForReadyRead(): - print_verbose('ReadyRead: %s' % QtCore.QString(process.readAll())) + print_verbose('ReadyRead: %s' % process.readAll()) print_verbose('Error(s):\n%s' % process.readAllStandardError()) print_verbose('Output:\n%s' % process.readAllStandardOutput()) @@ -261,7 +261,7 @@ def prepare_project(): lines.append('TRANSLATIONS += %s' % line) lines.sort() file = open(os.path.join(start_dir, 'openlp.pro'), 'w') - file.write('\n'.join(lines).encode('utf8')) + file.write('\n'.join(lines)) file.close() print_quiet(' Done.') From e70a09c93e3a7ad48551b4f04dbff77a6aee63d6 Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Thu, 22 May 2014 15:40:05 +0200 Subject: [PATCH 09/49] Detect language folder in source directory --- openlp/core/common/applocation.py | 29 +++++++++++++++------------- openlp/core/utils/languagemanager.py | 3 +-- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/openlp/core/common/applocation.py b/openlp/core/common/applocation.py index 2bc4027b6..f3abd5656 100644 --- a/openlp/core/common/applocation.py +++ b/openlp/core/common/applocation.py @@ -72,15 +72,15 @@ class AppLocation(object): :param dir_type: The directory type you want, for instance the data directory. Default *AppLocation.AppDir* """ if dir_type == AppLocation.AppDir: - return get_frozen_path(os.path.abspath(os.path.split(sys.argv[0])[0]), os.path.split(openlp.__file__)[0]) + return get_frozen_path(os.path.abspath(os.path.dirname(sys.argv[0])), os.path.dirname(openlp.__file__)) elif dir_type == AppLocation.PluginsDir: - app_path = os.path.abspath(os.path.split(sys.argv[0])[0]) + app_path = os.path.abspath(os.path.dirname(sys.argv[0])) return get_frozen_path(os.path.join(app_path, 'plugins'), - os.path.join(os.path.split(openlp.__file__)[0], 'plugins')) + os.path.join(os.path.dirname(openlp.__file__), 'plugins')) elif dir_type == AppLocation.VersionDir: - return get_frozen_path(os.path.abspath(os.path.split(sys.argv[0])[0]), os.path.split(openlp.__file__)[0]) + return get_frozen_path(os.path.abspath(os.path.dirname(sys.argv[0])), os.path.dirname(openlp.__file__)) elif dir_type == AppLocation.LanguageDir: - app_path = get_frozen_path(os.path.abspath(os.path.split(sys.argv[0])[0]), _get_os_dir_path(dir_type)) + app_path = get_frozen_path(os.path.abspath(os.path.dirname(sys.argv[0])), _get_os_dir_path(dir_type)) return os.path.join(app_path, 'i18n') elif dir_type == AppLocation.DataDir and AppLocation.BaseDir: return os.path.join(AppLocation.BaseDir, 'data') @@ -140,25 +140,28 @@ def _get_os_dir_path(dir_type): """ Return a path based on which OS and environment we are running in. """ + # If running from source, return the language directory from the source directory + if dir_type == AppLocation.LanguageDir: + directory = os.path.abspath(os.path.join(os.path.dirname(openlp.__file__), '..', 'resources')) + if os.path.exists(directory): + return directory if sys.platform == 'win32': if dir_type == AppLocation.DataDir: return os.path.join(str(os.getenv('APPDATA')), 'openlp', 'data') elif dir_type == AppLocation.LanguageDir: - return os.path.split(openlp.__file__)[0] + return os.path.dirname(openlp.__file__) return os.path.join(str(os.getenv('APPDATA')), 'openlp') elif sys.platform == 'darwin': if dir_type == AppLocation.DataDir: - return os.path.join(str(os.getenv('HOME')), - 'Library', 'Application Support', 'openlp', 'Data') + return os.path.join(str(os.getenv('HOME')), 'Library', 'Application Support', 'openlp', 'Data') elif dir_type == AppLocation.LanguageDir: - return os.path.split(openlp.__file__)[0] + return os.path.dirname(openlp.__file__) return os.path.join(str(os.getenv('HOME')), 'Library', 'Application Support', 'openlp') else: if dir_type == AppLocation.LanguageDir: - for prefix in ['/usr/local', '/usr']: - directory = os.path.join(prefix, 'share', 'openlp') - if os.path.exists(directory): - return directory + directory = os.path.join('/usr', 'local', 'share', 'openlp') + if os.path.exists(directory): + return directory return os.path.join('/usr', 'share', 'openlp') if XDG_BASE_AVAILABLE: if dir_type == AppLocation.DataDir: diff --git a/openlp/core/utils/languagemanager.py b/openlp/core/utils/languagemanager.py index bb584f7bd..dd048e04c 100644 --- a/openlp/core/utils/languagemanager.py +++ b/openlp/core/utils/languagemanager.py @@ -71,8 +71,7 @@ class LanguageManager(object): """ Find all available language files in this OpenLP install """ - log.debug('Translation files: %s', AppLocation.get_directory( - AppLocation.LanguageDir)) + log.debug('Translation files: %s', AppLocation.get_directory(AppLocation.LanguageDir)) trans_dir = QtCore.QDir(AppLocation.get_directory(AppLocation.LanguageDir)) file_names = trans_dir.entryList(['*.qm'], QtCore.QDir.Files, QtCore.QDir.Name) # Remove qm files from the list which start with "qt_". From 873f18ad651e3b2ab4fc763a8c568009885252ea Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Thu, 22 May 2014 15:48:57 +0200 Subject: [PATCH 10/49] Add test --- tests/functional/openlp_core_lib/test_ui.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/functional/openlp_core_lib/test_ui.py b/tests/functional/openlp_core_lib/test_ui.py index f1b8ee17a..f6a27f020 100644 --- a/tests/functional/openlp_core_lib/test_ui.py +++ b/tests/functional/openlp_core_lib/test_ui.py @@ -154,6 +154,21 @@ class TestUi(TestCase): self.assertEqual('my tooltip', action.toolTip()) self.assertEqual('my statustip', action.statusTip()) + def test_create_action_2(self): + """ + Test creating an action + """ + # GIVEN: A dialog + dialog = QtGui.QDialog() + + # WHEN: We create an action with some properties + action = create_action(dialog, 'my_action', checked=True, enabled=False, visible=False) + + # THEN: These properties should be set + self.assertEqual(True, action.isChecked()) + self.assertEqual(False, action.isEnabled()) + self.assertEqual(False, action.isVisible()) + def test_create_valign_selection_widgets(self): """ Test creating a combo box for valign selection From ea30fb4bdc60061505b3ad08f0d9dac0c4df729e Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Thu, 22 May 2014 23:35:38 +0200 Subject: [PATCH 11/49] Accidentally removed string --- openlp/plugins/songs/lib/db.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openlp/plugins/songs/lib/db.py b/openlp/plugins/songs/lib/db.py index 7b06d947d..2ce7ced1d 100644 --- a/openlp/plugins/songs/lib/db.py +++ b/openlp/plugins/songs/lib/db.py @@ -76,7 +76,8 @@ class AuthorType(object): Types = { Words: translate('SongsPlugin.AuthorType', 'Words', 'Author who wrote the lyrics of a song'), Music: translate('SongsPlugin.AuthorType', 'Music', 'Author who wrote the music of a song'), - WordsAndMusic: translate('SongsPlugin.AuthorType', 'Author who wrote both lyrics and music of a song'), + WordsAndMusic: translate('SongsPlugin.AuthorType', 'Words and Music', + 'Author who wrote both lyrics and music of a song'), Translation: translate('SongsPlugin.AuthorType', 'Translation', 'Author who translated the song') } From 56ebf2de006d012000d95b8996491a4b36432d7f Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Wed, 28 May 2014 19:17:26 +0200 Subject: [PATCH 12/49] Revert change in check for language dir --- openlp/core/common/applocation.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/openlp/core/common/applocation.py b/openlp/core/common/applocation.py index f3abd5656..073d3c7f7 100644 --- a/openlp/core/common/applocation.py +++ b/openlp/core/common/applocation.py @@ -159,9 +159,10 @@ def _get_os_dir_path(dir_type): return os.path.join(str(os.getenv('HOME')), 'Library', 'Application Support', 'openlp') else: if dir_type == AppLocation.LanguageDir: - directory = os.path.join('/usr', 'local', 'share', 'openlp') - if os.path.exists(directory): - return directory + for prefix in ['/usr/local', '/usr']: + directory = os.path.join(prefix, 'share', 'openlp') + if os.path.exists(directory): + return directory return os.path.join('/usr', 'share', 'openlp') if XDG_BASE_AVAILABLE: if dir_type == AppLocation.DataDir: From d424270b7fd56b1ad02b6126886276ff0c96a56b Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Fri, 30 May 2014 11:21:26 +0200 Subject: [PATCH 13/49] Fixed locating mudraw on windows and mac, and enabled presentationplugin on mac. --- openlp/core/lib/pluginmanager.py | 5 ----- openlp/core/ui/firsttimeform.py | 5 +---- openlp/core/ui/firsttimewizard.py | 16 +++++----------- .../plugins/presentations/lib/pdfcontroller.py | 8 ++++---- .../openlp_core_lib/test_pluginmanager.py | 2 +- 5 files changed, 11 insertions(+), 25 deletions(-) diff --git a/openlp/core/lib/pluginmanager.py b/openlp/core/lib/pluginmanager.py index 474113c98..822d510b2 100644 --- a/openlp/core/lib/pluginmanager.py +++ b/openlp/core/lib/pluginmanager.py @@ -82,11 +82,6 @@ class PluginManager(RegistryMixin, OpenLPMixin, RegistryProperties): present_plugin_dir = os.path.join(self.base_path, 'presentations') self.log_debug('finding plugins in %s at depth %d' % (self.base_path, start_depth)) for root, dirs, files in os.walk(self.base_path): - if sys.platform == 'darwin' and root.startswith(present_plugin_dir): - # TODO Presentation plugin is not yet working on Mac OS X. - # For now just ignore it. The following code will ignore files from the presentation plugin directory - # and thereby never import the plugin. - continue for name in files: if name.endswith('.py') and not name.startswith('__'): path = os.path.abspath(os.path.join(root, name)) diff --git a/openlp/core/ui/firsttimeform.py b/openlp/core/ui/firsttimeform.py index 531c4b49f..d7c16f0d3 100644 --- a/openlp/core/ui/firsttimeform.py +++ b/openlp/core/ui/firsttimeform.py @@ -412,10 +412,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard, RegistryProperties): self._increment_progress_bar(translate('OpenLP.FirstTimeWizard', 'Enabling selected plugins...')) self._set_plugin_status(self.songs_check_box, 'songs/status') self._set_plugin_status(self.bible_check_box, 'bibles/status') - # TODO Presentation plugin is not yet working on Mac OS X. - # For now just ignore it. - if sys.platform != 'darwin': - self._set_plugin_status(self.presentation_check_box, 'presentations/status') + self._set_plugin_status(self.presentation_check_box, 'presentations/status') self._set_plugin_status(self.image_check_box, 'images/status') self._set_plugin_status(self.media_check_box, 'media/status') self._set_plugin_status(self.remote_check_box, 'remotes/status') diff --git a/openlp/core/ui/firsttimewizard.py b/openlp/core/ui/firsttimewizard.py index 35623ded2..ff1675ff5 100644 --- a/openlp/core/ui/firsttimewizard.py +++ b/openlp/core/ui/firsttimewizard.py @@ -95,13 +95,10 @@ class Ui_FirstTimeWizard(object): self.image_check_box.setChecked(True) self.image_check_box.setObjectName('image_check_box') self.plugin_layout.addWidget(self.image_check_box) - # TODO Presentation plugin is not yet working on Mac OS X. - # For now just ignore it. - if sys.platform != 'darwin': - self.presentation_check_box = QtGui.QCheckBox(self.plugin_page) - self.presentation_check_box.setChecked(True) - self.presentation_check_box.setObjectName('presentation_check_box') - self.plugin_layout.addWidget(self.presentation_check_box) + self.presentation_check_box = QtGui.QCheckBox(self.plugin_page) + self.presentation_check_box.setChecked(True) + self.presentation_check_box.setObjectName('presentation_check_box') + self.plugin_layout.addWidget(self.presentation_check_box) self.media_check_box = QtGui.QCheckBox(self.plugin_page) self.media_check_box.setChecked(True) self.media_check_box.setObjectName('media_check_box') @@ -222,10 +219,7 @@ class Ui_FirstTimeWizard(object): self.custom_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Custom Slides')) self.bible_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Bible')) self.image_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Images')) - # TODO Presentation plugin is not yet working on Mac OS X. - # For now just ignore it. - if sys.platform != 'darwin': - self.presentation_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Presentations')) + self.presentation_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Presentations')) self.media_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Media (Audio and Video)')) self.remote_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Allow remote access')) self.song_usage_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Monitor Song Usage')) diff --git a/openlp/plugins/presentations/lib/pdfcontroller.py b/openlp/plugins/presentations/lib/pdfcontroller.py index 5ed11d2ab..b98ae131a 100644 --- a/openlp/plugins/presentations/lib/pdfcontroller.py +++ b/openlp/plugins/presentations/lib/pdfcontroller.py @@ -126,8 +126,8 @@ class PdfController(PresentationController): if os.name == 'nt': # for windows we only accept mudraw.exe in the base folder application_path = AppLocation.get_directory(AppLocation.AppDir) - if os.path.isfile(application_path + '/../mudraw.exe'): - self.mudrawbin = application_path + '/../mudraw.exe' + if os.path.isfile(os.path.join(application_path, 'mudraw.exe')): + self.mudrawbin = os.path.join(application_path, 'mudraw.exe') else: DEVNULL = open(os.devnull, 'wb') # First try to find mupdf @@ -145,8 +145,8 @@ class PdfController(PresentationController): # Last option: check if mudraw is placed in OpenLP base folder if not self.mudrawbin and not self.gsbin: application_path = AppLocation.get_directory(AppLocation.AppDir) - if os.path.isfile(application_path + '/../mudraw'): - self.mudrawbin = application_path + '/../mudraw' + if os.path.isfile(os.path.join(application_path, 'mudraw')): + self.mudrawbin = os.path.join(application_path, 'mudraw') if self.mudrawbin: self.also_supports = ['xps'] return True diff --git a/tests/interfaces/openlp_core_lib/test_pluginmanager.py b/tests/interfaces/openlp_core_lib/test_pluginmanager.py index 262f9f2f3..ba81d708f 100644 --- a/tests/interfaces/openlp_core_lib/test_pluginmanager.py +++ b/tests/interfaces/openlp_core_lib/test_pluginmanager.py @@ -88,7 +88,7 @@ class TestPluginManager(TestCase, TestMixin): plugin_names = [plugin.name for plugin in plugin_manager.plugins] assert 'songs' in plugin_names, 'There should be a "songs" plugin.' assert 'bibles' in plugin_names, 'There should be a "bibles" plugin.' - assert 'presentations' not in plugin_names, 'There should NOT be a "presentations" plugin.' + assert 'presentations' in plugin_names, 'There should be a "presentations" plugin.' assert 'images' in plugin_names, 'There should be a "images" plugin.' assert 'media' in plugin_names, 'There should be a "media" plugin.' assert 'custom' in plugin_names, 'There should be a "custom" plugin.' From 0441f0e71b3f4d2e4031c5ca5b8cbb5a98cca8fb Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Fri, 30 May 2014 19:59:11 +0200 Subject: [PATCH 14/49] Better description --- tests/functional/openlp_core_lib/test_ui.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/functional/openlp_core_lib/test_ui.py b/tests/functional/openlp_core_lib/test_ui.py index f6a27f020..854edcf88 100644 --- a/tests/functional/openlp_core_lib/test_ui.py +++ b/tests/functional/openlp_core_lib/test_ui.py @@ -156,7 +156,7 @@ class TestUi(TestCase): def test_create_action_2(self): """ - Test creating an action + Test creating an action with the 'checked', 'enabled' and 'visible' properties. """ # GIVEN: A dialog dialog = QtGui.QDialog() From 08e41672cb713e31afa6e883959a692c544de8a5 Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Sun, 8 Jun 2014 16:27:03 +0200 Subject: [PATCH 15/49] Better name for test --- tests/functional/openlp_core_lib/test_ui.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/functional/openlp_core_lib/test_ui.py b/tests/functional/openlp_core_lib/test_ui.py index 7d1658968..591762947 100644 --- a/tests/functional/openlp_core_lib/test_ui.py +++ b/tests/functional/openlp_core_lib/test_ui.py @@ -154,7 +154,7 @@ class TestUi(TestCase): self.assertEqual('my tooltip', action.toolTip()) self.assertEqual('my statustip', action.statusTip()) - def test_create_action_2(self): + def test_create_checked_enabled_visible_action(self): """ Test creating an action with the 'checked', 'enabled' and 'visible' properties. """ From 0794a1e0c6b2618113a370e65d2b2fbd45a55ed9 Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Sun, 8 Jun 2014 17:20:23 +0200 Subject: [PATCH 16/49] Give proper error messages in EasyWorship import Fixes: https://launchpad.net/bugs/1326664 --- openlp/plugins/songs/lib/ewimport.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/songs/lib/ewimport.py b/openlp/plugins/songs/lib/ewimport.py index 42f375e4b..ccd89e228 100644 --- a/openlp/plugins/songs/lib/ewimport.py +++ b/openlp/plugins/songs/lib/ewimport.py @@ -200,11 +200,20 @@ class EasyWorshipSongImport(SongImport): Import the songs from the database """ # Open the DB and MB files if they exist - import_source_mb = self.import_source.replace('.DB', '.MB') - if not os.path.isfile(self.import_source) or not os.path.isfile(import_source_mb): + import_source_mb = self.import_source.replace('.DB', '.MB').replace('.db', '.mb') + if not os.path.isfile(self.import_source): + self.log_error(self.import_source, translate('SongsPlugin.EasyWorshipSongImport', + 'This file does not exist.')) + return + if not os.path.isfile(import_source_mb): + self.log_error(self.import_source, translate('SongsPlugin.EasyWorshipSongImport', + 'Could not find the "Songs.MB" file. It must be in the same ' + 'folder as the "Songs.DB" file.')) return db_size = os.path.getsize(self.import_source) if db_size < 0x800: + self.log_error(self.import_source, translate('SongsPlugin.EasyWorshipSongImport', + 'This file is no valid EasyWorship Database.')) return db_file = open(self.import_source, 'rb') self.memo_file = open(import_source_mb, 'rb') @@ -213,6 +222,8 @@ class EasyWorshipSongImport(SongImport): if header_size != 0x800 or block_size < 1 or block_size > 4: db_file.close() self.memo_file.close() + self.log_error(self.import_source, translate('SongsPlugin.EasyWorshipSongImport', + 'This file is no valid EasyWorship Database.')) return # Take a stab at how text is encoded self.encoding = 'cp1252' @@ -240,6 +251,8 @@ class EasyWorshipSongImport(SongImport): self.encoding = 'cp874' self.encoding = retrieve_windows_encoding(self.encoding) if not self.encoding: + self.log_error(self.import_source, translate('SongsPlugin.EasyWorshipSongImport', + 'Could not retrieve encoding.')) return # Read the field description information db_file.seek(120) From b2e4c6f99f4abb96740741ec6239b9212bc1aff8 Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Mon, 9 Jun 2014 09:55:48 +0200 Subject: [PATCH 17/49] Add test for missing songs.mb --- .../openlp_plugins/songs/test_ewimport.py | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/functional/openlp_plugins/songs/test_ewimport.py b/tests/functional/openlp_plugins/songs/test_ewimport.py index 8d9302015..ea557711b 100644 --- a/tests/functional/openlp_plugins/songs/test_ewimport.py +++ b/tests/functional/openlp_plugins/songs/test_ewimport.py @@ -314,6 +314,26 @@ class TestEasyWorshipSongImport(TestCase): mocked_os_path.isfile.assert_any_call('Songs.DB') mocked_os_path.isfile.assert_any_call('Songs.MB') + def do_import_source_invalid_test(self): + """ + 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: + mocked_manager = MagicMock() + importer = EasyWorshipSongImport(mocked_manager, filenames=[]) + importer.log_error = MagicMock() + mocked_os_path.isfile.side_effect = [True, False] + + # WHEN: do_import is supplied with an import source (Songs.MB missing) + importer.import_source = 'Songs.DB' + importer.do_import() + + # THEN: do_import should have logged an error that the Songs.MB file could not be found. + importer.log_error.assert_any_call(importer.import_source, 'Could not find the "Songs.MB" file. It must be ' + 'in the same folder as the "Songs.DB" file.') + def do_import_database_validity_test(self): """ Test the :mod:`do_import` module handles invalid database files correctly From e424c3328308eecf6c3a7306e88fda1d1a05de23 Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Mon, 9 Jun 2014 10:59:52 +0200 Subject: [PATCH 18/49] This has been removed in trunk --- openlp/core/lib/filedialog.py | 2 +- openlp/plugins/songs/lib/__init__.py | 15 --------------- 2 files changed, 1 insertion(+), 16 deletions(-) diff --git a/openlp/core/lib/filedialog.py b/openlp/core/lib/filedialog.py index 5bf012ee5..3d1970dd5 100644 --- a/openlp/core/lib/filedialog.py +++ b/openlp/core/lib/filedialog.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 ############################################################################### # OpenLP - Open Source Lyrics Projection # diff --git a/openlp/plugins/songs/lib/__init__.py b/openlp/plugins/songs/lib/__init__.py index 7f8cd43dc..d03bdefd6 100644 --- a/openlp/plugins/songs/lib/__init__.py +++ b/openlp/plugins/songs/lib/__init__.py @@ -483,21 +483,6 @@ def strip_rtf(text, default_encoding=None): elif brace == '}' and len(stack) > 0: # Pop state ucskip, ignorable, font = stack.pop() - # \x (not a letter) - elif char: - curskip = 0 - if char == '~' and not ignorable: - out.append('\xA0') - elif char in '{}\\' and not ignorable: - out.append(char) - elif char in '\r\n' and not ignorable: - out.append(SPECIAL_CHARS['par']) - elif char == '-' and not ignorable: - out.append('\u00AD') - elif char == '_' and not ignorable: - out.append('\u2011') - elif char == '*': - ignorable = True # \command elif word: curskip = 0 From 6e9bba3a74494047b8a8725cff4bd1d72b018c1b Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Mon, 9 Jun 2014 11:08:27 +0200 Subject: [PATCH 19/49] Rename file --- openlp/plugins/songs/lib/importer.py | 2 +- openlp/plugins/songs/lib/{ppimport.py => propresenterimport.py} | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename openlp/plugins/songs/lib/{ppimport.py => propresenterimport.py} (97%) diff --git a/openlp/plugins/songs/lib/importer.py b/openlp/plugins/songs/lib/importer.py index 1cfae2602..a95b19bad 100644 --- a/openlp/plugins/songs/lib/importer.py +++ b/openlp/plugins/songs/lib/importer.py @@ -49,7 +49,7 @@ from .songproimport import SongProImport from .sundayplusimport import SundayPlusImport from .foilpresenterimport import FoilPresenterImport from .zionworximport import ZionWorxImport -from .ppimport import ProPresenterImport +from .propresenterimport import ProPresenterImport # Imports that might fail diff --git a/openlp/plugins/songs/lib/ppimport.py b/openlp/plugins/songs/lib/propresenterimport.py similarity index 97% rename from openlp/plugins/songs/lib/ppimport.py rename to openlp/plugins/songs/lib/propresenterimport.py index 11ba9d2e7..a69c3cec0 100644 --- a/openlp/plugins/songs/lib/ppimport.py +++ b/openlp/plugins/songs/lib/propresenterimport.py @@ -27,7 +27,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### """ -The :mod:`ppimport` module provides the functionality for importing +The :mod:`propresenterimport` module provides the functionality for importing ProPresenter song files into the current installation database. """ From 543f4f37dd0838cb99cf5a8738dc6f58a64fedad Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Mon, 9 Jun 2014 12:27:17 +0200 Subject: [PATCH 20/49] Add test for ProPresenter Import --- openlp/plugins/songs/lib/importer.py | 3 +- .../plugins/songs/lib/propresenterimport.py | 20 +- .../songs/test_propresenterimport.py | 54 ++ .../songs/test_zionworximport.py | 2 +- .../propresentersongs/Amazing Grace.json | 121 +++++ .../propresentersongs/Amazing Grace.pro4 | 486 ++++++++++++++++++ 6 files changed, 674 insertions(+), 12 deletions(-) create mode 100644 tests/functional/openlp_plugins/songs/test_propresenterimport.py create mode 100644 tests/resources/propresentersongs/Amazing Grace.json create mode 100644 tests/resources/propresentersongs/Amazing Grace.pro4 diff --git a/openlp/plugins/songs/lib/importer.py b/openlp/plugins/songs/lib/importer.py index a95b19bad..7ce637285 100644 --- a/openlp/plugins/songs/lib/importer.py +++ b/openlp/plugins/songs/lib/importer.py @@ -276,8 +276,7 @@ class SongFormat(object): 'class': ProPresenterImport, 'name': 'ProPresenter', 'prefix': 'proPresenter', - 'filter': '%s (*.pro4)' % translate('SongsPlugin.ImportWizardForm', - 'ProPresenter Song Files') + 'filter': '%s (*.pro4)' % translate('SongsPlugin.ImportWizardForm', 'ProPresenter Song Files') }, SongBeamer: { 'class': SongBeamerImport, diff --git a/openlp/plugins/songs/lib/propresenterimport.py b/openlp/plugins/songs/lib/propresenterimport.py index a69c3cec0..6ce3c0819 100644 --- a/openlp/plugins/songs/lib/propresenterimport.py +++ b/openlp/plugins/songs/lib/propresenterimport.py @@ -39,35 +39,37 @@ from openlp.core.ui.wizard import WizardStrings from openlp.plugins.songs.lib import strip_rtf from .songimport import SongImport + class ProPresenterImport(SongImport): """ The :class:`ProPresenterImport` class provides OpenLP with the ability to import ProPresenter song files. """ - def doImport(self): + def do_import(self): self.import_wizard.progress_bar.setMaximum(len(self.import_source)) for file_path in self.import_source: if self.stop_import_flag: return - self.import_wizard.increment_progress_bar( - WizardStrings.ImportingType % os.path.basename(file_path)) + self.import_wizard.increment_progress_bar(WizardStrings.ImportingType % os.path.basename(file_path)) root = objectify.parse(open(file_path, 'rb')).getroot() - self.processSong(root) + self.process_song(root) - def processSong(self, root): - self.setDefaults() + def process_song(self, root): + self.set_defaults() self.title = root.get('CCLISongTitle') self.copyright = root.get('CCLICopyrightInfo') self.comments = root.get('notes') - self.ccliNumber = root.get('CCLILicenseNumber') + self.ccli_number = root.get('CCLILicenseNumber') for author_key in ['author', 'artist', 'CCLIArtistCredits']: author = root.get(author_key) if len(author) > 0: self.parse_author(author) + count = 0 for slide in root.slides.RVDisplaySlide: + count += 1 RTFData = slide.displayElements.RVTextElement.get('RTFData') rtf = base64.standard_b64decode(RTFData) words, encoding = strip_rtf(rtf.decode()) - self.addVerse(words) + self.add_verse(words, "v%d" % count) if not self.finish(): - self.logError(self.import_source) + self.log_error(self.import_source) diff --git a/tests/functional/openlp_plugins/songs/test_propresenterimport.py b/tests/functional/openlp_plugins/songs/test_propresenterimport.py new file mode 100644 index 000000000..971ddbdf6 --- /dev/null +++ b/tests/functional/openlp_plugins/songs/test_propresenterimport.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2013 Raoul Snyman # +# Portions copyright (c) 2008-2013 Tim Bentley, Gerald Britton, Jonathan # +# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, # +# 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:`propresenterimport` module provides the functionality for importing +ProPresenter song files into the current installation database. +""" + +import os + +from tests.helpers.songfileimport import SongImportTestHelper + +TEST_PATH = os.path.abspath( + os.path.join(os.path.dirname(__file__), '..', '..', '..', 'resources', 'propresentersongs')) + + +class TestProPresenterFileImport(SongImportTestHelper): + + def __init__(self, *args, **kwargs): + self.importer_class_name = 'ProPresenterImport' + self.importer_module_name = 'propresenterimport' + super(TestProPresenterFileImport, self).__init__(*args, **kwargs) + + def test_song_import(self): + """ + Test that loading an ProPresenter file works correctly + """ + self.file_import(os.path.join(TEST_PATH, 'Amazing Grace.pro4'), + self.load_external_result_data(os.path.join(TEST_PATH, 'Amazing Grace.json'))) diff --git a/tests/functional/openlp_plugins/songs/test_zionworximport.py b/tests/functional/openlp_plugins/songs/test_zionworximport.py index 2edc071c7..c5669e9c8 100644 --- a/tests/functional/openlp_plugins/songs/test_zionworximport.py +++ b/tests/functional/openlp_plugins/songs/test_zionworximport.py @@ -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.songbeamerimport.SongImport'): + with patch('openlp.plugins.songs.lib.zionworximport.SongImport'): mocked_manager = MagicMock() # WHEN: An importer object is created diff --git a/tests/resources/propresentersongs/Amazing Grace.json b/tests/resources/propresentersongs/Amazing Grace.json new file mode 100644 index 000000000..1746b7696 --- /dev/null +++ b/tests/resources/propresentersongs/Amazing Grace.json @@ -0,0 +1,121 @@ +{ + "authors": [ + "John Newton" + ], + "title": "Amazing Grace", + "verse_order_list": [], + "verses": [ + [ + "Amazing grace! How sweet the sound\n", + "v1" + ], + [ + "That saved a wretch like me!\n", + "v2" + ], + [ + "I once was lost, but now am found;\n", + "v3" + ], + [ + "Was blind, but now I see.\n", + "v4" + ], + [ + "'Twas grace that taught my heart to fear,\n", + "v5" + ], + [ + "And grace my fears relieved;\n", + "v6" + ], + [ + "How precious did that grace appear\n", + "v7" + ], + [ + "The hour I first believed.\n", + "v8" + ], + [ + "Through many dangers, toils and snares,\n", + "v9" + ], + [ + "I have already come;\n", + "v10" + ], + [ + "'Tis grace hath brought me safe thus far,\n", + "v11" + ], + [ + "And grace will lead me home.\n", + "v12" + ], + [ + "The Lord has promised good to me,\n", + "v13" + ], + [ + "His Word my hope secures;\n", + "v14" + ], + [ + "He will my Shield and Portion be,\n", + "v15" + ], + [ + "As long as life endures.\n", + "v16" + ], + [ + "Yea, when this flesh and heart shall fail,\n", + "v17" + ], + [ + "And mortal life shall cease,\n", + "v18" + ], + [ + "I shall possess, within the veil,\n", + "v19" + ], + [ + "A life of joy and peace.\n", + "v20" + ], + [ + "The earth shall soon dissolve like snow,\n", + "v21" + ], + [ + "The sun forbear to shine;\n", + "v22" + ], + [ + "But God, Who called me here below,\n", + "v23" + ], + [ + "Shall be forever mine.\n", + "v24" + ], + [ + "When we've been there ten thousand years,\n", + "v25" + ], + [ + "Bright shining as the sun,\n", + "v26" + ], + [ + "We've no less days to sing God's praise\n", + "v27" + ], + [ + "Than when we'd first begun.\n", + "v28" + ] + ] +} \ No newline at end of file diff --git a/tests/resources/propresentersongs/Amazing Grace.pro4 b/tests/resources/propresentersongs/Amazing Grace.pro4 new file mode 100644 index 000000000..dbe114a88 --- /dev/null +++ b/tests/resources/propresentersongs/Amazing Grace.pro4 @@ -0,0 +1,486 @@ + + + + + + + + <_-RVRect3D-_position x="10" y="10" z="0" width="1004" height="748" /> + <_-D-_serializedShadow containerClass="NSMutableDictionary"> + + + + + + + + + + + + + + + + <_-RVRect3D-_position x="10" y="10" z="0" width="1004" height="748" /> + <_-D-_serializedShadow containerClass="NSMutableDictionary"> + + + + + + + + + + + + + + + + <_-RVRect3D-_position x="10" y="10" z="0" width="1004" height="748" /> + <_-D-_serializedShadow containerClass="NSMutableDictionary"> + + + + + + + + + + + + + + + + <_-RVRect3D-_position x="10" y="10" z="0" width="1004" height="748" /> + <_-D-_serializedShadow containerClass="NSMutableDictionary"> + + + + + + + + + + + + + + + + <_-RVRect3D-_position x="10" y="10" z="0" width="1004" height="748" /> + <_-D-_serializedShadow containerClass="NSMutableDictionary"> + + + + + + + + + + + + + + + + <_-RVRect3D-_position x="10" y="10" z="0" width="1004" height="748" /> + <_-D-_serializedShadow containerClass="NSMutableDictionary"> + + + + + + + + + + + + + + + + <_-RVRect3D-_position x="10" y="10" z="0" width="1004" height="748" /> + <_-D-_serializedShadow containerClass="NSMutableDictionary"> + + + + + + + + + + + + + + + + <_-RVRect3D-_position x="10" y="10" z="0" width="1004" height="748" /> + <_-D-_serializedShadow containerClass="NSMutableDictionary"> + + + + + + + + + + + + + + + + <_-RVRect3D-_position x="10" y="10" z="0" width="1004" height="748" /> + <_-D-_serializedShadow containerClass="NSMutableDictionary"> + + + + + + + + + + + + + + + + <_-RVRect3D-_position x="10" y="10" z="0" width="1004" height="748" /> + <_-D-_serializedShadow containerClass="NSMutableDictionary"> + + + + + + + + + + + + + + + + <_-RVRect3D-_position x="10" y="10" z="0" width="1004" height="748" /> + <_-D-_serializedShadow containerClass="NSMutableDictionary"> + + + + + + + + + + + + + + + + <_-RVRect3D-_position x="10" y="10" z="0" width="1004" height="748" /> + <_-D-_serializedShadow containerClass="NSMutableDictionary"> + + + + + + + + + + + + + + + + <_-RVRect3D-_position x="10" y="10" z="0" width="1004" height="748" /> + <_-D-_serializedShadow containerClass="NSMutableDictionary"> + + + + + + + + + + + + + + + + <_-RVRect3D-_position x="10" y="10" z="0" width="1004" height="748" /> + <_-D-_serializedShadow containerClass="NSMutableDictionary"> + + + + + + + + + + + + + + + + <_-RVRect3D-_position x="10" y="10" z="0" width="1004" height="748" /> + <_-D-_serializedShadow containerClass="NSMutableDictionary"> + + + + + + + + + + + + + + + + <_-RVRect3D-_position x="10" y="10" z="0" width="1004" height="748" /> + <_-D-_serializedShadow containerClass="NSMutableDictionary"> + + + + + + + + + + + + + + + + <_-RVRect3D-_position x="10" y="10" z="0" width="1004" height="748" /> + <_-D-_serializedShadow containerClass="NSMutableDictionary"> + + + + + + + + + + + + + + + + <_-RVRect3D-_position x="10" y="10" z="0" width="1004" height="748" /> + <_-D-_serializedShadow containerClass="NSMutableDictionary"> + + + + + + + + + + + + + + + + <_-RVRect3D-_position x="10" y="10" z="0" width="1004" height="748" /> + <_-D-_serializedShadow containerClass="NSMutableDictionary"> + + + + + + + + + + + + + + + + <_-RVRect3D-_position x="10" y="10" z="0" width="1004" height="748" /> + <_-D-_serializedShadow containerClass="NSMutableDictionary"> + + + + + + + + + + + + + + + + <_-RVRect3D-_position x="10" y="10" z="0" width="1004" height="748" /> + <_-D-_serializedShadow containerClass="NSMutableDictionary"> + + + + + + + + + + + + + + + + <_-RVRect3D-_position x="10" y="10" z="0" width="1004" height="748" /> + <_-D-_serializedShadow containerClass="NSMutableDictionary"> + + + + + + + + + + + + + + + + <_-RVRect3D-_position x="10" y="10" z="0" width="1004" height="748" /> + <_-D-_serializedShadow containerClass="NSMutableDictionary"> + + + + + + + + + + + + + + + + <_-RVRect3D-_position x="10" y="10" z="0" width="1004" height="748" /> + <_-D-_serializedShadow containerClass="NSMutableDictionary"> + + + + + + + + + + + + + + + + <_-RVRect3D-_position x="10" y="10" z="0" width="1004" height="748" /> + <_-D-_serializedShadow containerClass="NSMutableDictionary"> + + + + + + + + + + + + + + + + <_-RVRect3D-_position x="10" y="10" z="0" width="1004" height="748" /> + <_-D-_serializedShadow containerClass="NSMutableDictionary"> + + + + + + + + + + + + + + + + <_-RVRect3D-_position x="10" y="10" z="0" width="1004" height="748" /> + <_-D-_serializedShadow containerClass="NSMutableDictionary"> + + + + + + + + + + + + + + + + <_-RVRect3D-_position x="10" y="10" z="0" width="1004" height="748" /> + <_-D-_serializedShadow containerClass="NSMutableDictionary"> + + + + + + + + + + + + + + + + + + \ No newline at end of file From 8982839794623612ba97fd9bb62f35cc81f0d176 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Tue, 10 Jun 2014 10:33:02 +0200 Subject: [PATCH 22/49] fixed translation_util script for 2.2 --- scripts/translation_utils.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/scripts/translation_utils.py b/scripts/translation_utils.py index 2e9dffb12..d98fe61c9 100755 --- a/scripts/translation_utils.py +++ b/scripts/translation_utils.py @@ -63,7 +63,7 @@ import webbrowser from optparse import OptionParser from PyQt4 import QtCore -SERVER_URL = 'http://www.transifex.net/api/2/project/openlp/' +SERVER_URL = 'http://www.transifex.net/api/2/project/openlp/resource/openlp-22x/' IGNORED_PATHS = ['scripts'] IGNORED_FILES = ['setup.py'] @@ -193,12 +193,11 @@ def download_translations(): if not password: password = getpass(' Transifex password: ') # First get the list of languages - url = SERVER_URL + 'resource/ents/' base64string = base64.encodebytes('%s:%s' % (username, password))[:-1] auth_header = 'Basic %s' % base64string - request = urllib.request.Request(url + '?details') + request = urllib.request.Request(SERVER_URL + '?details') request.add_header('Authorization', auth_header) - print_verbose('Downloading list of languages from: %s' % url) + print_verbose('Downloading list of languages from: %s' % SERVER_URL) try: json_response = urllib.request.urlopen(request) except urllib.error.HTTPError: @@ -207,7 +206,7 @@ def download_translations(): json_dict = json.loads(json_response.read()) languages = [lang['code'] for lang in json_dict['available_languages']] for language in languages: - lang_url = url + 'translation/%s/?file' % language + lang_url = SERVER_URL + 'translation/%s/?file' % language request = urllib.request.Request(lang_url) request.add_header('Authorization', auth_header) filename = os.path.join(os.path.abspath('..'), 'resources', 'i18n', language + '.ts') From 108fabbae0fb791fbcabae02e84796fdc325e91a Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Tue, 10 Jun 2014 11:05:26 +0200 Subject: [PATCH 23/49] fixed str/byte errors --- scripts/translation_utils.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/translation_utils.py b/scripts/translation_utils.py index d98fe61c9..0074109dd 100755 --- a/scripts/translation_utils.py +++ b/scripts/translation_utils.py @@ -193,8 +193,8 @@ def download_translations(): if not password: password = getpass(' Transifex password: ') # First get the list of languages - base64string = base64.encodebytes('%s:%s' % (username, password))[:-1] - auth_header = 'Basic %s' % base64string + base64string = base64.encodebytes(('%s:%s' % (username, password)).encode())[:-1] + auth_header = 'Basic %s' % base64string.decode() request = urllib.request.Request(SERVER_URL + '?details') request.add_header('Authorization', auth_header) print_verbose('Downloading list of languages from: %s' % SERVER_URL) @@ -203,7 +203,7 @@ def download_translations(): except urllib.error.HTTPError: print_quiet('Username or password incorrect.') return False - json_dict = json.loads(json_response.read()) + json_dict = json.loads(json_response.read().decode()) languages = [lang['code'] for lang in json_dict['available_languages']] for language in languages: lang_url = SERVER_URL + 'translation/%s/?file' % language @@ -212,7 +212,7 @@ def download_translations(): filename = os.path.join(os.path.abspath('..'), 'resources', 'i18n', language + '.ts') print_verbose('Get Translation File: %s' % filename) response = urllib.request.urlopen(request) - fd = open(filename, 'w') + fd = open(filename, 'wb') fd.write(response.read()) fd.close() print_quiet(' Done.') From 6d0ee83de18881135775259c5e8b1e13f04f72aa Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Tue, 10 Jun 2014 11:24:50 +0200 Subject: [PATCH 24/49] moved tests --- .../openlp_core_common/test_common.py | 61 ++++++++++++++++++- tests/functional/openlp_core_lib/test_lib.py | 59 ------------------ 2 files changed, 60 insertions(+), 60 deletions(-) diff --git a/tests/functional/openlp_core_common/test_common.py b/tests/functional/openlp_core_common/test_common.py index ab2d11b3a..3cb212a9c 100644 --- a/tests/functional/openlp_core_common/test_common.py +++ b/tests/functional/openlp_core_common/test_common.py @@ -32,14 +32,54 @@ Functional tests to test the AppLocation class and related methods. from unittest import TestCase -from openlp.core.common import de_hump, trace_error_handler +from openlp.core.common import check_directory_exists, de_hump, trace_error_handler, translate from tests.functional import MagicMock, patch + class TestCommonFunctions(TestCase): """ A test suite to test out various functions in the openlp.core.common module. """ + def check_directory_exists_test(self): + """ + Test the check_directory_exists() function + """ + with patch('openlp.core.lib.os.path.exists') as mocked_exists, \ + patch('openlp.core.lib.os.makedirs') as mocked_makedirs: + # GIVEN: A directory to check and a mocked out os.makedirs and os.path.exists + directory_to_check = 'existing/directory' + + # WHEN: os.path.exists returns True and we check to see if the directory exists + mocked_exists.return_value = True + check_directory_exists(directory_to_check) + + # THEN: Only os.path.exists should have been called + mocked_exists.assert_called_with(directory_to_check) + self.assertIsNot(mocked_makedirs.called, 'os.makedirs should not have been called') + + # WHEN: os.path.exists returns False and we check the directory exists + mocked_exists.return_value = False + check_directory_exists(directory_to_check) + + # THEN: Both the mocked functions should have been called + mocked_exists.assert_called_with(directory_to_check) + mocked_makedirs.assert_called_with(directory_to_check) + + # WHEN: os.path.exists raises an IOError + mocked_exists.side_effect = IOError() + check_directory_exists(directory_to_check) + + # THEN: We shouldn't get an exception though the mocked exists has been called + mocked_exists.assert_called_with(directory_to_check) + + # WHEN: Some other exception is raised + mocked_exists.side_effect = ValueError() + + # THEN: check_directory_exists raises an exception + mocked_exists.assert_called_with(directory_to_check) + self.assertRaises(ValueError, check_directory_exists, directory_to_check) + def de_hump_conversion_test(self): """ Test the de_hump function with a class name @@ -81,3 +121,22 @@ class TestCommonFunctions(TestCase): # THEN: The mocked_logger.error() method should have been called with the correct parameters mocked_logger.error.assert_called_with( 'OpenLP Error trace\n File openlp.fake at line 56 \n\t called trace_error_handler_test') + + def translate_test(self): + """ + Test the translate() function + """ + # GIVEN: A string to translate and a mocked Qt translate function + context = 'OpenLP.Tests' + text = 'Untranslated string' + comment = 'A comment' + encoding = 1 + n = 1 + mocked_translate = MagicMock(return_value='Translated string') + + # WHEN: we call the translate function + result = translate(context, text, comment, encoding, n, mocked_translate) + + # THEN: the translated string should be returned, and the mocked function should have been called + mocked_translate.assert_called_with(context, text, comment, encoding, n) + self.assertEqual('Translated string', result, 'The translated string should have been returned') \ No newline at end of file diff --git a/tests/functional/openlp_core_lib/test_lib.py b/tests/functional/openlp_core_lib/test_lib.py index 2e06e47fe..70d111520 100644 --- a/tests/functional/openlp_core_lib/test_lib.py +++ b/tests/functional/openlp_core_lib/test_lib.py @@ -36,7 +36,6 @@ from datetime import datetime, timedelta from PyQt4 import QtCore, QtGui -from openlp.core.common import check_directory_exists, translate from openlp.core.lib import str_to_bool, create_thumb, get_text_file_string, \ build_icon, image_to_byte, check_item_selected, validate_thumb, create_separated_list, clean_tags, expand_tags from tests.functional import MagicMock, patch @@ -152,64 +151,6 @@ class TestLib(TestCase): # THEN: we should get back a true self.assertTrue(str_result, 'The result should be True') - def translate_test(self): - """ - Test the translate() function - """ - # GIVEN: A string to translate and a mocked Qt translate function - context = 'OpenLP.Tests' - text = 'Untranslated string' - comment = 'A comment' - encoding = 1 - n = 1 - mocked_translate = MagicMock(return_value='Translated string') - - # WHEN: we call the translate function - result = translate(context, text, comment, encoding, n, mocked_translate) - - # THEN: the translated string should be returned, and the mocked function should have been called - mocked_translate.assert_called_with(context, text, comment, encoding, n) - self.assertEqual('Translated string', result, 'The translated string should have been returned') - - def check_directory_exists_test(self): - """ - Test the check_directory_exists() function - """ - with patch('openlp.core.lib.os.path.exists') as mocked_exists, \ - patch('openlp.core.lib.os.makedirs') as mocked_makedirs: - # GIVEN: A directory to check and a mocked out os.makedirs and os.path.exists - directory_to_check = 'existing/directory' - - # WHEN: os.path.exists returns True and we check to see if the directory exists - mocked_exists.return_value = True - check_directory_exists(directory_to_check) - - # THEN: Only os.path.exists should have been called - mocked_exists.assert_called_with(directory_to_check) - self.assertIsNot(mocked_makedirs.called, 'os.makedirs should not have been called') - - # WHEN: os.path.exists returns False and we check the directory exists - mocked_exists.return_value = False - check_directory_exists(directory_to_check) - - # THEN: Both the mocked functions should have been called - mocked_exists.assert_called_with(directory_to_check) - mocked_makedirs.assert_called_with(directory_to_check) - - # WHEN: os.path.exists raises an IOError - mocked_exists.side_effect = IOError() - check_directory_exists(directory_to_check) - - # THEN: We shouldn't get an exception though the mocked exists has been called - mocked_exists.assert_called_with(directory_to_check) - - # WHEN: Some other exception is raised - mocked_exists.side_effect = ValueError() - - # THEN: check_directory_exists raises an exception - mocked_exists.assert_called_with(directory_to_check) - self.assertRaises(ValueError, check_directory_exists, directory_to_check) - def get_text_file_string_no_file_test(self): """ Test the get_text_file_string() function when a file does not exist From 837d95ae419e4e2dc9e0b5b55cd458865b81a285 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Tue, 10 Jun 2014 11:39:24 +0200 Subject: [PATCH 25/49] added a test case --- tests/functional/openlp_core_lib/test_lib.py | 24 +++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/tests/functional/openlp_core_lib/test_lib.py b/tests/functional/openlp_core_lib/test_lib.py index 70d111520..528341a98 100644 --- a/tests/functional/openlp_core_lib/test_lib.py +++ b/tests/functional/openlp_core_lib/test_lib.py @@ -37,7 +37,8 @@ from datetime import datetime, timedelta from PyQt4 import QtCore, QtGui from openlp.core.lib import str_to_bool, create_thumb, get_text_file_string, \ - build_icon, image_to_byte, check_item_selected, validate_thumb, create_separated_list, clean_tags, expand_tags + build_icon, image_to_byte, check_item_selected, validate_thumb, create_separated_list, clean_tags, expand_tags, \ + resize_image from tests.functional import MagicMock, patch TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', 'resources')) @@ -449,6 +450,27 @@ class TestLib(TestCase): mocked_os.stat.assert_any_call(thumb_path) assert result is False, 'The result should be False' + def resize_thumb_test(self): + """ + Test the resize_thumb() function + """ + # GIVEN: A path to an image. + image_path = os.path.join(TEST_PATH, 'church.jpg') + wanted_width = 777 + wanted_height = 72 + # We want the background to be white. + wanted_background_hex = '#FFFFFF' + wanted_background_rgb = QtGui.QColor(wanted_background_hex).rgb() + + # WHEN: Resize the image and add a background. + image = resize_image(image_path, wanted_width, wanted_height, wanted_background_hex) + + # THEN: Check if the size is correct and the background was set. + result_size = image.size() + self.assertEqual(wanted_height, result_size.height(), 'The image should have the requested height.') + self.assertEqual(wanted_width, result_size.width(), 'The image should have the requested width.') + self.assertEqual(image.pixel(0, 0), wanted_background_rgb, 'The background should be white.') + def create_separated_list_qlocate_test(self): """ Test the create_separated_list function using the Qt provided method From 3235c334eb21e7789a219bf1f6fbe50be851a5b6 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Tue, 10 Jun 2014 11:42:11 +0200 Subject: [PATCH 26/49] sorted imports --- tests/functional/openlp_core_lib/test_lib.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/functional/openlp_core_lib/test_lib.py b/tests/functional/openlp_core_lib/test_lib.py index 528341a98..083698212 100644 --- a/tests/functional/openlp_core_lib/test_lib.py +++ b/tests/functional/openlp_core_lib/test_lib.py @@ -36,9 +36,8 @@ from datetime import datetime, timedelta from PyQt4 import QtCore, QtGui -from openlp.core.lib import str_to_bool, create_thumb, get_text_file_string, \ - build_icon, image_to_byte, check_item_selected, validate_thumb, create_separated_list, clean_tags, expand_tags, \ - resize_image +from openlp.core.lib import build_icon, check_item_selected, clean_tags, create_thumb, create_separated_list, \ + expand_tags, get_text_file_string, image_to_byte, resize_image, str_to_bool, validate_thumb from tests.functional import MagicMock, patch TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', 'resources')) From 2791b37525ff366a74baa46845adb0598f19b12f Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Tue, 10 Jun 2014 11:48:42 +0200 Subject: [PATCH 27/49] pep fixes --- tests/functional/openlp_core_common/test_common.py | 3 +-- tests/functional/openlp_core_lib/test_lib.py | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/functional/openlp_core_common/test_common.py b/tests/functional/openlp_core_common/test_common.py index 3cb212a9c..f52256c5c 100644 --- a/tests/functional/openlp_core_common/test_common.py +++ b/tests/functional/openlp_core_common/test_common.py @@ -36,7 +36,6 @@ from openlp.core.common import check_directory_exists, de_hump, trace_error_hand from tests.functional import MagicMock, patch - class TestCommonFunctions(TestCase): """ A test suite to test out various functions in the openlp.core.common module. @@ -139,4 +138,4 @@ class TestCommonFunctions(TestCase): # THEN: the translated string should be returned, and the mocked function should have been called mocked_translate.assert_called_with(context, text, comment, encoding, n) - self.assertEqual('Translated string', result, 'The translated string should have been returned') \ No newline at end of file + self.assertEqual('Translated string', result, 'The translated string should have been returned') diff --git a/tests/functional/openlp_core_lib/test_lib.py b/tests/functional/openlp_core_lib/test_lib.py index 083698212..fca6f371d 100644 --- a/tests/functional/openlp_core_lib/test_lib.py +++ b/tests/functional/openlp_core_lib/test_lib.py @@ -294,7 +294,7 @@ class TestLib(TestCase): Test that the check_item_selected() function returns True when there are selected indexes """ # GIVEN: A mocked out QtGui module and a list widget with selected indexes - MockedQtGui = patch('openlp.core.lib.QtGui') + mocked_QtGui = patch('openlp.core.lib.QtGui') mocked_list_widget = MagicMock() mocked_list_widget.selectedIndexes.return_value = True message = 'message' From 50a226d51bad1f1d2ebff082ce743cbae5f747ef Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Wed, 11 Jun 2014 07:18:32 +0200 Subject: [PATCH 28/49] Better wording --- openlp/plugins/songs/lib/ewimport.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/songs/lib/ewimport.py b/openlp/plugins/songs/lib/ewimport.py index ccd89e228..c56e1dba1 100644 --- a/openlp/plugins/songs/lib/ewimport.py +++ b/openlp/plugins/songs/lib/ewimport.py @@ -213,7 +213,7 @@ class EasyWorshipSongImport(SongImport): db_size = os.path.getsize(self.import_source) if db_size < 0x800: self.log_error(self.import_source, translate('SongsPlugin.EasyWorshipSongImport', - 'This file is no valid EasyWorship Database.')) + 'This file is not a valid EasyWorship database.')) return db_file = open(self.import_source, 'rb') self.memo_file = open(import_source_mb, 'rb') @@ -223,7 +223,7 @@ class EasyWorshipSongImport(SongImport): db_file.close() self.memo_file.close() self.log_error(self.import_source, translate('SongsPlugin.EasyWorshipSongImport', - 'This file is no valid EasyWorship Database.')) + 'This file is not a valid EasyWorship database.')) return # Take a stab at how text is encoded self.encoding = 'cp1252' From 49342f4a6960fb55cca009704166cffb9cee82cd Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Sun, 22 Jun 2014 22:12:59 +0200 Subject: [PATCH 29/49] 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 248e703345e86ebfbcf5de882b9fea63b1215908 Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Tue, 24 Jun 2014 19:46:23 +0200 Subject: [PATCH 30/49] Fixed loading of libvlc.dll on windows --- openlp/core/ui/media/vendor/vlc.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/openlp/core/ui/media/vendor/vlc.py b/openlp/core/ui/media/vendor/vlc.py index 0326e4104..01aced404 100644 --- a/openlp/core/ui/media/vendor/vlc.py +++ b/openlp/core/ui/media/vendor/vlc.py @@ -110,7 +110,10 @@ def find_lib(): p = find_library('libvlc.dll') if p is None: try: # some registry settings - import _winreg as w # leaner than win32api, win32con + if PYTHON3: + import winreg as w # leaner than win32api, win32con + else: + import _winreg as w # leaner than win32api, win32con for r in w.HKEY_LOCAL_MACHINE, w.HKEY_CURRENT_USER: try: r = w.OpenKey(r, 'Software\\VideoLAN\\VLC') From f92afc296b862efe040f656c525cc9709680e9b8 Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Wed, 25 Jun 2014 14:23:31 +0200 Subject: [PATCH 31/49] First go at an importer for Worship Assistant --- openlp/plugins/songs/lib/importer.py | 31 ++-- .../songs/lib/worshipassistantimport.py | 144 ++++++++++++++++++ 2 files changed, 166 insertions(+), 9 deletions(-) create mode 100644 openlp/plugins/songs/lib/worshipassistantimport.py diff --git a/openlp/plugins/songs/lib/importer.py b/openlp/plugins/songs/lib/importer.py index 7ce637285..6d01da309 100644 --- a/openlp/plugins/songs/lib/importer.py +++ b/openlp/plugins/songs/lib/importer.py @@ -50,6 +50,7 @@ from .sundayplusimport import SundayPlusImport from .foilpresenterimport import FoilPresenterImport from .zionworximport import ZionWorxImport from .propresenterimport import ProPresenterImport +from .worshipassistantimport import WorshipAssistantImport # Imports that might fail @@ -167,8 +168,9 @@ class SongFormat(object): SongsOfFellowship = 16 SundayPlus = 17 WordsOfWorship = 18 - WorshipCenterPro = 19 - ZionWorx = 20 + WorshipAssistant = 19 + WorshipCenterPro = 20 + ZionWorx = 21 # Set optional attribute defaults __defaults__ = { @@ -321,6 +323,16 @@ class SongFormat(object): 'prefix': 'wordsOfWorship', 'filter': '%s (*.wsg *.wow-song)' % translate('SongsPlugin.ImportWizardForm', 'Words Of Worship Song Files') }, + WorshipAssistant: { + 'class': WorshipAssistantImport, + 'name': 'Worship Assistant 0', + 'prefix': 'worshipAssistant', + 'selectMode': SongFormatSelect.SingleFile, + 'filter': '%s (*.csv)' % translate('SongsPlugin.ImportWizardForm', 'Worship Assistant Files'), + 'comboBoxText': translate('SongsPlugin.ImportWizardForm', 'Worship Assistant (CSV)'), + 'descriptionText': translate('SongsPlugin.ImportWizardForm', + 'In Worship Assistant, export your Database to a CSV file.') + }, WorshipCenterPro: { 'name': 'WorshipCenter Pro', 'prefix': 'worshipCenterPro', @@ -370,16 +382,17 @@ class SongFormat(object): SongFormat.SongsOfFellowship, SongFormat.SundayPlus, SongFormat.WordsOfWorship, + SongFormat.WorshipAssistant, SongFormat.WorshipCenterPro, SongFormat.ZionWorx ] @staticmethod - def get(format, *attributes): + def get(song_format, *attributes): """ Return requested song format attribute(s). - :param format: A song format from SongFormat. + :param song_format: A song format from SongFormat. :param attributes: Zero or more song format attributes from SongFormat. Return type depends on number of supplied attributes: @@ -389,23 +402,23 @@ class SongFormat(object): :>1: Return tuple of requested attribute values. """ if not attributes: - return SongFormat.__attributes__.get(format) + return SongFormat.__attributes__.get(song_format) elif len(attributes) == 1: default = SongFormat.__defaults__.get(attributes[0]) - return SongFormat.__attributes__[format].get(attributes[0], default) + return SongFormat.__attributes__[song_format].get(attributes[0], default) else: values = [] for attr in attributes: default = SongFormat.__defaults__.get(attr) - values.append(SongFormat.__attributes__[format].get(attr, default)) + values.append(SongFormat.__attributes__[song_format].get(attr, default)) return tuple(values) @staticmethod - def set(format, attribute, value): + def set(song_format, attribute, value): """ Set specified song format attribute to the supplied value. """ - SongFormat.__attributes__[format][attribute] = value + SongFormat.__attributes__[song_format][attribute] = value SongFormat.set(SongFormat.SongsOfFellowship, 'availability', HAS_SOF) diff --git a/openlp/plugins/songs/lib/worshipassistantimport.py b/openlp/plugins/songs/lib/worshipassistantimport.py new file mode 100644 index 000000000..683ec6456 --- /dev/null +++ b/openlp/plugins/songs/lib/worshipassistantimport.py @@ -0,0 +1,144 @@ +# -*- 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:`worshipassistantimport` module provides the functionality for importing +Worship Assistant songs into the OpenLP database. +""" +import csv +import logging + +from openlp.core.common import translate +from openlp.plugins.songs.lib.songimport import SongImport + +log = logging.getLogger(__name__) + +# Used to strip control chars (except 10=LF, 13=CR) +CONTROL_CHARS_MAP = dict.fromkeys(list(range(10)) + [11, 12] + list(range(14, 32)) + [127]) + + +class WorshipAssistantImport(SongImport): + """ + The :class:`WorshipAssistantImport` class provides the ability to import songs + from Worship Assistant, via a dump of the database to a CSV file. + + The following fields are in the exported CSV file: + + * ``SONGNR`` Song ID (Discarded by importer) + * ``TITLE`` Song title + * ``AUTHOR`` Song author. May containt multiple authors. + * ``COPYRIGHT`` Copyright information + * ``FIRSTLINE`` Unknown (Discarded by importer) + * ``PRIKEY`` Primary chord key + * ``ALTKEY`` Alternate chord key + * ``TEMPO`` Tempo + * ``FOCUS`` Unknown (Discarded by importer) + * ``THEME`` Theme (Discarded by importer) + * ``SCRIPTURE`` Associated scripture (Discarded by importer) + * ``ACTIVE`` Boolean value (Discarded by importer) + * ``SONGBOOK`` Boolean value (Discarded by importer) + * ``TIMESIG`` Unknown (Discarded by importer) + * ``INTRODUCED`` Date the song was created (Discarded by importer) + * ``LASTUSED`` Date the song was last used (Discarded by importer) + * ``TIMESUSED`` How many times the song was used (Discarded by importer) + * ``TIMESUSED`` How many times the song was used (Discarded by importer) + * ``CCLINR`` CCLI Number + * ``USER1`` User Field 1 (Discarded by importer) + * ``USER2`` User Field 2 (Discarded by importer) + * ``USER3`` User Field 3 (Discarded by importer) + * ``USER4`` User Field 4 (Discarded by importer) + * ``USER5`` User Field 5 (Discarded by importer) + * ``ROADMAP`` Verse order + * ``FILELINK1`` Associated file 1 (Discarded by importer) + * ``OVERMAP`` Unknown (Discarded by importer) + * ``FILELINK2`` Associated file 2 (Discarded by importer) + * ``LYRICS`` The song lyrics as plain text (Discarded by importer) + * ``INFO`` Unknown (Discarded by importer) + * ``LYRICS2`` The song lyrics with verse numbers + * ``BACKGROUND`` Unknown (Discarded by importer) + """ + def do_import(self): + """ + Receive a CSV file to import. + """ + with open(self.import_source, 'r', encoding='latin-1') as songs_file: + field_names = ['SongNum', 'Title1', 'Title2', 'Lyrics', 'Writer', 'Copyright', 'Keywords', + 'DefaultStyle'] + songs_reader = csv.DictReader(songs_file)#, field_names) + try: + records = list(songs_reader) + except csv.Error as e: + self.log_error(translate('SongsPlugin.WorshipAssistantImport', 'Error reading CSV file.'), + translate('SongsPlugin.WorshipAssistantImport', 'Line %d: %s') % + (songs_reader.line_num, e)) + return + num_records = len(records) + log.info('%s records found in CSV file' % num_records) + self.import_wizard.progress_bar.setMaximum(num_records) + for index, record in enumerate(records, 1): + if self.stop_import_flag: + return + # The CSV file has a line in the middle of the file where the headers are repeated. + # We need to skip this line. + if record['TITLE'] == "TITLE" and record['COPYRIGHT'] == 'COPYRIGHT' and record['AUTHOR'] == 'AUTHOR': + continue + self.set_defaults() + try: + self.title = self._decode(record['TITLE']) + self.parse_author(self._decode(record['AUTHOR'])) + self.add_copyright(self._decode(record['COPYRIGHT'])) + lyrics = self._decode(record['LYRICS2']) + except UnicodeDecodeError as e: + self.log_error(translate('SongsPlugin.WorshipAssistantImport', 'Record %d' % index), + translate('SongsPlugin.WorshipAssistantImport', 'Decoding error: %s') % e) + continue + except TypeError as e: + self.log_error(translate('SongsPlugin.WorshipAssistantImport', + 'File not valid WorshipAssistant CSV format.'), 'TypeError: %s' % e) + return + verse = '' + for line in lyrics.splitlines(): + if line and not line.isspace(): + verse += line + '\n' + elif verse: + self.add_verse(verse) + verse = '' + if verse: + self.add_verse(verse) + if not self.finish(): + self.log_error(translate('SongsPlugin.ZionWorxImport', 'Record %d') % index + + (': "' + self.title + '"' if self.title else '')) + + def _decode(self, str): + """ + Decodes CSV input to unicode, stripping all control characters (except new lines). + """ + # This encoding choice seems OK. ZionWorx has no option for setting the + # encoding for its songs, so we assume encoding is always the same. + return str + #return str(str, 'cp1252').translate(CONTROL_CHARS_MAP) From 4ebfa33aac66b26eb106e2b2daf58edf6a40cec1 Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Wed, 25 Jun 2014 15:49:03 +0200 Subject: [PATCH 32/49] Parse verse names --- .../songs/lib/worshipassistantimport.py | 30 ++++++++++++++----- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/openlp/plugins/songs/lib/worshipassistantimport.py b/openlp/plugins/songs/lib/worshipassistantimport.py index 683ec6456..ee9cd52cd 100644 --- a/openlp/plugins/songs/lib/worshipassistantimport.py +++ b/openlp/plugins/songs/lib/worshipassistantimport.py @@ -32,8 +32,10 @@ Worship Assistant songs into the OpenLP database. """ import csv import logging +import re from openlp.core.common import translate +from openlp.plugins.songs.lib import VerseType from openlp.plugins.songs.lib.songimport import SongImport log = logging.getLogger(__name__) @@ -87,9 +89,7 @@ class WorshipAssistantImport(SongImport): Receive a CSV file to import. """ with open(self.import_source, 'r', encoding='latin-1') as songs_file: - field_names = ['SongNum', 'Title1', 'Title2', 'Lyrics', 'Writer', 'Copyright', 'Keywords', - 'DefaultStyle'] - songs_reader = csv.DictReader(songs_file)#, field_names) + songs_reader = csv.DictReader(songs_file) try: records = list(songs_reader) except csv.Error as e: @@ -105,7 +105,7 @@ class WorshipAssistantImport(SongImport): return # The CSV file has a line in the middle of the file where the headers are repeated. # We need to skip this line. - if record['TITLE'] == "TITLE" and record['COPYRIGHT'] == 'COPYRIGHT' and record['AUTHOR'] == 'AUTHOR': + if record['TITLE'] == "TITLE" and record['AUTHOR'] == 'AUTHOR' and record['LYRICS2'] == 'LYRICS2': continue self.set_defaults() try: @@ -123,13 +123,29 @@ class WorshipAssistantImport(SongImport): return verse = '' for line in lyrics.splitlines(): - if line and not line.isspace(): + if line.startswith('['): # verse marker + # drop the square brackets + right_bracket = line.find(']') + content = line[1:right_bracket].lower() + # have we got any digits? If so, verse number is everything from the digits to the end (openlp does not + # have concept of part verses, so just ignore any non integers on the end (including floats)) + match = re.match('(\D*)(\d+)', content) + if match is not None: + verse_tag = match.group(1) + verse_num = match.group(2) + else: + # otherwise we assume number 1 and take the whole prefix as the verse tag + verse_tag = content + verse_num = '1' + verse_index = VerseType.from_loose_input(verse_tag) if verse_tag else 0 + verse_tag = VerseType.tags[verse_index] + elif line and not line.isspace(): verse += line + '\n' elif verse: - self.add_verse(verse) + self.add_verse(verse, verse_tag+verse_num) verse = '' if verse: - self.add_verse(verse) + self.add_verse(verse, verse_tag+verse_num) if not self.finish(): self.log_error(translate('SongsPlugin.ZionWorxImport', 'Record %d') % index + (': "' + self.title + '"' if self.title else '')) From c3e9d0c5b31a38dd23096c9192eb3b44d42ca1f2 Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Wed, 25 Jun 2014 17:03:00 +0200 Subject: [PATCH 33/49] Add test --- openlp/plugins/songs/lib/cclifileimport.py | 2 +- .../songs/lib/worshipassistantimport.py | 162 +++++++++--------- .../songs/test_opensongimport.py | 6 +- .../songs/test_propresenterimport.py | 2 +- .../songs/test_songshowplusimport.py | 6 +- tests/helpers/songfileimport.py | 2 +- 6 files changed, 92 insertions(+), 88 deletions(-) diff --git a/openlp/plugins/songs/lib/cclifileimport.py b/openlp/plugins/songs/lib/cclifileimport.py index eda235ca1..69c20d1cc 100644 --- a/openlp/plugins/songs/lib/cclifileimport.py +++ b/openlp/plugins/songs/lib/cclifileimport.py @@ -64,7 +64,7 @@ class CCLIFileImport(SongImport): filename = str(filename) log.debug('Importing CCLI File: %s', filename) if os.path.isfile(filename): - detect_file = open(filename, 'r') + detect_file = open(filename, 'rb') detect_content = detect_file.read(2048) try: str(detect_content, 'utf-8') diff --git a/openlp/plugins/songs/lib/worshipassistantimport.py b/openlp/plugins/songs/lib/worshipassistantimport.py index ee9cd52cd..d371044b1 100644 --- a/openlp/plugins/songs/lib/worshipassistantimport.py +++ b/openlp/plugins/songs/lib/worshipassistantimport.py @@ -30,6 +30,7 @@ The :mod:`worshipassistantimport` module provides the functionality for importing Worship Assistant songs into the OpenLP database. """ +import chardet import csv import logging import re @@ -40,8 +41,7 @@ from openlp.plugins.songs.lib.songimport import SongImport log = logging.getLogger(__name__) -# Used to strip control chars (except 10=LF, 13=CR) -CONTROL_CHARS_MAP = dict.fromkeys(list(range(10)) + [11, 12] + list(range(14, 32)) + [127]) +EMPTY_STR = 'NULL' class WorshipAssistantImport(SongImport): @@ -53,12 +53,12 @@ class WorshipAssistantImport(SongImport): * ``SONGNR`` Song ID (Discarded by importer) * ``TITLE`` Song title - * ``AUTHOR`` Song author. May containt multiple authors. + * ``AUTHOR`` Song author. * ``COPYRIGHT`` Copyright information * ``FIRSTLINE`` Unknown (Discarded by importer) - * ``PRIKEY`` Primary chord key - * ``ALTKEY`` Alternate chord key - * ``TEMPO`` Tempo + * ``PRIKEY`` Primary chord key (Discarded by importer) + * ``ALTKEY`` Alternate chord key (Discarded by importer) + * ``TEMPO`` Tempo (Discarded by importer) * ``FOCUS`` Unknown (Discarded by importer) * ``THEME`` Theme (Discarded by importer) * ``SCRIPTURE`` Associated scripture (Discarded by importer) @@ -75,86 +75,90 @@ class WorshipAssistantImport(SongImport): * ``USER3`` User Field 3 (Discarded by importer) * ``USER4`` User Field 4 (Discarded by importer) * ``USER5`` User Field 5 (Discarded by importer) - * ``ROADMAP`` Verse order + * ``ROADMAP`` Verse order used for the presentation (Discarded by importer) * ``FILELINK1`` Associated file 1 (Discarded by importer) - * ``OVERMAP`` Unknown (Discarded by importer) + * ``OVERMAP`` Verse order used for printing (Discarded by importer) * ``FILELINK2`` Associated file 2 (Discarded by importer) - * ``LYRICS`` The song lyrics as plain text (Discarded by importer) + * ``LYRICS`` The song lyrics used for printing (Discarded by importer, LYRICS2 is used instead) * ``INFO`` Unknown (Discarded by importer) - * ``LYRICS2`` The song lyrics with verse numbers + * ``LYRICS2`` The song lyrics used for the presentation * ``BACKGROUND`` Unknown (Discarded by importer) """ def do_import(self): """ Receive a CSV file to import. """ - with open(self.import_source, 'r', encoding='latin-1') as songs_file: - songs_reader = csv.DictReader(songs_file) - try: - records = list(songs_reader) - except csv.Error as e: - self.log_error(translate('SongsPlugin.WorshipAssistantImport', 'Error reading CSV file.'), - translate('SongsPlugin.WorshipAssistantImport', 'Line %d: %s') % - (songs_reader.line_num, e)) - return - num_records = len(records) - log.info('%s records found in CSV file' % num_records) - self.import_wizard.progress_bar.setMaximum(num_records) - for index, record in enumerate(records, 1): - if self.stop_import_flag: - return - # The CSV file has a line in the middle of the file where the headers are repeated. - # We need to skip this line. - if record['TITLE'] == "TITLE" and record['AUTHOR'] == 'AUTHOR' and record['LYRICS2'] == 'LYRICS2': - continue - self.set_defaults() - try: - self.title = self._decode(record['TITLE']) - self.parse_author(self._decode(record['AUTHOR'])) - self.add_copyright(self._decode(record['COPYRIGHT'])) - lyrics = self._decode(record['LYRICS2']) - except UnicodeDecodeError as e: - self.log_error(translate('SongsPlugin.WorshipAssistantImport', 'Record %d' % index), - translate('SongsPlugin.WorshipAssistantImport', 'Decoding error: %s') % e) - continue - except TypeError as e: - self.log_error(translate('SongsPlugin.WorshipAssistantImport', - 'File not valid WorshipAssistant CSV format.'), 'TypeError: %s' % e) - return - verse = '' - for line in lyrics.splitlines(): - if line.startswith('['): # verse marker - # drop the square brackets - right_bracket = line.find(']') - content = line[1:right_bracket].lower() - # have we got any digits? If so, verse number is everything from the digits to the end (openlp does not - # have concept of part verses, so just ignore any non integers on the end (including floats)) - match = re.match('(\D*)(\d+)', content) - if match is not None: - verse_tag = match.group(1) - verse_num = match.group(2) - else: - # otherwise we assume number 1 and take the whole prefix as the verse tag - verse_tag = content - verse_num = '1' - verse_index = VerseType.from_loose_input(verse_tag) if verse_tag else 0 - verse_tag = VerseType.tags[verse_index] - elif line and not line.isspace(): - verse += line + '\n' - elif verse: - self.add_verse(verse, verse_tag+verse_num) - verse = '' - if verse: - self.add_verse(verse, verse_tag+verse_num) - if not self.finish(): - self.log_error(translate('SongsPlugin.ZionWorxImport', 'Record %d') % index - + (': "' + self.title + '"' if self.title else '')) + # Get encoding + detect_file = open(self.import_source, 'rb') + detect_content = detect_file.read() + details = chardet.detect(detect_content) + detect_file.close() + songs_file = open(self.import_source, 'r', encoding=details['encoding']) - def _decode(self, str): - """ - Decodes CSV input to unicode, stripping all control characters (except new lines). - """ - # This encoding choice seems OK. ZionWorx has no option for setting the - # encoding for its songs, so we assume encoding is always the same. - return str - #return str(str, 'cp1252').translate(CONTROL_CHARS_MAP) + songs_reader = csv.DictReader(songs_file) + try: + records = list(songs_reader) + except csv.Error as e: + self.log_error(translate('SongsPlugin.WorshipAssistantImport', 'Error reading CSV file.'), + translate('SongsPlugin.WorshipAssistantImport', 'Line %d: %s') % + (songs_reader.line_num, e)) + return + num_records = len(records) + log.info('%s records found in CSV file' % num_records) + self.import_wizard.progress_bar.setMaximum(num_records) + for index, record in enumerate(records, 1): + if self.stop_import_flag: + return + # Ensure that all keys are uppercase + record = dict((k.upper(), v) for k, v in record.items()) + # The CSV file has a line in the middle of the file where the headers are repeated. + # We need to skip this line. + if record['TITLE'] == "TITLE" and record['AUTHOR'] == 'AUTHOR' and record['LYRICS2'] == 'LYRICS2': + continue + self.set_defaults() + try: + self.title = record['TITLE'] + if record['AUTHOR'] != EMPTY_STR: + self.parse_author(record['AUTHOR']) + if record['COPYRIGHT']!= EMPTY_STR: + self.add_copyright(record['COPYRIGHT']) + if record['CCLINR'] != EMPTY_STR: + self.ccli_number = record['CCLINR'] + lyrics = record['LYRICS2'] + except UnicodeDecodeError as e: + self.log_error(translate('SongsPlugin.WorshipAssistantImport', 'Record %d' % index), + translate('SongsPlugin.WorshipAssistantImport', 'Decoding error: %s') % e) + continue + except TypeError as e: + self.log_error(translate('SongsPlugin.WorshipAssistantImport', + 'File not valid WorshipAssistant CSV format.'), 'TypeError: %s' % e) + return + verse = '' + for line in lyrics.splitlines(): + if line.startswith('['): # verse marker + # drop the square brackets + right_bracket = line.find(']') + content = line[1:right_bracket].lower() + # have we got any digits? If so, verse number is everything from the digits to the end (openlp does not + # have concept of part verses, so just ignore any non integers on the end (including floats)) + match = re.match('(\D*)(\d+)', content) + if match is not None: + verse_tag = match.group(1) + verse_num = match.group(2) + else: + # otherwise we assume number 1 and take the whole prefix as the verse tag + verse_tag = content + verse_num = '1' + verse_index = VerseType.from_loose_input(verse_tag) if verse_tag else 0 + verse_tag = VerseType.tags[verse_index] + elif line and not line.isspace(): + verse += line + '\n' + elif verse: + self.add_verse(verse, verse_tag+verse_num) + verse = '' + if verse: + self.add_verse(verse, verse_tag+verse_num) + if not self.finish(): + self.log_error(translate('SongsPlugin.ZionWorxImport', 'Record %d') % index + + (': "' + self.title + '"' if self.title else '')) + songs_file.close() diff --git a/tests/functional/openlp_plugins/songs/test_opensongimport.py b/tests/functional/openlp_plugins/songs/test_opensongimport.py index 70d3b342a..96d6bff0b 100644 --- a/tests/functional/openlp_plugins/songs/test_opensongimport.py +++ b/tests/functional/openlp_plugins/songs/test_opensongimport.py @@ -52,11 +52,11 @@ class TestOpenSongFileImport(SongImportTestHelper): """ Test that loading an OpenSong file works correctly on various files """ - self.file_import(os.path.join(TEST_PATH, 'Amazing Grace'), + self.file_import([os.path.join(TEST_PATH, 'Amazing Grace')], self.load_external_result_data(os.path.join(TEST_PATH, 'Amazing Grace.json'))) - self.file_import(os.path.join(TEST_PATH, 'Beautiful Garden Of Prayer'), + self.file_import([os.path.join(TEST_PATH, 'Beautiful Garden Of Prayer')], self.load_external_result_data(os.path.join(TEST_PATH, 'Beautiful Garden Of Prayer.json'))) - self.file_import(os.path.join(TEST_PATH, 'One, Two, Three, Four, Five'), + self.file_import([os.path.join(TEST_PATH, 'One, Two, Three, Four, Five')], self.load_external_result_data(os.path.join(TEST_PATH, 'One, Two, Three, Four, Five.json'))) diff --git a/tests/functional/openlp_plugins/songs/test_propresenterimport.py b/tests/functional/openlp_plugins/songs/test_propresenterimport.py index 971ddbdf6..10e2defc6 100644 --- a/tests/functional/openlp_plugins/songs/test_propresenterimport.py +++ b/tests/functional/openlp_plugins/songs/test_propresenterimport.py @@ -50,5 +50,5 @@ class TestProPresenterFileImport(SongImportTestHelper): """ Test that loading an ProPresenter file works correctly """ - self.file_import(os.path.join(TEST_PATH, 'Amazing Grace.pro4'), + self.file_import([os.path.join(TEST_PATH, 'Amazing Grace.pro4')], self.load_external_result_data(os.path.join(TEST_PATH, 'Amazing Grace.json'))) diff --git a/tests/functional/openlp_plugins/songs/test_songshowplusimport.py b/tests/functional/openlp_plugins/songs/test_songshowplusimport.py index 08400fdc5..dfee265e3 100644 --- a/tests/functional/openlp_plugins/songs/test_songshowplusimport.py +++ b/tests/functional/openlp_plugins/songs/test_songshowplusimport.py @@ -53,11 +53,11 @@ class TestSongShowPlusFileImport(SongImportTestHelper): """ Test that loading a SongShow Plus file works correctly on various files """ - self.file_import(os.path.join(TEST_PATH, 'Amazing Grace.sbsong'), + self.file_import([os.path.join(TEST_PATH, 'Amazing Grace.sbsong')], self.load_external_result_data(os.path.join(TEST_PATH, 'Amazing Grace.json'))) - self.file_import(os.path.join(TEST_PATH, 'Beautiful Garden Of Prayer.sbsong'), + self.file_import([os.path.join(TEST_PATH, 'Beautiful Garden Of Prayer.sbsong')], self.load_external_result_data(os.path.join(TEST_PATH, 'Beautiful Garden Of Prayer.json'))) - self.file_import(os.path.join(TEST_PATH, 'a mighty fortress is our god.sbsong'), + self.file_import([os.path.join(TEST_PATH, 'a mighty fortress is our god.sbsong')], self.load_external_result_data(os.path.join(TEST_PATH, 'a mighty fortress is our god.json'))) diff --git a/tests/helpers/songfileimport.py b/tests/helpers/songfileimport.py index 36beef6e5..80b2ee268 100644 --- a/tests/helpers/songfileimport.py +++ b/tests/helpers/songfileimport.py @@ -95,7 +95,7 @@ class SongImportTestHelper(TestCase): importer.topics = [] # WHEN: Importing the source file - importer.import_source = [source_file_name] + importer.import_source = source_file_name add_verse_calls = self._get_data(result_data, 'verses') author_calls = self._get_data(result_data, 'authors') ccli_number = self._get_data(result_data, 'ccli_number') From 5eb0ac618ecc733a00a0fdc1e16b7ffd0d5e32da Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Wed, 25 Jun 2014 17:04:13 +0200 Subject: [PATCH 34/49] PEP8 --- openlp/plugins/songs/lib/worshipassistantimport.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/openlp/plugins/songs/lib/worshipassistantimport.py b/openlp/plugins/songs/lib/worshipassistantimport.py index d371044b1..980f7a801 100644 --- a/openlp/plugins/songs/lib/worshipassistantimport.py +++ b/openlp/plugins/songs/lib/worshipassistantimport.py @@ -120,7 +120,7 @@ class WorshipAssistantImport(SongImport): self.title = record['TITLE'] if record['AUTHOR'] != EMPTY_STR: self.parse_author(record['AUTHOR']) - if record['COPYRIGHT']!= EMPTY_STR: + if record['COPYRIGHT'] != EMPTY_STR: self.add_copyright(record['COPYRIGHT']) if record['CCLINR'] != EMPTY_STR: self.ccli_number = record['CCLINR'] @@ -135,12 +135,10 @@ class WorshipAssistantImport(SongImport): return verse = '' for line in lyrics.splitlines(): - if line.startswith('['): # verse marker + if line.startswith('['): # verse marker # drop the square brackets right_bracket = line.find(']') content = line[1:right_bracket].lower() - # have we got any digits? If so, verse number is everything from the digits to the end (openlp does not - # have concept of part verses, so just ignore any non integers on the end (including floats)) match = re.match('(\D*)(\d+)', content) if match is not None: verse_tag = match.group(1) From 93c3a57ea9f3dcbce52ea925dc83190f25d33b6c Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Wed, 25 Jun 2014 17:04:28 +0200 Subject: [PATCH 35/49] Add missing files --- .../songs/test_worshipassistantimport.py | 54 +++++++++++++++++++ .../worshipassistantsongs/du_herr.csv | 30 +++++++++++ .../worshipassistantsongs/du_herr.json | 21 ++++++++ 3 files changed, 105 insertions(+) create mode 100644 tests/functional/openlp_plugins/songs/test_worshipassistantimport.py create mode 100644 tests/resources/worshipassistantsongs/du_herr.csv create mode 100644 tests/resources/worshipassistantsongs/du_herr.json diff --git a/tests/functional/openlp_plugins/songs/test_worshipassistantimport.py b/tests/functional/openlp_plugins/songs/test_worshipassistantimport.py new file mode 100644 index 000000000..9d968beaa --- /dev/null +++ b/tests/functional/openlp_plugins/songs/test_worshipassistantimport.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2013 Raoul Snyman # +# Portions copyright (c) 2008-2013 Tim Bentley, Gerald Britton, Jonathan # +# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, # +# 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:`worshipassistantimport` module provides the functionality for importing +WorshipAssistant song files into the current installation database. +""" + +import os + +from tests.helpers.songfileimport import SongImportTestHelper + +TEST_PATH = os.path.abspath( + os.path.join(os.path.dirname(__file__), '..', '..', '..', 'resources', 'worshipassistantsongs')) + + +class TestWorshipAssistantFileImport(SongImportTestHelper): + + def __init__(self, *args, **kwargs): + self.importer_class_name = 'WorshipAssistantImport' + self.importer_module_name = 'worshipassistantimport' + super(TestWorshipAssistantFileImport, self).__init__(*args, **kwargs) + + def test_song_import(self): + """ + Test that loading an Worship Assistant file works correctly + """ + self.file_import(os.path.join(TEST_PATH, 'du_herr.csv'), + self.load_external_result_data(os.path.join(TEST_PATH, 'du_herr.json'))) diff --git a/tests/resources/worshipassistantsongs/du_herr.csv b/tests/resources/worshipassistantsongs/du_herr.csv new file mode 100644 index 000000000..72c5b4735 --- /dev/null +++ b/tests/resources/worshipassistantsongs/du_herr.csv @@ -0,0 +1,30 @@ +"SongID","SongNr","Title","Author","Copyright","FirstLine","PriKey","AltKey","Tempo","Focus","Theme","Scripture","Active","Songbook","TimeSig","Introduced","LastUsed","TimesUsed","CCLINr","User1","User2","User3","User4","User5","Roadmap","Overmap","FileLink1","FileLink2","Updated","Lyrics","Info","Lyrics2","Background" +"4ee399dc-edda-4aa9-891e-a859ca093c78","NULL","Du, Herr, verläßt mich nicht","Carl Brockhaus / Johann Georg Bäßler 1806","NULL","NULL","NULL","NULL","NULL","NULL","NULL","NULL","1","1","NULL","NULL","NULL","NULL","NULL","NULL","NULL","NULL","NULL","NULL","NULL","NULL","NULL","NULL","2014-06-25 12:15:28.317","","NULL","[1] +Du, Herr, verläßt mich nicht. +Auf Dich mein Herz allein vertraut, +Mein Auge glaubend auf Dich schaut. +Du bist mein Heil, mein Licht, +Mein Fels, mein sichrer Hort. +Bin ich versucht, gibt's Not und Leid, +Du bleibst mein Trost, mein Arm im Streit, +Mein Licht am dunklen Ort. + +[2] +Ich weiß, daß Du mich liebst. +Bist mir in jeder Lage nah', +Wohin ich gehe – Du bist da, +Ja, Du mir alles gibst. +Ich überlaß mich Dir; +Denn Du, Herr, kennst mich ganz und gar +Und führst mich sicher, wunderbar, +Und bist selbst alles mir. + +[3] +In dieser Wüste hier +Find't nirgend meine Seele Ruh', +Denn meine Ruh' bist, Jesu, Du. +Wohl mir, ich geh' zu Dir! +Bald werd' ich bei Dir sein, +Bald mit den Deinen ewiglich +Anbeten, loben, preisen Dich, +Mich Deiner stets erfreun.","NULL" diff --git a/tests/resources/worshipassistantsongs/du_herr.json b/tests/resources/worshipassistantsongs/du_herr.json new file mode 100644 index 000000000..56f3a7f0c --- /dev/null +++ b/tests/resources/worshipassistantsongs/du_herr.json @@ -0,0 +1,21 @@ +{ + "authors": [ + "Carl Brockhaus / Johann Georg Bäßler 1806" + ], + "title": "Du, Herr, verläßt mich nicht", + "verse_order_list": [], + "verses": [ + [ + "Du, Herr, verläßt mich nicht.\nAuf Dich mein Herz allein vertraut,\nMein Auge glaubend auf Dich schaut.\nDu bist mein Heil, mein Licht,\nMein Fels, mein sichrer Hort.\nBin ich versucht, gibt's Not und Leid,\nDu bleibst mein Trost, mein Arm im Streit,\nMein Licht am dunklen Ort.\n", + "v1" + ], + [ + "Ich weiß, daß Du mich liebst.\nBist mir in jeder Lage nah',\nWohin ich gehe – Du bist da,\nJa, Du mir alles gibst.\nIch überlaß mich Dir;\nDenn Du, Herr, kennst mich ganz und gar\nUnd führst mich sicher, wunderbar,\nUnd bist selbst alles mir.\n", + "v2" + ], + [ + "In dieser Wüste hier\nFind't nirgend meine Seele Ruh',\nDenn meine Ruh' bist, Jesu, Du.\nWohl mir, ich geh' zu Dir!\nBald werd' ich bei Dir sein,\nBald mit den Deinen ewiglich\nAnbeten, loben, preisen Dich,\nMich Deiner stets erfreun.\n", + "v3" + ] + ] +} \ No newline at end of file From e773d823417c21a405b395971ba3b99595d83d89 Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Thu, 26 Jun 2014 09:41:22 +0200 Subject: [PATCH 36/49] Updated VLC bindings to latest build --- openlp/core/ui/media/vendor/vlc.py | 523 ++++++++++++++++++++++++----- 1 file changed, 443 insertions(+), 80 deletions(-) diff --git a/openlp/core/ui/media/vendor/vlc.py b/openlp/core/ui/media/vendor/vlc.py index 01aced404..95f12ec85 100644 --- a/openlp/core/ui/media/vendor/vlc.py +++ b/openlp/core/ui/media/vendor/vlc.py @@ -48,7 +48,7 @@ import sys from inspect import getargspec __version__ = "N/A" -build_date = "Tue Jul 2 10:35:53 2013" +build_date = "Wed Jun 25 13:46:01 2014" if sys.version_info[0] > 2: str = str @@ -110,10 +110,11 @@ def find_lib(): p = find_library('libvlc.dll') if p is None: try: # some registry settings + # leaner than win32api, win32con if PYTHON3: - import winreg as w # leaner than win32api, win32con + import winreg as w else: - import _winreg as w # leaner than win32api, win32con + import _winreg as w for r in w.HKEY_LOCAL_MACHINE, w.HKEY_CURRENT_USER: try: r = w.OpenKey(r, 'Software\\VideoLAN\\VLC') @@ -368,6 +369,7 @@ class EventType(_Enum): 3: 'MediaParsedChanged', 4: 'MediaFreed', 5: 'MediaStateChanged', + 6: 'MediaSubItemTreeAdded', 0x100: 'MediaPlayerMediaChanged', 257: 'MediaPlayerNothingSpecial', 258: 'MediaPlayerOpening', @@ -387,6 +389,7 @@ class EventType(_Enum): 272: 'MediaPlayerSnapshotTaken', 273: 'MediaPlayerLengthChanged', 274: 'MediaPlayerVout', + 275: 'MediaPlayerScrambledChanged', 0x200: 'MediaListItemAdded', 513: 'MediaListWillAddItem', 514: 'MediaListItemDeleted', @@ -442,6 +445,7 @@ EventType.MediaPlayerPausableChanged = EventType(270) EventType.MediaPlayerPaused = EventType(261) EventType.MediaPlayerPlaying = EventType(260) EventType.MediaPlayerPositionChanged = EventType(268) +EventType.MediaPlayerScrambledChanged = EventType(275) EventType.MediaPlayerSeekableChanged = EventType(269) EventType.MediaPlayerSnapshotTaken = EventType(272) EventType.MediaPlayerStopped = EventType(262) @@ -450,6 +454,7 @@ EventType.MediaPlayerTitleChanged = EventType(271) EventType.MediaPlayerVout = EventType(274) EventType.MediaStateChanged = EventType(5) EventType.MediaSubItemAdded = EventType(1) +EventType.MediaSubItemTreeAdded = EventType(6) EventType.VlmMediaAdded = EventType(0x600) EventType.VlmMediaChanged = EventType(1538) EventType.VlmMediaInstanceStarted = EventType(1539) @@ -483,23 +488,35 @@ class Meta(_Enum): 14: 'EncodedBy', 15: 'ArtworkURL', 16: 'TrackID', + 17: 'TrackTotal', + 18: 'Director', + 19: 'Season', + 20: 'Episode', + 21: 'ShowName', + 22: 'Actors', } +Meta.Actors = Meta(22) Meta.Album = Meta(4) Meta.Artist = Meta(1) Meta.ArtworkURL = Meta(15) Meta.Copyright = Meta(3) Meta.Date = Meta(8) Meta.Description = Meta(6) +Meta.Director = Meta(18) Meta.EncodedBy = Meta(14) +Meta.Episode = Meta(20) Meta.Genre = Meta(2) Meta.Language = Meta(11) Meta.NowPlaying = Meta(12) Meta.Publisher = Meta(13) Meta.Rating = Meta(7) +Meta.Season = Meta(19) Meta.Setting = Meta(9) +Meta.ShowName = Meta(21) Meta.Title = Meta(0) Meta.TrackID = Meta(16) Meta.TrackNumber = Meta(5) +Meta.TrackTotal = Meta(17) Meta.URL = Meta(10) class State(_Enum): @@ -597,6 +614,32 @@ NavigateMode.left = NavigateMode(3) NavigateMode.right = NavigateMode(4) NavigateMode.up = NavigateMode(1) +class Position(_Enum): + '''Enumeration of values used to set position (e.g. of video title). + ''' + _enum_names_ = { + -1: 'disable', + 0: 'center', + 1: 'left', + 2: 'right', + 3: 'top', + 4: 'left', + 5: 'right', + 6: 'bottom', + 7: 'left', + 8: 'right', + } +Position.bottom = Position(6) +Position.center = Position(0) +Position.disable = Position(-1) +Position.left = Position(1) +Position.left = Position(4) +Position.left = Position(7) +Position.right = Position(2) +Position.right = Position(5) +Position.right = Position(8) +Position.top = Position(3) + class VideoLogoOption(_Enum): '''Option values for libvlc_video_{get,set}_logo_{int,string}. ''' @@ -688,7 +731,7 @@ class LogCb(ctypes.c_void_p): """Callback prototype for LibVLC log message handler. \param data data pointer as given to L{libvlc_log_set}() \param level message level (@ref enum libvlc_log_level) -\param ctx message context (meta-informations about the message) +\param ctx message context (meta-information about the message) \param fmt printf() format string (as defined by ISO C11) \param args variable argument list for the format \note Log message handlers must be thread-safe. @@ -826,18 +869,18 @@ class CallbackDecorators(object): Callback = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p) Callback.__doc__ = '''Callback function notification \param p_event the event triggering the callback - ''' + ''' LogCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_int, Log_ptr, ctypes.c_char_p, ctypes.c_void_p) LogCb.__doc__ = '''Callback prototype for LibVLC log message handler. \param data data pointer as given to L{libvlc_log_set}() \param level message level (@ref enum libvlc_log_level) -\param ctx message context (meta-informations about the message) +\param ctx message context (meta-information about the message) \param fmt printf() format string (as defined by ISO C11) \param args variable argument list for the format \note Log message handlers must be thread-safe. \warning The message context pointer, the format string parameters and the variable arguments are only valid until the callback returns. - ''' + ''' VideoLockCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ListPOINTER(ctypes.c_void_p)) VideoLockCb.__doc__ = '''Callback prototype to allocate and lock a picture buffer. Whenever a new video frame needs to be decoded, the lock callback is @@ -849,7 +892,7 @@ planes must be aligned on 32-bytes boundaries. of void pointers, this callback must initialize the array) [OUT] \return a private pointer for the display and unlock callbacks to identify the picture buffers - ''' + ''' VideoUnlockCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p, ListPOINTER(ctypes.c_void_p)) VideoUnlockCb.__doc__ = '''Callback prototype to unlock a picture buffer. When the video frame decoding is complete, the unlock callback is invoked. @@ -862,7 +905,7 @@ but before the picture is displayed. callback [IN] \param planes pixel planes as defined by the @ref libvlc_video_lock_cb callback (this parameter is only for convenience) [IN] - ''' + ''' VideoDisplayCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p) VideoDisplayCb.__doc__ = '''Callback prototype to display a picture. When the video frame needs to be shown, as determined by the media playback @@ -870,7 +913,7 @@ clock, the display callback is invoked. \param opaque private pointer as passed to L{libvlc_video_set_callbacks}() [IN] \param picture private pointer returned from the @ref libvlc_video_lock_cb callback [IN] - ''' + ''' VideoFormatCb = ctypes.CFUNCTYPE(ctypes.POINTER(ctypes.c_uint), ListPOINTER(ctypes.c_void_p), ctypes.c_char_p, ctypes.POINTER(ctypes.c_uint), ctypes.POINTER(ctypes.c_uint), ctypes.POINTER(ctypes.c_uint), ctypes.POINTER(ctypes.c_uint)) VideoFormatCb.__doc__ = '''Callback prototype to configure picture buffers format. This callback gets the format of the video as output by the video decoder @@ -894,47 +937,47 @@ the pixel height. Furthermore, we recommend that pitches and lines be multiple of 32 to not break assumption that might be made by various optimizations in the video decoders, video filters and/or video converters. - ''' + ''' VideoCleanupCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p) VideoCleanupCb.__doc__ = '''Callback prototype to configure picture buffers format. \param opaque private pointer as passed to L{libvlc_video_set_callbacks}() (and possibly modified by @ref libvlc_video_format_cb) [IN] - ''' + ''' AudioPlayCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p, ctypes.c_uint, ctypes.c_int64) AudioPlayCb.__doc__ = '''Callback prototype for audio playback. \param data data pointer as passed to L{libvlc_audio_set_callbacks}() [IN] \param samples pointer to the first audio sample to play back [IN] \param count number of audio samples to play back \param pts expected play time stamp (see libvlc_delay()) - ''' + ''' AudioPauseCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_int64) AudioPauseCb.__doc__ = '''Callback prototype for audio pause. \note The pause callback is never called if the audio is already paused. \param data data pointer as passed to L{libvlc_audio_set_callbacks}() [IN] \param pts time stamp of the pause request (should be elapsed already) - ''' + ''' AudioResumeCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_int64) AudioResumeCb.__doc__ = '''Callback prototype for audio resumption (i.e. restart from pause). \note The resume callback is never called if the audio is not paused. \param data data pointer as passed to L{libvlc_audio_set_callbacks}() [IN] \param pts time stamp of the resumption request (should be elapsed already) - ''' + ''' AudioFlushCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_int64) AudioFlushCb.__doc__ = '''Callback prototype for audio buffer flush (i.e. discard all pending buffers and stop playback as soon as possible). \param data data pointer as passed to L{libvlc_audio_set_callbacks}() [IN] - ''' + ''' AudioDrainCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p) AudioDrainCb.__doc__ = '''Callback prototype for audio buffer drain (i.e. wait for pending buffers to be played). \param data data pointer as passed to L{libvlc_audio_set_callbacks}() [IN] - ''' + ''' AudioSetVolumeCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_float, ctypes.c_bool) AudioSetVolumeCb.__doc__ = '''Callback prototype for audio volume change. \param data data pointer as passed to L{libvlc_audio_set_callbacks}() [IN] \param volume software volume (1. = nominal, 0. = mute) \param mute muted flag - ''' + ''' AudioSetupCb = ctypes.CFUNCTYPE(ctypes.POINTER(ctypes.c_int), ListPOINTER(ctypes.c_void_p), ctypes.c_char_p, ctypes.POINTER(ctypes.c_uint), ctypes.POINTER(ctypes.c_uint)) AudioSetupCb.__doc__ = '''Callback prototype to setup the audio playback. This is called when the media player needs to create a new audio output. @@ -944,12 +987,12 @@ This is called when the media player needs to create a new audio output. \param rate sample rate [IN/OUT] \param channels channels count [IN/OUT] \return 0 on success, anything else to skip audio playback - ''' + ''' AudioCleanupCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p) AudioCleanupCb.__doc__ = '''Callback prototype for audio playback cleanup. This is called when the media player no longer needs an audio output. \param opaque data pointer as passed to L{libvlc_audio_set_callbacks}() [IN] - ''' + ''' cb = CallbackDecorators # End of generated enum types # @@ -1213,7 +1256,7 @@ class EventManager(_Ctype): @note: Only a single notification can be registered for each event type in an EventManager instance. - + ''' _callback_handler = None @@ -1290,7 +1333,7 @@ class Instance(_Ctype): - a string - a list of strings as first parameters - the parameters given as the constructor parameters (must be strings) - + ''' def __new__(cls, *args): @@ -1435,6 +1478,16 @@ class Instance(_Ctype): ''' return libvlc_set_user_agent(self, str_to_bytes(name), str_to_bytes(http)) + def set_app_id(self, id, version, icon): + '''Sets some meta-information about the application. + See also L{set_user_agent}(). + @param id: Java-style application identifier, e.g. "com.acme.foobar". + @param version: application version numbers, e.g. "1.2.3". + @param icon: application icon name, e.g. "foobar". + @version: LibVLC 2.1.0 or later. + ''' + return libvlc_set_app_id(self, str_to_bytes(id), str_to_bytes(version), str_to_bytes(icon)) + def log_unset(self): '''Unsets the logging callback for a LibVLC instance. This is rarely needed: the callback is implicitly unset when the instance is destroyed. @@ -1524,13 +1577,13 @@ class Instance(_Ctype): return libvlc_media_library_new(self) def audio_output_list_get(self): - '''Gets the list of available audio outputs. + '''Gets the list of available audio output modules. @return: list of available audio outputs. It must be freed it with In case of error, NULL is returned. ''' return libvlc_audio_output_list_get(self) def audio_output_device_list_get(self, aout): - '''Gets a list of audio output devices for a given audio output. + '''Gets a list of audio output devices for a given audio output module, See L{audio_output_device_set}(). @note: Not all audio outputs support this. In particular, an empty (NULL) list of devices does B{not} imply that the specified audio output does @@ -1756,11 +1809,11 @@ class Instance(_Ctype): class Media(_Ctype): '''Create a new Media instance. - + Usage: Media(MRL, *options) See vlc.Instance.media_new documentation for details. - + ''' def __new__(cls, *args): @@ -1793,6 +1846,19 @@ class Media(_Ctype): for o in options: self.add_option(o) + def tracks_get(self): + """Get media descriptor's elementary streams description + Note, you need to call L{parse}() or play the media at least once + before calling this function. + Not doing this will result in an empty array. + The result must be freed with L{tracks_release}. + @version: LibVLC 2.1.0 and later. + """ + mediaTrack_pp = ctypes.POINTER(MediaTrack)() + n = libvlc_media_tracks_get(self, byref(mediaTrack_pp)) + info = cast(ctypes.mediaTrack_pp, ctypes.POINTER(ctypes.POINTER(MediaTrack) * n)) + return info + def add_option(self, psz_options): '''Add an option to the media. @@ -1965,17 +2031,6 @@ class Media(_Ctype): ''' return libvlc_media_get_user_data(self) - def tracks_get(self, tracks): - '''Get media descriptor's elementary streams description - Note, you need to call L{parse}() or play the media at least once - before calling this function. - Not doing this will result in an empty array. - @param tracks: address to store an allocated array of Elementary Streams descriptions (must be freed with L{tracks_release}. - @return: the number of Elementary Streams (zero on error). - @version: LibVLC 2.1.0 and later. - ''' - return libvlc_media_tracks_get(self, tracks) - def player_new_from_media(self): '''Create a Media Player object from a Media. @return: a new media player object, or NULL on error. @@ -2056,11 +2111,11 @@ class MediaLibrary(_Ctype): class MediaList(_Ctype): '''Create a new MediaList instance. - + Usage: MediaList(list_of_MRLs) See vlc.Instance.media_list_new documentation for details. - + ''' def __new__(cls, *args): @@ -2076,10 +2131,10 @@ class MediaList(_Ctype): def get_instance(self): return getattr(self, '_instance', None) - + def add_media(self, mrl): """Add media instance to media list. - + The L{lock} should be held upon entering this function. @param mrl: a media instance or a MRL. @return: 0 on success, -1 if the media list is read-only. @@ -2196,7 +2251,7 @@ class MediaListPlayer(_Ctype): It may take as parameter either: - a vlc.Instance - nothing - + ''' def __new__(cls, arg=None): @@ -2322,13 +2377,13 @@ class MediaPlayer(_Ctype): It may take as parameter either: - a string (media URI), options... In this case, a vlc.Instance will be created. - a vlc.Instance, a string (media URI), options... - + ''' def __new__(cls, *args): if len(args) == 1 and isinstance(args[0], _Ints): return _Constructor(cls, args[0]) - + if args and isinstance(args[0], Instance): instance = args[0] args = args[1:] @@ -2400,13 +2455,13 @@ class MediaPlayer(_Ctype): Specify where the media player should render its video output. If LibVLC was built without Win32/Win64 API output support, then this has no effects. - + @param drawable: windows handle of the drawable. """ if not isinstance(drawable, ctypes.c_void_p): drawable = ctypes.c_void_p(int(drawable)) libvlc_media_player_set_hwnd(self, drawable) - + def video_get_width(self, num=0): """Get the width of a video in pixels. @@ -2559,12 +2614,12 @@ class MediaPlayer(_Ctype): If you want to use it along with Qt4 see the QMacCocoaViewContainer. Then the following code should work: @begincode - + NSView *video = [[NSView alloc] init]; QMacCocoaViewContainer *container = new QMacCocoaViewContainer(video, parent); L{set_nsobject}(mp, video); [video release]; - + @endcode You can find a live example in VLCVideoView in VLCKit.framework. @param drawable: the drawable that is either an NSView or an object following the VLCOpenGLVideoViewEmbedding protocol. @@ -2799,6 +2854,13 @@ class MediaPlayer(_Ctype): ''' return libvlc_media_player_can_pause(self) + def program_scrambled(self): + '''Check if the current program is scrambled. + @return: true if the current program is scrambled \libvlc_return_bool. + @version: LibVLC 2.2.0 or later. + ''' + return libvlc_media_player_program_scrambled(self) + def next_frame(self): '''Display the next frame (if supported). ''' @@ -2811,6 +2873,14 @@ class MediaPlayer(_Ctype): ''' return libvlc_media_player_navigate(self, navigate) + def set_video_title_display(self, position, timeout): + '''Set if, and how, the video title will be shown when media is played. + @param position: position at which to display the title, or libvlc_position_disable to prevent the title from being displayed. + @param timeout: title display timeout in milliseconds (ignored if libvlc_position_disable). + @version: libVLC 2.1.0 or later. + ''' + return libvlc_media_player_set_video_title_display(self, position, timeout) + def toggle_fullscreen(self): '''Toggle fullscreen status on non-embedded video outputs. @warning: The same limitations applies to this function @@ -3086,7 +3156,7 @@ class MediaPlayer(_Ctype): return libvlc_video_set_adjust_float(self, option, value) def audio_output_set(self, psz_name): - '''Sets the audio output. + '''Selects an audio output module. @note: Any change will take be effect only after playback is stopped and restarted. Audio output cannot be changed while playing. @param psz_name: name of audio output, use psz_name of See L{AudioOutput}. @@ -3094,21 +3164,46 @@ class MediaPlayer(_Ctype): ''' return libvlc_audio_output_set(self, str_to_bytes(psz_name)) - def audio_output_device_set(self, psz_audio_output, psz_device_id): - '''Configures an explicit audio output device for a given audio output plugin. - A list of possible devices can be obtained with + def audio_output_device_enum(self): + '''Gets a list of potential audio output devices, + See L{audio_output_device_set}(). + @note: Not all audio outputs support enumerating devices. + The audio output may be functional even if the list is empty (NULL). + @note: The list may not be exhaustive. + @warning: Some audio output devices in the list might not actually work in + some circumstances. By default, it is recommended to not specify any + explicit audio device. + @return: A NULL-terminated linked list of potential audio output devices. It must be freed it with L{audio_output_device_list_release}(). + @version: LibVLC 2.2.0 or later. + ''' + return libvlc_audio_output_device_enum(self) + + def audio_output_device_set(self, module, device_id): + '''Configures an explicit audio output device. + If the module paramater is NULL, audio output will be moved to the device + specified by the device identifier string immediately. This is the + recommended usage. + A list of adequate potential device strings can be obtained with + L{audio_output_device_enum}(). + However passing NULL is supported in LibVLC version 2.2.0 and later only; + in earlier versions, this function would have no effects when the module + parameter was NULL. + If the module parameter is not NULL, the device parameter of the + corresponding audio output, if it exists, will be set to the specified + string. Note that some audio output modules do not have such a parameter + (notably MMDevice and PulseAudio). + A list of adequate potential device strings can be obtained with L{audio_output_device_list_get}(). @note: This function does not select the specified audio output plugin. L{audio_output_set}() is used for that purpose. @warning: The syntax for the device parameter depends on the audio output. - This is not portable. Only use this function if you know what you are doing. - Some audio outputs do not support this function (e.g. PulseAudio, WASAPI). - Some audio outputs require further parameters (e.g. ALSA: channels map). - @param psz_audio_output: - name of audio output, See L{AudioOutput}. - @param psz_device_id: device. - @return: Nothing. Errors are ignored. + Some audio output modules require further parameters (e.g. a channels map + in the case of ALSA). + @param module: If NULL, current audio output module. if non-NULL, name of audio output module. + @param device_id: device identifier string. + @return: Nothing. Errors are ignored (this is a design bug). ''' - return libvlc_audio_output_device_set(self, str_to_bytes(psz_audio_output), str_to_bytes(psz_device_id)) + return libvlc_audio_output_device_set(self, str_to_bytes(module), str_to_bytes(device_id)) def audio_toggle_mute(self): '''Toggle mute status. @@ -3187,6 +3282,28 @@ class MediaPlayer(_Ctype): ''' return libvlc_audio_set_delay(self, i_delay) + def set_equalizer(self, p_equalizer): + '''Apply new equalizer settings to a media player. + The equalizer is first created by invoking L{audio_equalizer_new}() or + L{audio_equalizer_new_from_preset}(). + It is possible to apply new equalizer settings to a media player whether the media + player is currently playing media or not. + Invoking this method will immediately apply the new equalizer settings to the audio + output of the currently playing media if there is any. + If there is no currently playing media, the new equalizer settings will be applied + later if and when new media is played. + Equalizer settings will automatically be applied to subsequently played media. + To disable the equalizer for a media player invoke this method passing NULL for the + p_equalizer parameter. + The media player does not keep a reference to the supplied equalizer so it is safe + for an application to release the equalizer reference any time after this method + returns. + @param p_equalizer: opaque equalizer handle, or NULL to disable the equalizer for this media player. + @return: zero on success, -1 on error. + @version: LibVLC 2.2.0 or later. + ''' + return libvlc_media_player_set_equalizer(self, p_equalizer) + # LibVLC __version__ functions # @@ -3282,6 +3399,20 @@ def libvlc_set_user_agent(p_instance, name, http): None, Instance, ctypes.c_char_p, ctypes.c_char_p) return f(p_instance, name, http) +def libvlc_set_app_id(p_instance, id, version, icon): + '''Sets some meta-information about the application. + See also L{libvlc_set_user_agent}(). + @param p_instance: LibVLC instance. + @param id: Java-style application identifier, e.g. "com.acme.foobar". + @param version: application version numbers, e.g. "1.2.3". + @param icon: application icon name, e.g. "foobar". + @version: LibVLC 2.1.0 or later. + ''' + f = _Cfunctions.get('libvlc_set_app_id', None) or \ + _Cfunction('libvlc_set_app_id', ((1,), (1,), (1,), (1,),), None, + None, Instance, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p) + return f(p_instance, id, version, icon) + def libvlc_get_version(): '''Retrieve libvlc version. Example: "1.1.0-git The Luggage". @@ -3358,7 +3489,7 @@ def libvlc_event_type_name(event_type): return f(event_type) def libvlc_log_get_context(ctx): - '''Gets debugging informations about a log message: the name of the VLC module + '''Gets debugging information about a log message: the name of the VLC module emitting the message and the message location within the source code. The returned module name and file name will be NULL if unknown. The returned line number will similarly be zero if unknown. @@ -3372,9 +3503,9 @@ def libvlc_log_get_context(ctx): return f(ctx) def libvlc_log_get_object(ctx, id): - '''Gets VLC object informations about a log message: the type name of the VLC + '''Gets VLC object information about a log message: the type name of the VLC object emitting the message, the object header if any and a temporaly-unique - object identifier. These informations are mainly meant for B{manual} + object identifier. This information is mainly meant for B{manual} troubleshooting. The returned type name may be "generic" if unknown, but it cannot be NULL. The returned header will be NULL if unset; in current versions, the header @@ -4433,12 +4564,12 @@ def libvlc_media_player_set_nsobject(p_mi, drawable): If you want to use it along with Qt4 see the QMacCocoaViewContainer. Then the following code should work: @begincode - + NSView *video = [[NSView alloc] init]; QMacCocoaViewContainer *container = new QMacCocoaViewContainer(video, parent); L{libvlc_media_player_set_nsobject}(mp, video); [video release]; - + @endcode You can find a live example in VLCVideoView in VLCKit.framework. @param p_mi: the Media Player. @@ -4817,6 +4948,17 @@ def libvlc_media_player_can_pause(p_mi): ctypes.c_int, MediaPlayer) return f(p_mi) +def libvlc_media_player_program_scrambled(p_mi): + '''Check if the current program is scrambled. + @param p_mi: the media player. + @return: true if the current program is scrambled \libvlc_return_bool. + @version: LibVLC 2.2.0 or later. + ''' + f = _Cfunctions.get('libvlc_media_player_program_scrambled', None) or \ + _Cfunction('libvlc_media_player_program_scrambled', ((1,),), None, + ctypes.c_int, MediaPlayer) + return f(p_mi) + def libvlc_media_player_next_frame(p_mi): '''Display the next frame (if supported). @param p_mi: the media player. @@ -4837,6 +4979,18 @@ def libvlc_media_player_navigate(p_mi, navigate): None, MediaPlayer, ctypes.c_uint) return f(p_mi, navigate) +def libvlc_media_player_set_video_title_display(p_mi, position, timeout): + '''Set if, and how, the video title will be shown when media is played. + @param p_mi: the media player. + @param position: position at which to display the title, or libvlc_position_disable to prevent the title from being displayed. + @param timeout: title display timeout in milliseconds (ignored if libvlc_position_disable). + @version: libVLC 2.1.0 or later. + ''' + f = _Cfunctions.get('libvlc_media_player_set_video_title_display', None) or \ + _Cfunction('libvlc_media_player_set_video_title_display', ((1,), (1,), (1,),), None, + None, MediaPlayer, Position, ctypes.c_int) + return f(p_mi, position, timeout) + def libvlc_track_description_list_release(p_track_description): '''Release (free) L{TrackDescription}. @param p_track_description: the structure to release. @@ -5338,7 +5492,7 @@ def libvlc_video_set_adjust_float(p_mi, option, value): return f(p_mi, option, value) def libvlc_audio_output_list_get(p_instance): - '''Gets the list of available audio outputs. + '''Gets the list of available audio output modules. @param p_instance: libvlc instance. @return: list of available audio outputs. It must be freed it with In case of error, NULL is returned. ''' @@ -5348,7 +5502,7 @@ def libvlc_audio_output_list_get(p_instance): return f(p_instance) def libvlc_audio_output_list_release(p_list): - '''Frees the list of available audio outputs. + '''Frees the list of available audio output modules. @param p_list: list with audio outputs for release. ''' f = _Cfunctions.get('libvlc_audio_output_list_release', None) or \ @@ -5357,7 +5511,7 @@ def libvlc_audio_output_list_release(p_list): return f(p_list) def libvlc_audio_output_set(p_mi, psz_name): - '''Sets the audio output. + '''Selects an audio output module. @note: Any change will take be effect only after playback is stopped and restarted. Audio output cannot be changed while playing. @param p_mi: media player. @@ -5369,8 +5523,26 @@ def libvlc_audio_output_set(p_mi, psz_name): ctypes.c_int, MediaPlayer, ctypes.c_char_p) return f(p_mi, psz_name) +def libvlc_audio_output_device_enum(mp): + '''Gets a list of potential audio output devices, + See L{libvlc_audio_output_device_set}(). + @note: Not all audio outputs support enumerating devices. + The audio output may be functional even if the list is empty (NULL). + @note: The list may not be exhaustive. + @warning: Some audio output devices in the list might not actually work in + some circumstances. By default, it is recommended to not specify any + explicit audio device. + @param mp: media player. + @return: A NULL-terminated linked list of potential audio output devices. It must be freed it with L{libvlc_audio_output_device_list_release}(). + @version: LibVLC 2.2.0 or later. + ''' + f = _Cfunctions.get('libvlc_audio_output_device_enum', None) or \ + _Cfunction('libvlc_audio_output_device_enum', ((1,),), None, + ctypes.POINTER(AudioOutputDevice), MediaPlayer) + return f(mp) + def libvlc_audio_output_device_list_get(p_instance, aout): - '''Gets a list of audio output devices for a given audio output. + '''Gets a list of audio output devices for a given audio output module, See L{libvlc_audio_output_device_set}(). @note: Not all audio outputs support this. In particular, an empty (NULL) list of devices does B{not} imply that the specified audio output does @@ -5399,25 +5571,36 @@ def libvlc_audio_output_device_list_release(p_list): None, ctypes.POINTER(AudioOutputDevice)) return f(p_list) -def libvlc_audio_output_device_set(p_mi, psz_audio_output, psz_device_id): - '''Configures an explicit audio output device for a given audio output plugin. - A list of possible devices can be obtained with +def libvlc_audio_output_device_set(mp, module, device_id): + '''Configures an explicit audio output device. + If the module paramater is NULL, audio output will be moved to the device + specified by the device identifier string immediately. This is the + recommended usage. + A list of adequate potential device strings can be obtained with + L{libvlc_audio_output_device_enum}(). + However passing NULL is supported in LibVLC version 2.2.0 and later only; + in earlier versions, this function would have no effects when the module + parameter was NULL. + If the module parameter is not NULL, the device parameter of the + corresponding audio output, if it exists, will be set to the specified + string. Note that some audio output modules do not have such a parameter + (notably MMDevice and PulseAudio). + A list of adequate potential device strings can be obtained with L{libvlc_audio_output_device_list_get}(). @note: This function does not select the specified audio output plugin. L{libvlc_audio_output_set}() is used for that purpose. @warning: The syntax for the device parameter depends on the audio output. - This is not portable. Only use this function if you know what you are doing. - Some audio outputs do not support this function (e.g. PulseAudio, WASAPI). - Some audio outputs require further parameters (e.g. ALSA: channels map). - @param p_mi: media player. - @param psz_audio_output: - name of audio output, See L{AudioOutput}. - @param psz_device_id: device. - @return: Nothing. Errors are ignored. + Some audio output modules require further parameters (e.g. a channels map + in the case of ALSA). + @param mp: media player. + @param module: If NULL, current audio output module. if non-NULL, name of audio output module. + @param device_id: device identifier string. + @return: Nothing. Errors are ignored (this is a design bug). ''' f = _Cfunctions.get('libvlc_audio_output_device_set', None) or \ _Cfunction('libvlc_audio_output_device_set', ((1,), (1,), (1,),), None, None, MediaPlayer, ctypes.c_char_p, ctypes.c_char_p) - return f(p_mi, psz_audio_output, psz_device_id) + return f(mp, module, device_id) def libvlc_audio_toggle_mute(p_mi): '''Toggle mute status. @@ -5554,6 +5737,175 @@ def libvlc_audio_set_delay(p_mi, i_delay): ctypes.c_int, MediaPlayer, ctypes.c_int64) return f(p_mi, i_delay) +def libvlc_audio_equalizer_get_preset_count(): + '''Get the number of equalizer presets. + @return: number of presets. + @version: LibVLC 2.2.0 or later. + ''' + f = _Cfunctions.get('libvlc_audio_equalizer_get_preset_count', None) or \ + _Cfunction('libvlc_audio_equalizer_get_preset_count', (), None, + ctypes.c_uint) + return f() + +def libvlc_audio_equalizer_get_preset_name(u_index): + '''Get the name of a particular equalizer preset. + This name can be used, for example, to prepare a preset label or menu in a user + interface. + @param u_index: index of the preset, counting from zero. + @return: preset name, or NULL if there is no such preset. + @version: LibVLC 2.2.0 or later. + ''' + f = _Cfunctions.get('libvlc_audio_equalizer_get_preset_name', None) or \ + _Cfunction('libvlc_audio_equalizer_get_preset_name', ((1,),), None, + ctypes.c_char_p, ctypes.c_uint) + return f(u_index) + +def libvlc_audio_equalizer_get_band_count(): + '''Get the number of distinct frequency bands for an equalizer. + @return: number of frequency bands. + @version: LibVLC 2.2.0 or later. + ''' + f = _Cfunctions.get('libvlc_audio_equalizer_get_band_count', None) or \ + _Cfunction('libvlc_audio_equalizer_get_band_count', (), None, + ctypes.c_uint) + return f() + +def libvlc_audio_equalizer_get_band_frequency(u_index): + '''Get a particular equalizer band frequency. + This value can be used, for example, to create a label for an equalizer band control + in a user interface. + @param u_index: index of the band, counting from zero. + @return: equalizer band frequency (Hz), or -1 if there is no such band. + @version: LibVLC 2.2.0 or later. + ''' + f = _Cfunctions.get('libvlc_audio_equalizer_get_band_frequency', None) or \ + _Cfunction('libvlc_audio_equalizer_get_band_frequency', ((1,),), None, + ctypes.c_float, ctypes.c_uint) + return f(u_index) + +def libvlc_audio_equalizer_new(): + '''Create a new default equalizer, with all frequency values zeroed. + The new equalizer can subsequently be applied to a media player by invoking + L{libvlc_media_player_set_equalizer}(). + The returned handle should be freed via L{libvlc_audio_equalizer_release}() when + it is no longer needed. + @return: opaque equalizer handle, or NULL on error. + @version: LibVLC 2.2.0 or later. + ''' + f = _Cfunctions.get('libvlc_audio_equalizer_new', None) or \ + _Cfunction('libvlc_audio_equalizer_new', (), None, + ctypes.c_void_p) + return f() + +def libvlc_audio_equalizer_new_from_preset(u_index): + '''Create a new equalizer, with initial frequency values copied from an existing + preset. + The new equalizer can subsequently be applied to a media player by invoking + L{libvlc_media_player_set_equalizer}(). + The returned handle should be freed via L{libvlc_audio_equalizer_release}() when + it is no longer needed. + @param u_index: index of the preset, counting from zero. + @return: opaque equalizer handle, or NULL on error. + @version: LibVLC 2.2.0 or later. + ''' + f = _Cfunctions.get('libvlc_audio_equalizer_new_from_preset', None) or \ + _Cfunction('libvlc_audio_equalizer_new_from_preset', ((1,),), None, + ctypes.c_void_p, ctypes.c_uint) + return f(u_index) + +def libvlc_audio_equalizer_release(p_equalizer): + '''Release a previously created equalizer instance. + The equalizer was previously created by using L{libvlc_audio_equalizer_new}() or + L{libvlc_audio_equalizer_new_from_preset}(). + It is safe to invoke this method with a NULL p_equalizer parameter for no effect. + @param p_equalizer: opaque equalizer handle, or NULL. + @version: LibVLC 2.2.0 or later. + ''' + f = _Cfunctions.get('libvlc_audio_equalizer_release', None) or \ + _Cfunction('libvlc_audio_equalizer_release', ((1,),), None, + None, ctypes.c_void_p) + return f(p_equalizer) + +def libvlc_audio_equalizer_set_preamp(p_equalizer, f_preamp): + '''Set a new pre-amplification value for an equalizer. + The new equalizer settings are subsequently applied to a media player by invoking + L{libvlc_media_player_set_equalizer}(). + The supplied amplification value will be clamped to the -20.0 to +20.0 range. + @param p_equalizer: valid equalizer handle, must not be NULL. + @param f_preamp: preamp value (-20.0 to 20.0 Hz). + @return: zero on success, -1 on error. + @version: LibVLC 2.2.0 or later. + ''' + f = _Cfunctions.get('libvlc_audio_equalizer_set_preamp', None) or \ + _Cfunction('libvlc_audio_equalizer_set_preamp', ((1,), (1,),), None, + ctypes.c_int, ctypes.c_void_p, ctypes.c_float) + return f(p_equalizer, f_preamp) + +def libvlc_audio_equalizer_get_preamp(p_equalizer): + '''Get the current pre-amplification value from an equalizer. + @param p_equalizer: valid equalizer handle, must not be NULL. + @return: preamp value (Hz). + @version: LibVLC 2.2.0 or later. + ''' + f = _Cfunctions.get('libvlc_audio_equalizer_get_preamp', None) or \ + _Cfunction('libvlc_audio_equalizer_get_preamp', ((1,),), None, + ctypes.c_float, ctypes.c_void_p) + return f(p_equalizer) + +def libvlc_audio_equalizer_set_amp_at_index(p_equalizer, f_amp, u_band): + '''Set a new amplification value for a particular equalizer frequency band. + The new equalizer settings are subsequently applied to a media player by invoking + L{libvlc_media_player_set_equalizer}(). + The supplied amplification value will be clamped to the -20.0 to +20.0 range. + @param p_equalizer: valid equalizer handle, must not be NULL. + @param f_amp: amplification value (-20.0 to 20.0 Hz). + @param u_band: index, counting from zero, of the frequency band to set. + @return: zero on success, -1 on error. + @version: LibVLC 2.2.0 or later. + ''' + f = _Cfunctions.get('libvlc_audio_equalizer_set_amp_at_index', None) or \ + _Cfunction('libvlc_audio_equalizer_set_amp_at_index', ((1,), (1,), (1,),), None, + ctypes.c_int, ctypes.c_void_p, ctypes.c_float, ctypes.c_uint) + return f(p_equalizer, f_amp, u_band) + +def libvlc_audio_equalizer_get_amp_at_index(p_equalizer, u_band): + '''Get the amplification value for a particular equalizer frequency band. + @param p_equalizer: valid equalizer handle, must not be NULL. + @param u_band: index, counting from zero, of the frequency band to get. + @return: amplification value (Hz); NaN if there is no such frequency band. + @version: LibVLC 2.2.0 or later. + ''' + f = _Cfunctions.get('libvlc_audio_equalizer_get_amp_at_index', None) or \ + _Cfunction('libvlc_audio_equalizer_get_amp_at_index', ((1,), (1,),), None, + ctypes.c_float, ctypes.c_void_p, ctypes.c_uint) + return f(p_equalizer, u_band) + +def libvlc_media_player_set_equalizer(p_mi, p_equalizer): + '''Apply new equalizer settings to a media player. + The equalizer is first created by invoking L{libvlc_audio_equalizer_new}() or + L{libvlc_audio_equalizer_new_from_preset}(). + It is possible to apply new equalizer settings to a media player whether the media + player is currently playing media or not. + Invoking this method will immediately apply the new equalizer settings to the audio + output of the currently playing media if there is any. + If there is no currently playing media, the new equalizer settings will be applied + later if and when new media is played. + Equalizer settings will automatically be applied to subsequently played media. + To disable the equalizer for a media player invoke this method passing NULL for the + p_equalizer parameter. + The media player does not keep a reference to the supplied equalizer so it is safe + for an application to release the equalizer reference any time after this method + returns. + @param p_mi: opaque media player handle. + @param p_equalizer: opaque equalizer handle, or NULL to disable the equalizer for this media player. + @return: zero on success, -1 on error. + @version: LibVLC 2.2.0 or later. + ''' + f = _Cfunctions.get('libvlc_media_player_set_equalizer', None) or \ + _Cfunction('libvlc_media_player_set_equalizer', ((1,), (1,),), None, + ctypes.c_int, MediaPlayer, ctypes.c_void_p) + return f(p_mi, p_equalizer) + def libvlc_vlm_release(p_instance): '''Release the vlm instance related to the given L{Instance}. @param p_instance: the instance. @@ -5866,7 +6218,18 @@ def libvlc_vlm_get_event_manager(p_instance): # libvlc_printerr # libvlc_set_exit_handler -# 17 function(s) not wrapped as methods: +# 28 function(s) not wrapped as methods: +# libvlc_audio_equalizer_get_amp_at_index +# libvlc_audio_equalizer_get_band_count +# libvlc_audio_equalizer_get_band_frequency +# libvlc_audio_equalizer_get_preamp +# libvlc_audio_equalizer_get_preset_count +# libvlc_audio_equalizer_get_preset_name +# libvlc_audio_equalizer_new +# libvlc_audio_equalizer_new_from_preset +# libvlc_audio_equalizer_release +# libvlc_audio_equalizer_set_amp_at_index +# libvlc_audio_equalizer_set_preamp # libvlc_audio_output_device_list_release # libvlc_audio_output_list_release # libvlc_clearerr From 66827a7676b1a7a9bce3966483430200cd424140 Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Thu, 26 Jun 2014 09:58:59 +0200 Subject: [PATCH 37/49] Parse verse order --- openlp/plugins/songs/lib/songimport.py | 1 + .../songs/lib/worshipassistantimport.py | 18 ++++++++++++++---- .../songs/test_worshipassistantimport.py | 2 ++ .../worshipassistantsongs/du_herr.json | 2 +- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/openlp/plugins/songs/lib/songimport.py b/openlp/plugins/songs/lib/songimport.py index b8fcc604b..18bb571d3 100644 --- a/openlp/plugins/songs/lib/songimport.py +++ b/openlp/plugins/songs/lib/songimport.py @@ -266,6 +266,7 @@ class SongImport(QtCore.QObject): """ Add an author to the list """ + print(author) if author in self.authors: return self.authors.append(author) diff --git a/openlp/plugins/songs/lib/worshipassistantimport.py b/openlp/plugins/songs/lib/worshipassistantimport.py index 980f7a801..6831ec450 100644 --- a/openlp/plugins/songs/lib/worshipassistantimport.py +++ b/openlp/plugins/songs/lib/worshipassistantimport.py @@ -68,21 +68,20 @@ class WorshipAssistantImport(SongImport): * ``INTRODUCED`` Date the song was created (Discarded by importer) * ``LASTUSED`` Date the song was last used (Discarded by importer) * ``TIMESUSED`` How many times the song was used (Discarded by importer) - * ``TIMESUSED`` How many times the song was used (Discarded by importer) * ``CCLINR`` CCLI Number * ``USER1`` User Field 1 (Discarded by importer) * ``USER2`` User Field 2 (Discarded by importer) * ``USER3`` User Field 3 (Discarded by importer) * ``USER4`` User Field 4 (Discarded by importer) * ``USER5`` User Field 5 (Discarded by importer) - * ``ROADMAP`` Verse order used for the presentation (Discarded by importer) + * ``ROADMAP`` Verse order used for the presentation * ``FILELINK1`` Associated file 1 (Discarded by importer) * ``OVERMAP`` Verse order used for printing (Discarded by importer) * ``FILELINK2`` Associated file 2 (Discarded by importer) * ``LYRICS`` The song lyrics used for printing (Discarded by importer, LYRICS2 is used instead) * ``INFO`` Unknown (Discarded by importer) * ``LYRICS2`` The song lyrics used for the presentation - * ``BACKGROUND`` Unknown (Discarded by importer) + * ``BACKGROUND`` Custom background (Discarded by importer) """ def do_import(self): """ @@ -116,14 +115,18 @@ class WorshipAssistantImport(SongImport): if record['TITLE'] == "TITLE" and record['AUTHOR'] == 'AUTHOR' and record['LYRICS2'] == 'LYRICS2': continue self.set_defaults() + verse_order_list = [] try: self.title = record['TITLE'] if record['AUTHOR'] != EMPTY_STR: self.parse_author(record['AUTHOR']) + print(record['AUTHOR']) if record['COPYRIGHT'] != EMPTY_STR: self.add_copyright(record['COPYRIGHT']) if record['CCLINR'] != EMPTY_STR: self.ccli_number = record['CCLINR'] + if record['ROADMAP'] != EMPTY_STR: + verse_order_list = record['ROADMAP'].split(',') lyrics = record['LYRICS2'] except UnicodeDecodeError as e: self.log_error(translate('SongsPlugin.WorshipAssistantImport', 'Record %d' % index), @@ -149,6 +152,11 @@ class WorshipAssistantImport(SongImport): verse_num = '1' verse_index = VerseType.from_loose_input(verse_tag) if verse_tag else 0 verse_tag = VerseType.tags[verse_index] + # Update verse order when the verse name has changed + if content != verse_tag + verse_num: + for i in range(len(verse_order_list)): + if verse_order_list[i].lower() == content.lower(): + verse_order_list[i] = verse_tag + verse_num elif line and not line.isspace(): verse += line + '\n' elif verse: @@ -156,7 +164,9 @@ class WorshipAssistantImport(SongImport): verse = '' if verse: self.add_verse(verse, verse_tag+verse_num) + if verse_order_list: + self.verse_order_list = verse_order_list if not self.finish(): - self.log_error(translate('SongsPlugin.ZionWorxImport', 'Record %d') % index + self.log_error(translate('SongsPlugin.WorshipAssistantImport', 'Record %d') % index + (': "' + self.title + '"' if self.title else '')) songs_file.close() diff --git a/tests/functional/openlp_plugins/songs/test_worshipassistantimport.py b/tests/functional/openlp_plugins/songs/test_worshipassistantimport.py index 9d968beaa..c0c5c7416 100644 --- a/tests/functional/openlp_plugins/songs/test_worshipassistantimport.py +++ b/tests/functional/openlp_plugins/songs/test_worshipassistantimport.py @@ -52,3 +52,5 @@ class TestWorshipAssistantFileImport(SongImportTestHelper): """ self.file_import(os.path.join(TEST_PATH, 'du_herr.csv'), self.load_external_result_data(os.path.join(TEST_PATH, 'du_herr.json'))) + self.file_import(os.path.join(TEST_PATH, 'would_you_be_free.csv'), + self.load_external_result_data(os.path.join(TEST_PATH, 'would_you_be_free.json'))) diff --git a/tests/resources/worshipassistantsongs/du_herr.json b/tests/resources/worshipassistantsongs/du_herr.json index 56f3a7f0c..1df700df8 100644 --- a/tests/resources/worshipassistantsongs/du_herr.json +++ b/tests/resources/worshipassistantsongs/du_herr.json @@ -18,4 +18,4 @@ "v3" ] ] -} \ No newline at end of file +} From c63883402383702fb2750e003f53e42de1707d7b Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Thu, 26 Jun 2014 09:59:16 +0200 Subject: [PATCH 38/49] Add missing files --- .../would_you_be_free.csv | 30 +++++++++++++++++++ .../would_you_be_free.json | 19 ++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 tests/resources/worshipassistantsongs/would_you_be_free.csv create mode 100644 tests/resources/worshipassistantsongs/would_you_be_free.json diff --git a/tests/resources/worshipassistantsongs/would_you_be_free.csv b/tests/resources/worshipassistantsongs/would_you_be_free.csv new file mode 100644 index 000000000..a454ddbf5 --- /dev/null +++ b/tests/resources/worshipassistantsongs/would_you_be_free.csv @@ -0,0 +1,30 @@ +SONGNR,TITLE,AUTHOR,COPYRIGHT,FIRSTLINE,PRIKEY,ALTKEY,TEMPO,FOCUS,THEME,SCRIPTURE,ACTIVE,SONGBOOK,TIMESIG,INTRODUCED,LASTUSED,TIMESUSED,CCLINR,USER1,USER2,USER3,USER4,USER5,ROADMAP,FILELINK1,OVERMAP,FILELINK2,LYRICS,INFO,LYRICS2,Background +"7","Would You Be Free","Jones, Lewis E.","Public Domain","Would you be free from your burden of sin?","G","","Moderate","Only To Others","","","N","Y","","1899-12-30","1899-12-30","","","","","","","","1,C,1","","","",".G C G + Would you be free from your burden of sin? +. D D7 G + There's power in the blood, power in the blood +. C G + Would you o'er evil a victory win? +. D D7 G + There's wonderful power in the blood + +.G C G + There is power, power, wonder working power +.D G + In the blood of the Lamb +. C G + There is power, power, wonder working power +. D G + In the precious blood of the Lamb +","","[1] +Would you be free from your burden of sin? +There's power in the blood, power in the blood +Would you o'er evil a victory win? +There's wonderful power in the blood + +[C] +There is power, power, wonder working power +In the blood of the Lamb +There is power, power, wonder working power +In the precious blood of the Lamb +","" diff --git a/tests/resources/worshipassistantsongs/would_you_be_free.json b/tests/resources/worshipassistantsongs/would_you_be_free.json new file mode 100644 index 000000000..96bc06a59 --- /dev/null +++ b/tests/resources/worshipassistantsongs/would_you_be_free.json @@ -0,0 +1,19 @@ +{ + "authors": [ + "Jones", + "Lewis E" + ], + "title": "Would You Be Free", + "verse_order_list": ["v1", "c1", "v1"], + "copyright": "Public Domain", + "verses": [ + [ + "Would you be free from your burden of sin? \nThere's power in the blood, power in the blood \nWould you o'er evil a victory win? \nThere's wonderful power in the blood \n", + "v1" + ], + [ + "There is power, power, wonder working power \nIn the blood of the Lamb \nThere is power, power, wonder working power \nIn the precious blood of the Lamb \n", + "c1" + ] + ] +} From a52dc69c89f4e965f6224ba6022dd99a71f42215 Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Thu, 26 Jun 2014 10:04:33 +0200 Subject: [PATCH 39/49] Remove debug output --- openlp/plugins/songs/lib/songimport.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openlp/plugins/songs/lib/songimport.py b/openlp/plugins/songs/lib/songimport.py index 18bb571d3..b8fcc604b 100644 --- a/openlp/plugins/songs/lib/songimport.py +++ b/openlp/plugins/songs/lib/songimport.py @@ -266,7 +266,6 @@ class SongImport(QtCore.QObject): """ Add an author to the list """ - print(author) if author in self.authors: return self.authors.append(author) From 78f1756380b4576a8c57ef98db16b7d95c507bcc Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Thu, 26 Jun 2014 10:35:53 +0200 Subject: [PATCH 40/49] Fix biblegateway url --- openlp/plugins/bibles/lib/http.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index 64b024639..6b26dfabe 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -225,7 +225,7 @@ class BGExtract(RegistryProperties): url_book_name = urllib.parse.quote(book_name.encode("utf-8")) url_params = 'search=%s+%s&version=%s' % (url_book_name, chapter, version) soup = get_soup_for_bible_ref( - 'http://www.biblegateway.com/passage/?%s' % url_params, + 'http://legacy.biblegateway.com/passage/?%s' % url_params, pre_parse_regex=r'', pre_parse_substitute='') if not soup: return None @@ -252,7 +252,7 @@ class BGExtract(RegistryProperties): """ log.debug('BGExtract.get_books_from_http("%s")', version) url_params = urllib.parse.urlencode({'action': 'getVersionInfo', 'vid': '%s' % version}) - reference_url = 'http://www.biblegateway.com/versions/?%s#books' % url_params + reference_url = 'http://legacy.biblegateway.com/versions/?%s#books' % url_params page = get_web_page(reference_url) if not page: send_error_message('download') From b4be73b616bad50b9fe732cddd45b092cdbaa1d6 Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Thu, 26 Jun 2014 11:21:46 +0200 Subject: [PATCH 41/49] Fix bzr tags test --- tests/utils/test_bzr_tags.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/utils/test_bzr_tags.py b/tests/utils/test_bzr_tags.py index 393f4ce25..acadbd8c4 100644 --- a/tests/utils/test_bzr_tags.py +++ b/tests/utils/test_bzr_tags.py @@ -50,10 +50,6 @@ TAGS = [ ['1.9.11', '2039'], ['1.9.12', '2063'], ['2.0', '2118'], - ['2.0.1', '?'], - ['2.0.2', '?'], - ['2.0.3', '?'], - ['2.0.4', '?'], ['2.1.0', '2119'] ] From 7364d4962f7b70aa9f2536a2c347269e402a9a29 Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Mon, 30 Jun 2014 09:18:26 +0200 Subject: [PATCH 42/49] Small fixes --- openlp/plugins/songs/lib/worshipassistantimport.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/openlp/plugins/songs/lib/worshipassistantimport.py b/openlp/plugins/songs/lib/worshipassistantimport.py index 6831ec450..772fe8622 100644 --- a/openlp/plugins/songs/lib/worshipassistantimport.py +++ b/openlp/plugins/songs/lib/worshipassistantimport.py @@ -93,7 +93,6 @@ class WorshipAssistantImport(SongImport): details = chardet.detect(detect_content) detect_file.close() songs_file = open(self.import_source, 'r', encoding=details['encoding']) - songs_reader = csv.DictReader(songs_file) try: records = list(songs_reader) @@ -109,7 +108,7 @@ class WorshipAssistantImport(SongImport): if self.stop_import_flag: return # Ensure that all keys are uppercase - record = dict((k.upper(), v) for k, v in record.items()) + record = dict((field.upper(), value) for field, value in record.items()) # The CSV file has a line in the middle of the file where the headers are repeated. # We need to skip this line. if record['TITLE'] == "TITLE" and record['AUTHOR'] == 'AUTHOR' and record['LYRICS2'] == 'LYRICS2': From 79c7c583988c1f19f9183877a6fad6f635d15f58 Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Thu, 3 Jul 2014 13:21:12 +0200 Subject: [PATCH 43/49] 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 44/49] 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 45/49] 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 46/49] 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 47/49] 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 48/49] 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 49/49] 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()