Add an importer for PowerPraise

bzr-revno: 2404
This commit is contained in:
Samuel Mehrbrodt 2014-07-14 17:26:50 +01:00 committed by Tim Bentley
commit b2afbd688d
9 changed files with 233 additions and 14 deletions

View File

@ -51,6 +51,7 @@ from .importers.foilpresenter import FoilPresenterImport
from .importers.zionworx import ZionWorxImport from .importers.zionworx import ZionWorxImport
from .importers.propresenter import ProPresenterImport from .importers.propresenter import ProPresenterImport
from .importers.worshipassistant import WorshipAssistantImport from .importers.worshipassistant import WorshipAssistantImport
from .importers.powerpraise import PowerPraiseImport
# Imports that might fail # Imports that might fail
@ -160,17 +161,18 @@ class SongFormat(object):
FoilPresenter = 8 FoilPresenter = 8
MediaShout = 9 MediaShout = 9
OpenSong = 10 OpenSong = 10
PowerSong = 11 PowerPraise = 11
ProPresenter = 12 PowerSong = 12
SongBeamer = 13 ProPresenter = 13
SongPro = 14 SongBeamer = 14
SongShowPlus = 15 SongPro = 15
SongsOfFellowship = 16 SongShowPlus = 16
SundayPlus = 17 SongsOfFellowship = 17
WordsOfWorship = 18 SundayPlus = 18
WorshipAssistant = 19 WordsOfWorship = 19
WorshipCenterPro = 20 WorshipAssistant = 20
ZionWorx = 21 WorshipCenterPro = 21
ZionWorx = 22
# Set optional attribute defaults # Set optional attribute defaults
__defaults__ = { __defaults__ = {
@ -266,6 +268,12 @@ class SongFormat(object):
'name': WizardStrings.OS, 'name': WizardStrings.OS,
'prefix': 'openSong' 'prefix': 'openSong'
}, },
PowerPraise: {
'class': PowerPraiseImport,
'name': 'PowerPraise',
'prefix': 'powerPraise',
'filter': '%s (*.ppl)' % translate('SongsPlugin.ImportWizardForm', 'PowerPraise Song Files')
},
PowerSong: { PowerSong: {
'class': PowerSongImport, 'class': PowerSongImport,
'name': 'PowerSong 1.0', 'name': 'PowerSong 1.0',
@ -374,6 +382,7 @@ class SongFormat(object):
SongFormat.FoilPresenter, SongFormat.FoilPresenter,
SongFormat.MediaShout, SongFormat.MediaShout,
SongFormat.OpenSong, SongFormat.OpenSong,
SongFormat.PowerPraise,
SongFormat.PowerSong, SongFormat.PowerSong,
SongFormat.ProPresenter, SongFormat.ProPresenter,
SongFormat.SongBeamer, SongFormat.SongBeamer,

View File

@ -0,0 +1,91 @@
# -*- 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
from lxml import objectify
from openlp.core.ui.wizard import WizardStrings
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 = []
verse_count = {}
for item in root.order.item:
verse_order_list.append(str(item))
for part in root.songtext.part:
original_verse_def = part.get('caption')
# There are some predefined verse defitions in PowerPraise, try to parse these
if original_verse_def.startswith("Strophe") or original_verse_def.startswith("Teil"):
verse_def = 'v'
elif original_verse_def.startswith("Refrain"):
verse_def = 'c'
elif original_verse_def.startswith("Bridge"):
verse_def = 'b'
elif original_verse_def.startswith("Schluss"):
verse_def = 'e'
else:
verse_def = 'o'
verse_count[verse_def] = verse_count.get(verse_def, 0) + 1
verse_def = '%s%d' % (verse_def, verse_count[verse_def])
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)

View File

@ -0,0 +1,56 @@
# -*- 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 = 'powerpraise'
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')))
self.file_import([os.path.join(TEST_PATH, 'You are so faithful.ppl')],
self.load_external_result_data(os.path.join(TEST_PATH, 'You are so faithful.json')))

View File

@ -48,7 +48,7 @@ class TestProPresenterFileImport(SongImportTestHelper):
def test_song_import(self): 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.file_import([os.path.join(TEST_PATH, 'Amazing Grace.pro4')],
self.load_external_result_data(os.path.join(TEST_PATH, 'Amazing Grace.json'))) self.load_external_result_data(os.path.join(TEST_PATH, 'Amazing Grace.json')))

View File

@ -31,10 +31,13 @@ The :mod:`songfileimporthelper` modules provides a helper class and methods to e
song files from third party applications. song files from third party applications.
""" """
import json import json
import logging
from unittest import TestCase from unittest import TestCase
from tests.functional import patch, MagicMock, call from tests.functional import patch, MagicMock, call
log = logging.getLogger(__name__)
class SongImportTestHelper(TestCase): class SongImportTestHelper(TestCase):
""" """
@ -108,9 +111,21 @@ class SongImportTestHelper(TestCase):
topics = self._get_data(result_data, 'topics') topics = self._get_data(result_data, 'topics')
verse_order_list = self._get_data(result_data, 'verse_order_list') 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 # THEN: do_import should return none, the song data should be as expected, and finish should have been called.
# called.
self.assertIsNone(importer.do_import(), 'do_import should return None when it has completed') 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)) self.assertEqual(importer.title, title, 'title for %s should be "%s"' % (source_file_name, title))
for author in author_calls: for author in author_calls:
self.mocked_add_author.assert_any_call(author) self.mocked_add_author.assert_any_call(author)

View File

@ -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"
]
]
}

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<ppl version="3.0"><general><title>Näher, mein Gott, zu Dir</title><category>Anbetung</category><language>Deutsch</language></general><songtext><part caption="Teil 1"><slide mainsize="42" backgroundnr="0"><line>Näher, mein Gott, zu Dir,</line><line>sei meine Bitt'!</line><line>Näher, 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äher zu Dir!</line></slide></part><part caption="Teil 2"><slide mainsize="42" backgroundnr="0"><line>Näher, 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ösung hat gebracht,</line><line>in uns're Sündennacht.</line><line>Näher zu Dir!</line></slide></part><part caption="Teil 3"><slide mainsize="42" backgroundnr="0"><line>Näher, 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äher 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ünes Buch 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>

View File

@ -0,0 +1,26 @@
{
"title": "You are so faithful",
"verse_order_list": ["v1", "c1", "v2", "c1", "v3", "c1", "v4"],
"verses": [
[
"You are so faithful\nso faithful, so faithful.\nYou are so faithful\nso faithful, so faithful.",
"v1"
],
[
"That's why I praise you\nin the morning\nThat's why I praise you\nin the noontime.\nThat's why I praise you\nin the evening\nThat's why I praise you\nall the time.",
"c1"
],
[
"You are so loving\nso loving, so loving.\nYou are so loving\nso loving, so loving.",
"v2"
],
[
"You are so caring\nso caring, so caring.\nYou are so caring\nso caring, so caring.",
"v3"
],
[
"You are so mighty\nso mighty, so mighty.\nYou are so mighty\nso mighty, so mighty.",
"v4"
]
]
}

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<ppl version="3.0"><general><title>You are so faithful</title><category>Lobpreis</category><language>Englisch</language></general><songtext><part caption="Strophe 1"><slide mainsize="30" backgroundnr="0"><line>You are so faithful</line><line>so faithful, so faithful.</line><translation>Du bist so treu</translation><translation>so treu, so treu.</translation></slide><slide mainsize="30" backgroundnr="0"><line>You are so faithful</line><line>so faithful, so faithful.</line><translation>Du bist so treu</translation><translation>so treu, so treu.</translation></slide></part><part caption="Refrain"><slide mainsize="30" backgroundnr="0"><line>That's why I praise you</line><line>in the morning</line><line>That's why I praise you</line><line>in the noontime.</line><translation>Deshalb preise ich Dich</translation><translation>am Morgen</translation><translation>Deshalb preise ich Dich</translation><translation>am Mittag.</translation></slide><slide mainsize="30" backgroundnr="0"><line>That's why I praise you</line><line>in the evening</line><line>That's why I praise you</line><line>all the time.</line><translation>Deshalb preise ich Dich</translation><translation>am Abend</translation><translation>Deshalb preise ich Dich</translation><translation>allezeit.</translation></slide></part><part caption="Strophe 2"><slide mainsize="30" backgroundnr="0"><line>You are so loving</line><line>so loving, so loving.</line><translation>Du bist so liebevoll</translation><translation>so liebevoll, so liebevoll.</translation></slide><slide mainsize="30" backgroundnr="0"><line>You are so loving</line><line>so loving, so loving.</line><translation>Du bist so liebevoll</translation><translation>so liebevoll, so liebevoll.</translation></slide></part><part caption="Strophe 3"><slide mainsize="30" backgroundnr="0"><line>You are so caring</line><line>so caring, so caring.</line><translation>Du sorgst so gut</translation><translation>Du kümmerst dich um uns.</translation></slide><slide mainsize="30" backgroundnr="0"><line>You are so caring</line><line>so caring, so caring.</line><translation>Du sorgst so gut</translation><translation>Du kümmerst dich um uns.</translation></slide></part><part caption="Strophe 4"><slide mainsize="30" backgroundnr="0"><line>You are so mighty</line><line>so mighty, so mighty.</line><translation>Du bist so mächtig</translation><translation>so mächtig, so mächtig.</translation></slide><slide mainsize="30" backgroundnr="0"><line>You are so mighty</line><line>so mighty, so mighty.</line><translation>Du bist so mächtig</translation><translation>so mächtig, so mächtig.</translation></slide></part></songtext><order><item>Strophe 1</item><item>Refrain</item><item>Strophe 2</item><item>Refrain</item><item>Strophe 3</item><item>Refrain</item><item>Strophe 4</item></order><information><copyright><position>lastslide</position><text><line>Musik &amp; Copyright unbekannt</line></text></copyright><source><position>firstslide</position><text/></source></information><formatting><font><maintext><name>Tahoma</name><size>30</size><bold>true</bold><italic>false</italic><color>16777215</color><outline>30</outline><shadow>20</shadow></maintext><translationtext><name>Tahoma</name><size>20</size><bold>false</bold><italic>false</italic><color>16777215</color><outline>30</outline><shadow>20</shadow></translationtext><copyrighttext><name>Tahoma</name><size>14</size><bold>false</bold><italic>false</italic><color>16777215</color><outline>30</outline><shadow>20</shadow></copyrighttext><sourcetext><name>Tahoma</name><size>30</size><bold>false</bold><italic>false</italic><color>16777215</color><outline>30</outline><shadow>20</shadow></sourcetext><outline><enabled>true</enabled><color>0</color></outline><shadow><enabled>true</enabled><color>0</color><direction>125</direction></shadow></font><background><file>Blumen\Blume 6.jpg</file></background><linespacing><main>30</main><translation>20</translation></linespacing><textorientation><horizontal>center</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>