← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~phill-ridout/openlp/1174039_2.0 into lp:openlp/2.0

 

Phill has proposed merging lp:~phill-ridout/openlp/1174039_2.0 into lp:openlp/2.0.

Requested reviews:
  Tim Bentley (trb143)
Related bugs:
  Bug #1174039 in OpenLP: "Foil Presenter Importer fails if no verses"
  https://bugs.launchpad.net/openlp/+bug/1174039

For more details, see:
https://code.launchpad.net/~phill-ridout/openlp/1174039_2.0/+merge/176772

changed skip_song to save_song & changed logic round
-- 
https://code.launchpad.net/~phill-ridout/openlp/1174039_2.0/+merge/176772
Your team OpenLP Core is subscribed to branch lp:openlp/2.0.
=== modified file 'openlp/plugins/songs/lib/foilpresenterimport.py'
--- openlp/plugins/songs/lib/foilpresenterimport.py	2012-12-30 19:41:24 +0000
+++ openlp/plugins/songs/lib/foilpresenterimport.py	2013-07-24 20:07:31 +0000
@@ -96,6 +96,7 @@
 
 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 @@
         """
         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 @@
         <copyright> 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 @@
         song.search_lyrics = u''
         song.verse_order = u''
         song.search_title = u''
+        self.save_song = True
         # Because "text" seems to be an reserverd word, we have to recompile it.
         xml = re.compile(u'<text>').sub(u'<text_>', xml)
         xml = re.compile(u'</text>').sub(u'</text_>', xml)
@@ -236,8 +239,9 @@
         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 self.save_song:
+            clean_song(self.manager, song)
+            self.manager.save_object(song)
 
     def _child(self, element):
         """
@@ -424,6 +428,12 @@
             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.save_song = False
+            return
         for strophe in foilpresenterfolie.strophen.strophe:
             text = self._child(strophe.text_) if hasattr(strophe, u'text_') \
                 else u''


Follow ups