New importer for DreamBeam song files.

One small fix to SongShowPlus importer
This commit is contained in:
Philip Ridout 2012-03-24 16:41:29 +00:00
parent b4e8b48c6d
commit b68300bdc6
5 changed files with 207 additions and 12 deletions

View File

@ -46,6 +46,7 @@ class WizardStrings(object):
# 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'

View File

@ -129,6 +129,12 @@ class SongImportForm(OpenLPWizard):
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 @@ class SongImportForm(OpenLPWizard):
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
@ -247,6 +255,8 @@ class SongImportForm(OpenLPWizard):
translate('SongsPlugin.ImportWizardForm',
'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(
@ -291,6 +301,10 @@ class SongImportForm(OpenLPWizard):
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 @@ class SongImportForm(OpenLPWizard):
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 @@ class SongImportForm(OpenLPWizard):
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:
@ -562,6 +582,22 @@ class SongImportForm(OpenLPWizard):
"""
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
@ -671,6 +707,7 @@ class SongImportForm(OpenLPWizard):
self.openSongFileListWidget.clear()
self.wordsOfWorshipFileListWidget.clear()
self.ccliFileListWidget.clear()
self.dreamBeamFileListWidget.clear()
self.songsOfFellowshipFileListWidget.clear()
self.genericFileListWidget.clear()
self.easySlidesFilenameEdit.setText(u'')
@ -732,6 +769,12 @@ class SongImportForm(OpenLPWizard):
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,

View File

@ -0,0 +1,146 @@
# -*- 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, 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 __init__(self, manager, **kwargs):
"""
Initialise the Words of Worship importer.
"""
SongImport.__init__(self, manager, **kwargs)
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)
print song_xml.tag
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'Title'):
self.title = unicode(song_xml.Title.text)
if hasattr(song_xml, u'Author'):
# Dreambeam does not have a copyright field, instead it
# some times uses the author feild
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)
if not self.finish():
self.logError(file)

View File

@ -35,6 +35,7 @@ from olpimport import OpenLPSongImport
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 @@ class SongFormat(object):
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 @@ class SongFormat(object):
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 @@ class SongFormat(object):
SongFormat.OpenLP1,
SongFormat.Generic,
SongFormat.CCLI,
SongFormat.DreamBeam,
SongFormat.EasySlides,
SongFormat.EasyWorship,
SongFormat.FoilPresenter,

View File

@ -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
Song Show Plus songs into the OpenLP database.
"""
import os
import logging