Adds DreamBeam song importer.

Small fix for SongShowPlus importer.

bzr-revno: 1955
This commit is contained in:
Philip Ridout 2012-04-25 20:50:08 +02:00 committed by Raoul Snyman
commit 7b99c97174
5 changed files with 218 additions and 12 deletions

View File

@ -46,6 +46,7 @@ class WizardStrings(object):
# the writers translating their own product name. # the writers translating their own product name.
CCLI = u'CCLI/SongSelect' CCLI = u'CCLI/SongSelect'
CSV = u'CSV' CSV = u'CSV'
DB = u'DreamBeam'
EW = u'EasyWorship' EW = u'EasyWorship'
ES = u'EasySlides' ES = u'EasySlides'
FP = u'Foilpresenter' FP = u'Foilpresenter'

View File

@ -129,6 +129,12 @@ class SongImportForm(OpenLPWizard):
QtCore.QObject.connect(self.ccliRemoveButton, QtCore.QObject.connect(self.ccliRemoveButton,
QtCore.SIGNAL(u'clicked()'), QtCore.SIGNAL(u'clicked()'),
self.onCCLIRemoveButtonClicked) 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.QObject.connect(self.songsOfFellowshipAddButton,
QtCore.SIGNAL(u'clicked()'), QtCore.SIGNAL(u'clicked()'),
self.onSongsOfFellowshipAddButtonClicked) self.onSongsOfFellowshipAddButtonClicked)
@ -201,6 +207,8 @@ class SongImportForm(OpenLPWizard):
self.addFileSelectItem(u'generic', None, True) self.addFileSelectItem(u'generic', None, True)
# CCLI File import # CCLI File import
self.addFileSelectItem(u'ccli') self.addFileSelectItem(u'ccli')
# DreamBeam
self.addFileSelectItem(u'dreamBeam')
# EasySlides # EasySlides
self.addFileSelectItem(u'easySlides', single_select=True) self.addFileSelectItem(u'easySlides', single_select=True)
# EasyWorship # EasyWorship
@ -247,6 +255,8 @@ class SongImportForm(OpenLPWizard):
translate('SongsPlugin.ImportWizardForm', translate('SongsPlugin.ImportWizardForm',
'Generic Document/Presentation')) 'Generic Document/Presentation'))
self.formatComboBox.setItemText(SongFormat.CCLI, WizardStrings.CCLI) self.formatComboBox.setItemText(SongFormat.CCLI, WizardStrings.CCLI)
self.formatComboBox.setItemText(
SongFormat.DreamBeam, WizardStrings.DB)
self.formatComboBox.setItemText( self.formatComboBox.setItemText(
SongFormat.EasySlides, WizardStrings.ES) SongFormat.EasySlides, WizardStrings.ES)
self.formatComboBox.setItemText( self.formatComboBox.setItemText(
@ -291,6 +301,10 @@ class SongImportForm(OpenLPWizard):
translate('SongsPlugin.ImportWizardForm', 'Add Files...')) translate('SongsPlugin.ImportWizardForm', 'Add Files...'))
self.ccliRemoveButton.setText( self.ccliRemoveButton.setText(
translate('SongsPlugin.ImportWizardForm', 'Remove File(s)')) 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( self.songsOfFellowshipAddButton.setText(
translate('SongsPlugin.ImportWizardForm', 'Add Files...')) translate('SongsPlugin.ImportWizardForm', 'Add Files...'))
self.songsOfFellowshipRemoveButton.setText( self.songsOfFellowshipRemoveButton.setText(
@ -397,6 +411,12 @@ class SongImportForm(OpenLPWizard):
WizardStrings.YouSpecifyFile % WizardStrings.CCLI) WizardStrings.YouSpecifyFile % WizardStrings.CCLI)
self.ccliAddButton.setFocus() self.ccliAddButton.setFocus()
return False 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: elif source_format == SongFormat.SongsOfFellowship:
if self.songsOfFellowshipFileListWidget.count() == 0: if self.songsOfFellowshipFileListWidget.count() == 0:
critical_error_message_box(UiStrings().NFSp, critical_error_message_box(UiStrings().NFSp,
@ -433,7 +453,7 @@ class SongImportForm(OpenLPWizard):
if self.songShowPlusFileListWidget.count() == 0: if self.songShowPlusFileListWidget.count() == 0:
critical_error_message_box(UiStrings().NFSp, critical_error_message_box(UiStrings().NFSp,
WizardStrings.YouSpecifyFile % WizardStrings.SSP) WizardStrings.YouSpecifyFile % WizardStrings.SSP)
self.wordsOfWorshipAddButton.setFocus() self.songShowPlusAddButton.setFocus()
return False return False
elif source_format == SongFormat.FoilPresenter: elif source_format == SongFormat.FoilPresenter:
if self.foilPresenterFileListWidget.count() == 0: if self.foilPresenterFileListWidget.count() == 0:
@ -564,6 +584,22 @@ class SongImportForm(OpenLPWizard):
""" """
self.removeSelectedItems(self.ccliFileListWidget) 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): def onSongsOfFellowshipAddButtonClicked(self):
""" """
Get Songs of Fellowship song database files Get Songs of Fellowship song database files
@ -680,6 +716,7 @@ class SongImportForm(OpenLPWizard):
self.openSongFileListWidget.clear() self.openSongFileListWidget.clear()
self.wordsOfWorshipFileListWidget.clear() self.wordsOfWorshipFileListWidget.clear()
self.ccliFileListWidget.clear() self.ccliFileListWidget.clear()
self.dreamBeamFileListWidget.clear()
self.songsOfFellowshipFileListWidget.clear() self.songsOfFellowshipFileListWidget.clear()
self.genericFileListWidget.clear() self.genericFileListWidget.clear()
self.easySlidesFilenameEdit.setText(u'') self.easySlidesFilenameEdit.setText(u'')
@ -741,6 +778,12 @@ class SongImportForm(OpenLPWizard):
importer = self.plugin.importSongs(SongFormat.CCLI, importer = self.plugin.importSongs(SongFormat.CCLI,
filenames=self.getListOfFiles(self.ccliFileListWidget) 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: elif source_format == SongFormat.SongsOfFellowship:
# Import a Songs of Fellowship RTF file # Import a Songs of Fellowship RTF file
importer = self.plugin.importSongs(SongFormat.SongsOfFellowship, importer = self.plugin.importSongs(SongFormat.SongsOfFellowship,

View File

@ -0,0 +1,157 @@
# -*- 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">Twas 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)
else:
self.version = 0
# Version numbers found in DreamBeam Source /FileTypes/Song.cs
if self.version >= 0.5:
if hasattr(song_xml, u'Title'):
self.title = unicode(song_xml.Title.text)
if hasattr(song_xml, u'Author'):
author_copyright = 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:
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'):
author_copyright = song_xml.Text2.Text.text
if author_copyright:
author_copyright = unicode(author_copyright)
if author_copyright.find(
unicode(SongStrings.CopyrightSymbol)) >= 0:
self.addCopyright(author_copyright)
else:
self.parseAuthor(author_copyright)
if not self.finish():
self.logError(file)

View File

@ -35,6 +35,7 @@ from olpimport import OpenLPSongImport
from openlyricsimport import OpenLyricsImport from openlyricsimport import OpenLyricsImport
from wowimport import WowImport from wowimport import WowImport
from cclifileimport import CCLIFileImport from cclifileimport import CCLIFileImport
from dreambeamimport import DreamBeamImport
from ewimport import EasyWorshipSongImport from ewimport import EasyWorshipSongImport
from songbeamerimport import SongBeamerImport from songbeamerimport import SongBeamerImport
from songshowplusimport import SongShowPlusImport from songshowplusimport import SongShowPlusImport
@ -73,15 +74,16 @@ class SongFormat(object):
OpenLP1 = 2 OpenLP1 = 2
Generic = 3 Generic = 3
CCLI = 4 CCLI = 4
EasySlides = 5 DreamBeam = 5
EasyWorship = 6 EasySlides = 6
FoilPresenter = 7 EasyWorship = 7
OpenSong = 8 FoilPresenter = 8
SongBeamer = 9 OpenSong = 9
SongShowPlus = 10 SongBeamer = 10
SongsOfFellowship = 11 SongShowPlus = 11
WordsOfWorship = 12 SongsOfFellowship = 12
#CSV = 13 WordsOfWorship = 13
#CSV = 14
@staticmethod @staticmethod
def get_class(format): def get_class(format):
@ -107,6 +109,8 @@ class SongFormat(object):
return OooImport return OooImport
elif format == SongFormat.CCLI: elif format == SongFormat.CCLI:
return CCLIFileImport return CCLIFileImport
elif format == SongFormat.DreamBeam:
return DreamBeamImport
elif format == SongFormat.EasySlides: elif format == SongFormat.EasySlides:
return EasySlidesImport return EasySlidesImport
elif format == SongFormat.EasyWorship: elif format == SongFormat.EasyWorship:
@ -130,6 +134,7 @@ class SongFormat(object):
SongFormat.OpenLP1, SongFormat.OpenLP1,
SongFormat.Generic, SongFormat.Generic,
SongFormat.CCLI, SongFormat.CCLI,
SongFormat.DreamBeam,
SongFormat.EasySlides, SongFormat.EasySlides,
SongFormat.EasyWorship, SongFormat.EasyWorship,
SongFormat.FoilPresenter, SongFormat.FoilPresenter,

View File

@ -25,8 +25,8 @@
# Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Temple Place, Suite 330, Boston, MA 02111-1307 USA #
############################################################################### ###############################################################################
""" """
The :mod:`wowimport` module provides the functionality for importing Words of The :mod:`songshowplusimport` module provides the functionality for importing
Worship songs into the OpenLP database. SongShow Plus songs into the OpenLP database.
""" """
import os import os
import logging import logging