From 7f1db15ab174f213e42db5a44a6f004e47163d3f Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Fri, 29 Apr 2011 01:25:28 +0200 Subject: [PATCH 1/2] Fixed bug #771529, dealing with 1.9.0 databases. --- openlp/plugins/songs/lib/__init__.py | 5 ++++- openlp/plugins/songs/lib/xml.py | 16 ++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/openlp/plugins/songs/lib/__init__.py b/openlp/plugins/songs/lib/__init__.py index 249a76a38..f9a160e55 100644 --- a/openlp/plugins/songs/lib/__init__.py +++ b/openlp/plugins/songs/lib/__init__.py @@ -293,7 +293,10 @@ def clean_song(manager, song): song.lyrics = unicode(sxml.extract_xml(), u'utf-8') # Rebuild the verse order, to convert translated verse tags, which might # have been added prior to 1.9.5. - order = song.verse_order.strip().split() + if song.verse_order: + order = song.verse_order.strip().split() + else: + order = [] new_order = [] for verse_def in order: verse_type = VerseType.Tags[VerseType.from_loose_input(verse_def[0])] diff --git a/openlp/plugins/songs/lib/xml.py b/openlp/plugins/songs/lib/xml.py index 87e28591e..f2fd897d9 100644 --- a/openlp/plugins/songs/lib/xml.py +++ b/openlp/plugins/songs/lib/xml.py @@ -133,14 +133,26 @@ class SongXML(object): [{'lang': 'en', 'type': 'c', 'label': '1'}, u"English chorus"]] """ self.song_xml = None - if xml[:5] == u'') + self.lyrics = etree.SubElement(self.song_xml, u'lyrics') + verses = xml.split(u'\n\n') + for count, verse in enumerate(verses): + verse_list.append([{u'type': u'v', u'label': unicode(count)}, + unicode(verse)]) + self.add_verse_to_lyrics(u'v', unicode(count), verse) + return verse_list + elif xml[:5] == u' Date: Fri, 29 Apr 2011 08:28:09 +0200 Subject: [PATCH 2/2] Changed [:] notation to .startswith(). --- openlp/plugins/songs/lib/xml.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/songs/lib/xml.py b/openlp/plugins/songs/lib/xml.py index f2fd897d9..1c20b23a5 100644 --- a/openlp/plugins/songs/lib/xml.py +++ b/openlp/plugins/songs/lib/xml.py @@ -146,7 +146,7 @@ class SongXML(object): unicode(verse)]) self.add_verse_to_lyrics(u'v', unicode(count), verse) return verse_list - elif xml[:5] == u'