From b68300bdc66f39d9f217270c020d8ce8e7b04719 Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Sat, 24 Mar 2012 16:41:29 +0000 Subject: [PATCH 01/25] New importer for DreamBeam song files. One small fix to SongShowPlus importer --- openlp/core/ui/wizard.py | 1 + openlp/plugins/songs/forms/songimportform.py | 45 +++++- openlp/plugins/songs/lib/dreambeamimport.py | 146 ++++++++++++++++++ openlp/plugins/songs/lib/importer.py | 23 +-- .../plugins/songs/lib/songshowplusimport.py | 4 +- 5 files changed, 207 insertions(+), 12 deletions(-) create mode 100644 openlp/plugins/songs/lib/dreambeamimport.py diff --git a/openlp/core/ui/wizard.py b/openlp/core/ui/wizard.py index 91aa42e43..004494b9a 100644 --- a/openlp/core/ui/wizard.py +++ b/openlp/core/ui/wizard.py @@ -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' diff --git a/openlp/plugins/songs/forms/songimportform.py b/openlp/plugins/songs/forms/songimportform.py index db4d9bf56..3323f5cbb 100644 --- a/openlp/plugins/songs/forms/songimportform.py +++ b/openlp/plugins/songs/forms/songimportform.py @@ -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, diff --git a/openlp/plugins/songs/lib/dreambeamimport.py b/openlp/plugins/songs/lib/dreambeamimport.py new file mode 100644 index 000000000..1b7d5c4bd --- /dev/null +++ b/openlp/plugins/songs/lib/dreambeamimport.py @@ -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: + + + + false + 0.80 + Amazing Grace + John Newton + + + + F + G + false + false + + 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. + 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. + + + + + + false + + + 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) diff --git a/openlp/plugins/songs/lib/importer.py b/openlp/plugins/songs/lib/importer.py index 867b28c91..ea13c5065 100644 --- a/openlp/plugins/songs/lib/importer.py +++ b/openlp/plugins/songs/lib/importer.py @@ -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, diff --git a/openlp/plugins/songs/lib/songshowplusimport.py b/openlp/plugins/songs/lib/songshowplusimport.py index aba2f6d05..d7317ff9f 100644 --- a/openlp/plugins/songs/lib/songshowplusimport.py +++ b/openlp/plugins/songs/lib/songshowplusimport.py @@ -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 From a75102a868f44f7fc781d6e9410111e29b63d366 Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Sat, 24 Mar 2012 18:20:19 +0000 Subject: [PATCH 02/25] Removed errant print statment --- openlp/plugins/songs/lib/dreambeamimport.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openlp/plugins/songs/lib/dreambeamimport.py b/openlp/plugins/songs/lib/dreambeamimport.py index 1b7d5c4bd..b43b2cf8b 100644 --- a/openlp/plugins/songs/lib/dreambeamimport.py +++ b/openlp/plugins/songs/lib/dreambeamimport.py @@ -110,7 +110,6 @@ class DreamBeamImport(SongImport): 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', From 5925fb624ec48d16db7c132b67decc2bc249762b Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Sun, 25 Mar 2012 18:25:08 +0100 Subject: [PATCH 03/25] Changed Restructured text layout --- openlp/plugins/songs/lib/dreambeamimport.py | 64 ++++++++++----------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/openlp/plugins/songs/lib/dreambeamimport.py b/openlp/plugins/songs/lib/dreambeamimport.py index b43b2cf8b..ecd0d7c79 100644 --- a/openlp/plugins/songs/lib/dreambeamimport.py +++ b/openlp/plugins/songs/lib/dreambeamimport.py @@ -47,42 +47,42 @@ class DreamBeamImport(SongImport): The :class:`DreamBeamImport` class provides the ability to import song files from DreamBeam. - An example of DreamBeam xml mark-up: + An example of DreamBeam xml mark-up:: - - - false - 0.80 - Amazing Grace - John Newton - - - - F - G - false - false - - 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. - 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. - - - - - - false - + + + false + 0.80 + Amazing Grace + John Newton + + + + F + G + false + false + + 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. + 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. + + + + + + false + Valid extensions for a DreamBeam song file are: - * .xml + * \*.xml """ def __init__(self, manager, **kwargs): From 7260dee1d63eefaf9ab3014a6fca74886d9182a4 Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Tue, 27 Mar 2012 21:09:01 +0100 Subject: [PATCH 04/25] Made changes as to Jonathan's requests --- openlp/plugins/songs/lib/dreambeamimport.py | 11 ++++------- openlp/plugins/songs/lib/songshowplusimport.py | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/openlp/plugins/songs/lib/dreambeamimport.py b/openlp/plugins/songs/lib/dreambeamimport.py index ecd0d7c79..381beb033 100644 --- a/openlp/plugins/songs/lib/dreambeamimport.py +++ b/openlp/plugins/songs/lib/dreambeamimport.py @@ -31,15 +31,12 @@ DreamBeam songs into the OpenLP database. import os, sys import logging -from lxml import etree, objectify +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): @@ -87,7 +84,7 @@ class DreamBeamImport(SongImport): def __init__(self, manager, **kwargs): """ - Initialise the Words of Worship importer. + Initialise the DreamBeam importer. """ SongImport.__init__(self, manager, **kwargs) @@ -119,8 +116,8 @@ class DreamBeamImport(SongImport): 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 + # DreamBeam does not have a copyright field, instead it + # some times uses the author field self.addCopyright(unicode(song_xml.Author.text)) self.parseAuthor(unicode(song_xml.Author.text)) if hasattr(song_xml, u'SongLyrics'): diff --git a/openlp/plugins/songs/lib/songshowplusimport.py b/openlp/plugins/songs/lib/songshowplusimport.py index d7317ff9f..8d2af5514 100644 --- a/openlp/plugins/songs/lib/songshowplusimport.py +++ b/openlp/plugins/songs/lib/songshowplusimport.py @@ -26,7 +26,7 @@ ############################################################################### """ The :mod:`songshowplusimport` module provides the functionality for importing -Song Show Plus songs into the OpenLP database. +SongShow Plus songs into the OpenLP database. """ import os import logging From e6af8d8bef5b2efcb35a05803eeaa2d9026eb34f Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Thu, 29 Mar 2012 19:37:05 +0100 Subject: [PATCH 05/25] Remove constructor as per Raouls comment. --- openlp/plugins/songs/lib/dreambeamimport.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/openlp/plugins/songs/lib/dreambeamimport.py b/openlp/plugins/songs/lib/dreambeamimport.py index 381beb033..569f0006a 100644 --- a/openlp/plugins/songs/lib/dreambeamimport.py +++ b/openlp/plugins/songs/lib/dreambeamimport.py @@ -81,13 +81,7 @@ class DreamBeamImport(SongImport): * \*.xml """ - - def __init__(self, manager, **kwargs): - """ - Initialise the DreamBeam importer. - """ - SongImport.__init__(self, manager, **kwargs) - + def doImport(self): """ Receive a single file or a list of files to import. From 4ce95e9d5630c2d69a7fb40f2fbdd08292b3dd82 Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Fri, 30 Mar 2012 22:52:50 +0100 Subject: [PATCH 06/25] Made changes as per Andreas comments. --- openlp/plugins/songs/lib/dreambeamimport.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/songs/lib/dreambeamimport.py b/openlp/plugins/songs/lib/dreambeamimport.py index 569f0006a..68868baa1 100644 --- a/openlp/plugins/songs/lib/dreambeamimport.py +++ b/openlp/plugins/songs/lib/dreambeamimport.py @@ -28,7 +28,8 @@ The :mod:`dreambeamimport` module provides the functionality for importing DreamBeam songs into the OpenLP database. """ -import os, sys +import os +import sys import logging from lxml import etree, objectify @@ -111,7 +112,7 @@ class DreamBeamImport(SongImport): 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 field + # 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'): From 9c11494364b1b5d4a6a41f11ff94bdc93e622cd7 Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Sat, 7 Apr 2012 17:41:03 +0100 Subject: [PATCH 07/25] Added support for ALL DreamBeam file formats. --- openlp/plugins/songs/lib/dreambeamimport.py | 72 ++++++++++++++------- 1 file changed, 47 insertions(+), 25 deletions(-) diff --git a/openlp/plugins/songs/lib/dreambeamimport.py b/openlp/plugins/songs/lib/dreambeamimport.py index 68868baa1..d5373cf39 100644 --- a/openlp/plugins/songs/lib/dreambeamimport.py +++ b/openlp/plugins/songs/lib/dreambeamimport.py @@ -108,30 +108,52 @@ class DreamBeamImport(SongImport): ('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 - # 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) + 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) From 20eab8b9178678bd24e1c99b9938146833e98ee7 Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Sat, 7 Apr 2012 20:47:41 +0100 Subject: [PATCH 08/25] Fixed case when there is no version information --- openlp/plugins/songs/lib/dreambeamimport.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/openlp/plugins/songs/lib/dreambeamimport.py b/openlp/plugins/songs/lib/dreambeamimport.py index d5373cf39..6d8e994c8 100644 --- a/openlp/plugins/songs/lib/dreambeamimport.py +++ b/openlp/plugins/songs/lib/dreambeamimport.py @@ -110,6 +110,13 @@ class DreamBeamImport(SongImport): continue if hasattr(song_xml, u'Version'): self.version = float(song_xml.Version.text) + else: + log.exception(u'No valid version information.' + 'Invalid file %s' % file) + self.logError(file, unicode( + translate('SongsPlugin.DreamBeamImport', + ('No valid version information.')))) + continue # Version numbers found in DreamBeam Source /FileTypes/Song.cs if self.version <= 0.49: if hasattr(song_xml.Text0, u'Text'): @@ -150,10 +157,5 @@ class DreamBeamImport(SongImport): 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) From be3da3368e04bd75925de71cfe5cfccc00e03a8e Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Fri, 13 Apr 2012 21:22:55 +0100 Subject: [PATCH 09/25] changed file version handeling. Added check for (c) symbol if not use it for the author --- openlp/plugins/songs/lib/dreambeamimport.py | 43 ++++++++++----------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/openlp/plugins/songs/lib/dreambeamimport.py b/openlp/plugins/songs/lib/dreambeamimport.py index 6d8e994c8..da649bba9 100644 --- a/openlp/plugins/songs/lib/dreambeamimport.py +++ b/openlp/plugins/songs/lib/dreambeamimport.py @@ -31,6 +31,7 @@ DreamBeam songs into the OpenLP database. import os import sys import logging +import types from lxml import etree, objectify @@ -111,33 +112,13 @@ class DreamBeamImport(SongImport): if hasattr(song_xml, u'Version'): self.version = float(song_xml.Version.text) else: - log.exception(u'No valid version information.' - 'Invalid file %s' % file) - self.logError(file, unicode( - translate('SongsPlugin.DreamBeamImport', - ('No valid version information.')))) - continue + self.version = 0 # 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 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)) + 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') @@ -157,5 +138,21 @@ class DreamBeamImport(SongImport): 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) From 0fdf3b7f7c050d63e7e5481c64474dbf51ec23ee Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 16 Apr 2012 09:02:24 +0200 Subject: [PATCH 10/25] trivial clean ups --- openlp/core/lib/renderer.py | 2 +- openlp/core/lib/settingsmanager.py | 4 +- openlp/plugins/bibles/bibleplugin.py | 7 +- openlp/plugins/presentations/lib/mediaitem.py | 78 +++++++++---------- .../presentations/presentationplugin.py | 5 +- 5 files changed, 45 insertions(+), 51 deletions(-) diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index 8da5967a1..cb5b1a5a5 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -364,7 +364,7 @@ class Renderer(object): self.web.setVisible(False) self.web.resize(self.page_width, self.page_height) self.web_frame = self.web.page().mainFrame() - # Adjust width and height to account for shadow. outline done in css + # Adjust width and height to account for shadow. outline done in css. html = u"""