From 201dc353ff2a9a35869c56ff0309ab59f9c4effa Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Tue, 23 Jul 2013 20:30:47 +0100 Subject: [PATCH] Fixed bug 1174039 --- .../plugins/songs/lib/foilpresenterimport.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/openlp/plugins/songs/lib/foilpresenterimport.py b/openlp/plugins/songs/lib/foilpresenterimport.py index fc9afd602..bb22bb52e 100644 --- a/openlp/plugins/songs/lib/foilpresenterimport.py +++ b/openlp/plugins/songs/lib/foilpresenterimport.py @@ -96,6 +96,7 @@ import os from lxml import etree, objectify +from openlp.core.lib import translate from openlp.core.ui.wizard import WizardStrings from openlp.plugins.songs.lib import clean_song, VerseType from openlp.plugins.songs.lib.songimport import SongImport @@ -115,7 +116,7 @@ class FoilPresenterImport(SongImport): """ log.debug(u'initialise FoilPresenterImport') SongImport.__init__(self, manager, **kwargs) - self.FoilPresenter = FoilPresenter(self.manager) + self.FoilPresenter = FoilPresenter(self.manager, self) def doImport(self): """ @@ -202,8 +203,9 @@ class FoilPresenter(object): tag. """ - def __init__(self, manager): + def __init__(self, manager, importer): self.manager = manager + self.importer = importer def xml_to_song(self, xml): """ @@ -222,6 +224,7 @@ class FoilPresenter(object): song.search_lyrics = u'' song.verse_order = u'' song.search_title = u'' + self.skip_song = False # Because "text" seems to be an reserverd word, we have to recompile it. xml = re.compile(u'').sub(u'', xml) xml = re.compile(u'').sub(u'', xml) @@ -236,8 +239,9 @@ class FoilPresenter(object): self._process_authors(foilpresenterfolie, song) self._process_songbooks(foilpresenterfolie, song) self._process_topics(foilpresenterfolie, song) - clean_song(self.manager, song) - self.manager.save_object(song) + if not self.skip_song: + clean_song(self.manager, song) + self.manager.save_object(song) def _child(self, element): """ @@ -424,6 +428,12 @@ class FoilPresenter(object): VerseType.Tags[VerseType.Intro]: 1, VerseType.Tags[VerseType.PreChorus]: 1 } + if not hasattr(foilpresenterfolie.strophen, u'strophe'): + self.importer.logError(self._child(foilpresenterfolie.titel), + unicode(translate('SongsPlugin.FoilPresenterSongImport', + 'Invalid Foilpresenter song file. No verses found.'))) + self.skip_song = True + return for strophe in foilpresenterfolie.strophen.strophe: text = self._child(strophe.text_) if hasattr(strophe, u'text_') \ else u''