openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #15143
[Merge] lp:~phill-ridout/openlp/DreamBeam into lp:openlp
phill has proposed merging lp:~phill-ridout/openlp/DreamBeam into lp:openlp.
Requested reviews:
Raoul Snyman (raoul-snyman)
Andreas Preikschat (googol)
Jonathan Corwin (j-corwin)
For more details, see:
https://code.launchpad.net/~phill-ridout/openlp/DreamBeam/+merge/101183
Adds DreamBeam song importer.
Small fix for SongShowPlus importer.
Removed errant print statment
Fixed doc string
Removed constructor
Added support for all DreamBeam files
--
https://code.launchpad.net/~phill-ridout/openlp/DreamBeam/+merge/101183
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/core/ui/wizard.py'
--- openlp/core/ui/wizard.py 2012-04-01 22:44:09 +0000
+++ openlp/core/ui/wizard.py 2012-04-07 17:00:33 +0000
@@ -46,6 +46,7 @@
# the writers translating their own product name.
CCLI = u'CCLI/SongSelect'
CSV = u'CSV'
+ DB = u'DreamBeam'
EW = u'EasyWorship'
ES = u'EasySlides'
FP = u'Foilpresenter'
=== modified file 'openlp/plugins/songs/forms/songimportform.py'
--- openlp/plugins/songs/forms/songimportform.py 2012-03-29 19:03:01 +0000
+++ openlp/plugins/songs/forms/songimportform.py 2012-04-07 17:00:33 +0000
@@ -129,6 +129,12 @@
QtCore.QObject.connect(self.ccliRemoveButton,
QtCore.SIGNAL(u'clicked()'),
self.onCCLIRemoveButtonClicked)
+ QtCore.QObject.connect(self.dreamBeamAddButton,
+ QtCore.SIGNAL(u'clicked()'),
+ self.onDreamBeamAddButtonClicked)
+ QtCore.QObject.connect(self.dreamBeamRemoveButton,
+ QtCore.SIGNAL(u'clicked()'),
+ self.onDreamBeamRemoveButtonClicked)
QtCore.QObject.connect(self.songsOfFellowshipAddButton,
QtCore.SIGNAL(u'clicked()'),
self.onSongsOfFellowshipAddButtonClicked)
@@ -201,6 +207,8 @@
self.addFileSelectItem(u'generic', None, True)
# CCLI File import
self.addFileSelectItem(u'ccli')
+ # DreamBeam
+ self.addFileSelectItem(u'dreamBeam')
# EasySlides
self.addFileSelectItem(u'easySlides', single_select=True)
# EasyWorship
@@ -248,6 +256,8 @@
'Generic Document/Presentation'))
self.formatComboBox.setItemText(SongFormat.CCLI, WizardStrings.CCLI)
self.formatComboBox.setItemText(
+ SongFormat.DreamBeam, WizardStrings.DB)
+ self.formatComboBox.setItemText(
SongFormat.EasySlides, WizardStrings.ES)
self.formatComboBox.setItemText(
SongFormat.EasyWorship, WizardStrings.EW)
@@ -291,6 +301,10 @@
translate('SongsPlugin.ImportWizardForm', 'Add Files...'))
self.ccliRemoveButton.setText(
translate('SongsPlugin.ImportWizardForm', 'Remove File(s)'))
+ self.dreamBeamAddButton.setText(
+ translate('SongsPlugin.ImportWizardForm', 'Add Files...'))
+ self.dreamBeamRemoveButton.setText(
+ translate('SongsPlugin.ImportWizardForm', 'Remove File(s)'))
self.songsOfFellowshipAddButton.setText(
translate('SongsPlugin.ImportWizardForm', 'Add Files...'))
self.songsOfFellowshipRemoveButton.setText(
@@ -397,6 +411,12 @@
WizardStrings.YouSpecifyFile % WizardStrings.CCLI)
self.ccliAddButton.setFocus()
return False
+ elif source_format == SongFormat.DreamBeam:
+ if self.dreamBeamFileListWidget.count() == 0:
+ critical_error_message_box(UiStrings().NFSp,
+ WizardStrings.YouSpecifyFile % WizardStrings.DB)
+ self.dreamBeamAddButton.setFocus()
+ return False
elif source_format == SongFormat.SongsOfFellowship:
if self.songsOfFellowshipFileListWidget.count() == 0:
critical_error_message_box(UiStrings().NFSp,
@@ -433,7 +453,7 @@
if self.songShowPlusFileListWidget.count() == 0:
critical_error_message_box(UiStrings().NFSp,
WizardStrings.YouSpecifyFile % WizardStrings.SSP)
- self.wordsOfWorshipAddButton.setFocus()
+ self.songShowPlusAddButton.setFocus()
return False
elif source_format == SongFormat.FoilPresenter:
if self.foilPresenterFileListWidget.count() == 0:
@@ -564,6 +584,22 @@
"""
self.removeSelectedItems(self.ccliFileListWidget)
+ def onDreamBeamAddButtonClicked(self):
+ """
+ Get DreamBeam song database files
+ """
+ self.getFiles(WizardStrings.OpenTypeFile % WizardStrings.DB,
+ self.dreamBeamFileListWidget, u'%s (*.xml)'
+ % translate('SongsPlugin.ImportWizardForm',
+ 'DreamBeam Song Files')
+ )
+
+ def onDreamBeamRemoveButtonClicked(self):
+ """
+ Remove selected DreamBeam files from the import list
+ """
+ self.removeSelectedItems(self.dreamBeamFileListWidget)
+
def onSongsOfFellowshipAddButtonClicked(self):
"""
Get Songs of Fellowship song database files
@@ -680,6 +716,7 @@
self.openSongFileListWidget.clear()
self.wordsOfWorshipFileListWidget.clear()
self.ccliFileListWidget.clear()
+ self.dreamBeamFileListWidget.clear()
self.songsOfFellowshipFileListWidget.clear()
self.genericFileListWidget.clear()
self.easySlidesFilenameEdit.setText(u'')
@@ -741,6 +778,12 @@
importer = self.plugin.importSongs(SongFormat.CCLI,
filenames=self.getListOfFiles(self.ccliFileListWidget)
)
+ elif source_format == SongFormat.DreamBeam:
+ # Import DreamBeam songs
+ importer = self.plugin.importSongs(SongFormat.DreamBeam,
+ filenames=self.getListOfFiles(
+ self.dreamBeamFileListWidget)
+ )
elif source_format == SongFormat.SongsOfFellowship:
# Import a Songs of Fellowship RTF file
importer = self.plugin.importSongs(SongFormat.SongsOfFellowship,
=== added file 'openlp/plugins/songs/lib/dreambeamimport.py'
--- openlp/plugins/songs/lib/dreambeamimport.py 1970-01-01 00:00:00 +0000
+++ openlp/plugins/songs/lib/dreambeamimport.py 2012-04-07 17:00:33 +0000
@@ -0,0 +1,159 @@
+# -*- coding: utf-8 -*-
+# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
+
+###############################################################################
+# OpenLP - Open Source Lyrics Projection #
+# --------------------------------------------------------------------------- #
+# Copyright (c) 2008-2012 Raoul Snyman #
+# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan #
+# Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, #
+# Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias #
+# Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, #
+# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Frode Woldsund #
+# --------------------------------------------------------------------------- #
+# 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:`dreambeamimport` module provides the functionality for importing
+DreamBeam songs into the OpenLP database.
+"""
+import os
+import sys
+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.ui import SongStrings
+
+log = logging.getLogger(__name__)
+
+class DreamBeamImport(SongImport):
+ """
+ The :class:`DreamBeamImport` class provides the ability to import song files from
+ DreamBeam.
+
+ An example of DreamBeam xml mark-up::
+
+ <?xml version="1.0"?>
+ <DreamSong xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <WordWrap>false</WordWrap>
+ <Version>0.80</Version>
+ <Title>Amazing Grace</Title>
+ <Author>John Newton</Author>
+ <Collection />
+ <Number />
+ <Notes />
+ <KeyRangeLow>F</KeyRangeLow>
+ <KeyRangeHigh>G</KeyRangeHigh>
+ <MinorKey>false</MinorKey>
+ <DualLanguage>false</DualLanguage>
+ <SongLyrics>
+ <LyricsItem Type="Verse" Number="1">Amazing Grace, how sweet the sound,
+ That saved a wretch like me.
+ I once was lost but now am found,
+ Was blind, but now, I see.</LyricsItem>
+ <LyricsItem Type="Verse" Number="2">T’was Grace that taught my heart to fear.
+ And Grace, my fears relieved.
+ How precious did that Grace appear…
+ the hour I first believed.</LyricsItem>
+ </SongLyrics>
+ <Sequence>
+ <LyricsSequenceItem Type="Verse" Number="1" />
+ <LyricsSequenceItem Type="Verse" Number="2" />
+ </Sequence>
+ <ShowRectangles>false</ShowRectangles>
+ </DreamSong>
+
+ Valid extensions for a DreamBeam song file are:
+
+ * \*.xml
+ """
+
+ def doImport(self):
+ """
+ Receive a single file or a list of files to import.
+ """
+ if isinstance(self.importSource, list):
+ self.importWizard.progressBar.setMaximum(len(self.importSource))
+ for file in self.importSource:
+ if self.stopImportFlag:
+ return
+ self.setDefaults()
+ parser = etree.XMLParser(remove_blank_text=True)
+ try:
+ parsed_file = etree.parse(open(file, u'r'), parser)
+ except etree.XMLSyntaxError:
+ log.exception(u'XML syntax error in file %s' % file)
+ self.logError(file, SongStrings.XMLSyntaxError)
+ continue
+ xml = unicode(etree.tostring(parsed_file))
+ song_xml = objectify.fromstring(xml)
+ if song_xml.tag != u'DreamSong':
+ self.logError(file, unicode(
+ translate('SongsPlugin.DreamBeamImport',
+ ('Invalid DreamBeam song file. Missing '
+ 'DreamSong tag.'))))
+ continue
+ if hasattr(song_xml, u'Version'):
+ self.version = float(song_xml.Version.text)
+ # Version numbers found in DreamBeam Source /FileTypes/Song.cs
+ if self.version <= 0.49:
+ if hasattr(song_xml.Text0, u'Text'):
+ self.title = unicode(song_xml.Text0.Text.text)
+ if hasattr(song_xml.Text1, u'Text'):
+ self.lyrics = unicode(song_xml.Text1.Text.text)
+ for verse in self.lyrics.split(u'\n\n\n'):
+ self.addVerse(verse)
+ if hasattr(song_xml.Text2, u'Text'):
+ # DreamBeam does not have a copyright field, instead it
+ # sometimes uses the author field
+ self.addCopyright(unicode(song_xml.Text2.Text.text))
+ self.parseAuthor(unicode(song_xml.Text2.Text.text))
+ elif self.version >= 0.5:
+ if hasattr(song_xml, u'Title'):
+ self.title = unicode(song_xml.Title.text)
+ if hasattr(song_xml, u'Author'):
+ # DreamBeam does not have a copyright field, instead it
+ # sometimes uses the author field
+ self.addCopyright(unicode(song_xml.Author.text))
+ self.parseAuthor(unicode(song_xml.Author.text))
+ if hasattr(song_xml, u'SongLyrics'):
+ for lyrics_item in song_xml.SongLyrics.iterchildren():
+ verse_type = lyrics_item.get(u'Type')
+ verse_number = lyrics_item.get(u'Number')
+ verse_text = unicode(lyrics_item.text)
+ self.addVerse(verse_text,
+ (u'%s%s' % (verse_type[:1], verse_number)))
+ if hasattr(song_xml, u'Collection'):
+ self.songBookName = unicode(song_xml.Collection.text)
+ if hasattr(song_xml, u'Number'):
+ self.songNumber = unicode(song_xml.Number.text)
+ if hasattr(song_xml, u'Sequence'):
+ for LyricsSequenceItem in (
+ song_xml.Sequence.iterchildren()):
+ self.verseOrderList.append(
+ "%s%s" % (LyricsSequenceItem.get(u'Type')[:1],
+ LyricsSequenceItem.get(u'Number')))
+ if hasattr(song_xml, u'Notes'):
+ self.comments = unicode(song_xml.Notes.text)
+ else:
+ log.exception(u'No valid version information.'
+ 'Invalid file %s' % file)
+ self.logError(file, SongStrings.XMLSyntaxError)
+ continue
+ if not self.finish():
+ self.logError(file)
=== modified file 'openlp/plugins/songs/lib/importer.py'
--- openlp/plugins/songs/lib/importer.py 2012-04-04 07:26:51 +0000
+++ openlp/plugins/songs/lib/importer.py 2012-04-07 17:00:33 +0000
@@ -35,6 +35,7 @@
from openlyricsimport import OpenLyricsImport
from wowimport import WowImport
from cclifileimport import CCLIFileImport
+from dreambeamimport import DreamBeamImport
from ewimport import EasyWorshipSongImport
from songbeamerimport import SongBeamerImport
from songshowplusimport import SongShowPlusImport
@@ -73,15 +74,16 @@
OpenLP1 = 2
Generic = 3
CCLI = 4
- EasySlides = 5
- EasyWorship = 6
- FoilPresenter = 7
- OpenSong = 8
- SongBeamer = 9
- SongShowPlus = 10
- SongsOfFellowship = 11
- WordsOfWorship = 12
- #CSV = 13
+ DreamBeam = 5
+ EasySlides = 6
+ EasyWorship = 7
+ FoilPresenter = 8
+ OpenSong = 9
+ SongBeamer = 10
+ SongShowPlus = 11
+ SongsOfFellowship = 12
+ WordsOfWorship = 13
+ #CSV = 14
@staticmethod
def get_class(format):
@@ -107,6 +109,8 @@
return OooImport
elif format == SongFormat.CCLI:
return CCLIFileImport
+ elif format == SongFormat.DreamBeam:
+ return DreamBeamImport
elif format == SongFormat.EasySlides:
return EasySlidesImport
elif format == SongFormat.EasyWorship:
@@ -130,6 +134,7 @@
SongFormat.OpenLP1,
SongFormat.Generic,
SongFormat.CCLI,
+ SongFormat.DreamBeam,
SongFormat.EasySlides,
SongFormat.EasyWorship,
SongFormat.FoilPresenter,
=== modified file 'openlp/plugins/songs/lib/songshowplusimport.py'
--- openlp/plugins/songs/lib/songshowplusimport.py 2011-12-27 10:33:55 +0000
+++ openlp/plugins/songs/lib/songshowplusimport.py 2012-04-07 17:00:33 +0000
@@ -25,8 +25,8 @@
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
"""
-The :mod:`wowimport` module provides the functionality for importing Words of
-Worship songs into the OpenLP database.
+The :mod:`songshowplusimport` module provides the functionality for importing
+SongShow Plus songs into the OpenLP database.
"""
import os
import logging
Follow ups