← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~sam92/openlp/powerpraise-importer into lp:openlp

 

Samuel Mehrbrodt has proposed merging lp:~sam92/openlp/powerpraise-importer into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)
Related bugs:
  Bug #1336929 in OpenLP: "Support PowerPraise import"
  https://bugs.launchpad.net/openlp/+bug/1336929

For more details, see:
https://code.launchpad.net/~sam92/openlp/powerpraise-importer/+merge/225585

Add an importer for PowerPraise

lp:~sam92/openlp/powerpraise-importer (revision 2399)
[SUCCESS] http://ci.openlp.org/job/Branch-01-Pull/508/
[SUCCESS] http://ci.openlp.org/job/Branch-02-Functional-Tests/466/
[SUCCESS] http://ci.openlp.org/job/Branch-03-Interface-Tests/411/
[FAILURE] http://ci.openlp.org/job/Branch-04-Windows_Tests/370/
[SUCCESS] http://ci.openlp.org/job/Branch-05a-Code_Analysis/245/
[SUCCESS] http://ci.openlp.org/job/Branch-05b-Test_Coverage/119/
-- 
https://code.launchpad.net/~sam92/openlp/powerpraise-importer/+merge/225585
Your team OpenLP Core is requested to review the proposed merge of lp:~sam92/openlp/powerpraise-importer into lp:openlp.
=== modified file 'openlp/plugins/songs/lib/importer.py'
--- openlp/plugins/songs/lib/importer.py	2014-06-25 12:23:31 +0000
+++ openlp/plugins/songs/lib/importer.py	2014-07-03 22:09:52 +0000
@@ -51,6 +51,7 @@
 from .zionworximport import ZionWorxImport
 from .propresenterimport import ProPresenterImport
 from .worshipassistantimport import WorshipAssistantImport
+from .powerpraiseimport import PowerPraiseImport
 # Imports that might fail
 
 
@@ -160,17 +161,18 @@
     FoilPresenter = 8
     MediaShout = 9
     OpenSong = 10
-    PowerSong = 11
-    ProPresenter = 12
-    SongBeamer = 13
-    SongPro = 14
-    SongShowPlus = 15
-    SongsOfFellowship = 16
-    SundayPlus = 17
-    WordsOfWorship = 18
-    WorshipAssistant = 19
-    WorshipCenterPro = 20
-    ZionWorx = 21
+    PowerPraise = 11
+    PowerSong = 12
+    ProPresenter = 13
+    SongBeamer = 14
+    SongPro = 15
+    SongShowPlus = 16
+    SongsOfFellowship = 17
+    SundayPlus = 18
+    WordsOfWorship = 19
+    WorshipAssistant = 20
+    WorshipCenterPro = 21
+    ZionWorx = 22
 
     # Set optional attribute defaults
     __defaults__ = {
@@ -266,6 +268,12 @@
             'name': WizardStrings.OS,
             'prefix': 'openSong'
         },
+        PowerPraise: {
+            'class': PowerPraiseImport,
+            'name': 'PowerPraise',
+            'prefix': 'powerPraise',
+            'filter': '%s (*.ppl)' % translate('SongsPlugin.ImportWizardForm', 'PowerPraise Song Files')
+        },
         PowerSong: {
             'class': PowerSongImport,
             'name': 'PowerSong 1.0',
@@ -374,6 +382,7 @@
             SongFormat.FoilPresenter,
             SongFormat.MediaShout,
             SongFormat.OpenSong,
+            SongFormat.PowerPraise,
             SongFormat.PowerSong,
             SongFormat.ProPresenter,
             SongFormat.SongBeamer,

=== added file 'openlp/plugins/songs/lib/powerpraiseimport.py'
--- openlp/plugins/songs/lib/powerpraiseimport.py	1970-01-01 00:00:00 +0000
+++ openlp/plugins/songs/lib/powerpraiseimport.py	2014-07-03 22:09:52 +0000
@@ -0,0 +1,83 @@
+# -*- 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:`powerpraiseimport` module provides the functionality for importing
+Powerpraise song files into the current 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 PowerPraiseImport(SongImport):
+    """
+    The :class:`PowerpraiseImport` class provides OpenLP with the
+    ability to import Powerpraise song files.
+    """
+    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))
+            root = objectify.parse(open(file_path, 'rb')).getroot()
+            self.process_song(root)
+
+    def process_song(self, root):
+        self.set_defaults()
+        self.title = str(root.general.title)
+        verse_order_list = []
+        for item in root.order.item:
+            verse_order_list.append(str(item))
+
+        count = 0
+        for part in root.songtext.part:
+            count += 1
+            verse_def = "v%d" % count
+            original_verse_def = part.get('caption')
+            verse_text = []
+            for slide in part.slide:
+                if not hasattr(slide, 'line'):
+                    continue  # No content
+                for line in slide.line:
+                    verse_text.append(str(line))
+            self.add_verse('\n'.join(verse_text), verse_def)
+            # Update verse name in verse order list
+            for i in range(len(verse_order_list)):
+                if verse_order_list[i].lower() == original_verse_def.lower():
+                    verse_order_list[i] = verse_def
+
+        self.verse_order_list = verse_order_list
+        if not self.finish():
+            self.log_error(self.import_source)

=== added file 'tests/functional/openlp_plugins/songs/test_powerpraiseimport.py'
--- tests/functional/openlp_plugins/songs/test_powerpraiseimport.py	1970-01-01 00:00:00 +0000
+++ tests/functional/openlp_plugins/songs/test_powerpraiseimport.py	2014-07-03 22:09:52 +0000
@@ -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:`powerpraiseimport` 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', 'powerpraisesongs'))
+
+
+class TestPowerPraiseFileImport(SongImportTestHelper):
+
+    def __init__(self, *args, **kwargs):
+        self.importer_class_name = 'PowerPraiseImport'
+        self.importer_module_name = 'powerpraiseimport'
+        super(TestPowerPraiseFileImport, self).__init__(*args, **kwargs)
+
+    def test_song_import(self):
+        """
+        Test that loading a PowerPraise file works correctly
+        """
+        self.file_import([os.path.join(TEST_PATH, 'Näher, mein Gott zu Dir.ppl')],
+                         self.load_external_result_data(os.path.join(TEST_PATH, 'Näher, mein Gott zu Dir.json')))

=== modified file 'tests/functional/openlp_plugins/songs/test_propresenterimport.py'
--- tests/functional/openlp_plugins/songs/test_propresenterimport.py	2014-06-25 15:03:00 +0000
+++ tests/functional/openlp_plugins/songs/test_propresenterimport.py	2014-07-03 22:09:52 +0000
@@ -48,7 +48,7 @@
 
     def test_song_import(self):
         """
-        Test that loading an ProPresenter file works correctly
+        Test that loading a 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')))

=== modified file 'tests/helpers/songfileimport.py'
--- tests/helpers/songfileimport.py	2014-06-25 15:03:00 +0000
+++ tests/helpers/songfileimport.py	2014-07-03 22:09:52 +0000
@@ -31,10 +31,13 @@
 song files from third party applications.
 """
 import json
+import logging
 from unittest import TestCase
 
 from tests.functional import patch, MagicMock, call
 
+log = logging.getLogger(__name__)
+
 
 class SongImportTestHelper(TestCase):
     """
@@ -107,9 +110,21 @@
         topics = self._get_data(result_data, 'topics')
         verse_order_list = self._get_data(result_data, 'verse_order_list')
 
-        # THEN: do_import should return none, the song data should be as expected, and finish should have been
-        #       called.
+        # THEN: do_import should return none, the song data should be as expected, and finish should have been called.
         self.assertIsNone(importer.do_import(), 'do_import should return None when it has completed')
+
+        # Debug information - will be displayed when the test fails
+        log.debug("Title imported: %s" % importer.title)
+        log.debug("Verses imported: %s" % self.mocked_add_verse.mock_calls)
+        log.debug("Verse order imported: %s" % importer.verse_order_list)
+        log.debug("Authors imported: %s" % self.mocked_add_author.mock_calls)
+        log.debug("CCLI No. imported: %s" % importer.ccli_number)
+        log.debug("Comments imported: %s" % importer.comments)
+        log.debug("Songbook imported: %s" % importer.song_book_name)
+        log.debug("Song number imported: %s" % importer.song_number)
+        log.debug("Song copyright imported: %s" % importer.song_number)
+        log.debug("Topics imported: %s" % importer.topics)
+
         self.assertEqual(importer.title, title, 'title for %s should be "%s"' % (source_file_name, title))
         for author in author_calls:
             self.mocked_add_author.assert_any_call(author)

=== added directory 'tests/resources/powerpraisesongs'
=== added file 'tests/resources/powerpraisesongs/Näher, mein Gott zu Dir.json'
--- tests/resources/powerpraisesongs/Näher, mein Gott zu Dir.json	1970-01-01 00:00:00 +0000
+++ tests/resources/powerpraisesongs/Näher, mein Gott zu Dir.json	2014-07-03 22:09:52 +0000
@@ -0,0 +1,18 @@
+{
+    "title": "Näher, mein Gott, zu Dir",
+    "verse_order_list": ["v1", "v2", "v3"],
+    "verses": [
+        [
+            "Näher, mein Gott, zu Dir,\nsei meine Bitt'!\nNäher, o Herr, zu Dir\nmit jedem Schritt.\nNur an dem Herzen Dein\nkann ich geborgen sein;\ndeshalb die Bitte mein:\nNäher zu Dir!",
+            "v1"
+        ],
+        [
+            "Näher, mein Gott, zu Dir!\nEin jeder Tag\nsoll es neu zeigen mir,\nwas er vermag:\nWie seiner Gnade Macht,\nErlösung hat gebracht,\nin uns're Sündennacht.\nNäher zu Dir!",
+            "v2"
+        ],
+        [
+            "Näher, mein Gott, zu Dir!\nDich bet' ich an.\nWie vieles hast an mir,\nDu doch getan!\nVon Banden frei und los,\nruh' ich in Deinem Schoss.\nJa, Deine Gnad' ist gross!\nNäher zu Dir!",
+            "v3"
+        ]
+    ]
+}
\ No newline at end of file

=== added file 'tests/resources/powerpraisesongs/Näher, mein Gott zu Dir.ppl'
--- tests/resources/powerpraisesongs/Näher, mein Gott zu Dir.ppl	1970-01-01 00:00:00 +0000
+++ tests/resources/powerpraisesongs/Näher, mein Gott zu Dir.ppl	2014-07-03 22:09:52 +0000
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<ppl version="3.0"><general><title>N�r, mein Gott, zu Dir</title><category>Anbetung</category><language>Deutsch</language></general><songtext><part caption="Teil 1"><slide mainsize="42" backgroundnr="0"><line>N�r, mein Gott, zu Dir,</line><line>sei meine Bitt'!</line><line>N�r, o Herr, zu Dir</line><line>mit jedem Schritt.</line></slide><slide mainsize="44" backgroundnr="0"><line>Nur an dem Herzen Dein</line><line>kann ich geborgen sein;</line><line>deshalb die Bitte mein:</line><line>N�r zu Dir!</line></slide></part><part caption="Teil 2"><slide mainsize="42" backgroundnr="0"><line>N�r, mein Gott, zu Dir!</line><line>Ein jeder Tag</line><line>soll es neu zeigen mir,</line><line>was er vermag:</line></slide><slide mainsize="42" backgroundnr="0"><line>Wie seiner Gnade Macht,</line><line>Erl�g hat gebracht,</line><line>in uns're S�acht.</line><line>N�r zu Dir!</line></slide></part><part caption="Teil 3"><slide mainsize="42" backgroundnr="0"><line>N�r, mein Gott, zu Dir!</line><line>Dich bet' ich an.</line><line>Wie vieles hast an mir,</line><line>Du doch getan!</line></slide><slide mainsize="42" backgroundnr="0"><line>Von Banden frei und los,</line><line>ruh' ich in Deinem Schoss.</line><line>Ja, Deine Gnad' ist gross!</line><line>N�r zu Dir!</line></slide></part></songtext><order><item>Teil 1</item><item>Teil 2</item><item>Teil 3</item></order><information><copyright><position>lastslide</position><text><line>Text und Musik: Lowell Mason, 1792-1872</line></text></copyright><source><position>firstslide</position><text><line>gr�uch 339</line></text></source></information><formatting><font><maintext><name>Times New Roman</name><size>44</size><bold>true</bold><italic>true</italic><color>16777215</color><outline>30</outline><shadow>15</shadow></maintext><translationtext><name>Times New Roman</name><size>20</size><bold>false</bold><italic>false</italic><color>16777215</color><outline>30</outline><shadow>20</shadow></translationtext><copyrighttext><name>Times New Roman</name><size>14</size><bold>false</bold><italic>false</italic><color>16777215</color><outline>30</outline><shadow>20</shadow></copyrighttext><sourcetext><name>Times New Roman</name><size>30</size><bold>false</bold><italic>false</italic><color>16777215</color><outline>30</outline><shadow>20</shadow></sourcetext><outline><enabled>false</enabled><color>0</color></outline><shadow><enabled>true</enabled><color>0</color><direction>125</direction></shadow></font><background><file>Blumen\Blume 3.jpg</file></background><linespacing><main>30</main><translation>20</translation></linespacing><textorientation><horizontal>left</horizontal><vertical>center</vertical><transpos>inline</transpos></textorientation><borders><mainleft>50</mainleft><maintop>40</maintop><mainright>60</mainright><mainbottom>70</mainbottom><copyrightbottom>30</copyrightbottom><sourcetop>20</sourcetop><sourceright>40</sourceright></borders></formatting></ppl>


Follow ups