← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~googol-hush/openlp/bug-789143 into lp:openlp

 

Andreas Preikschat has proposed merging lp:~googol-hush/openlp/bug-789143 into lp:openlp.

Requested reviews:
  Jonathan Corwin (j-corwin)
  Tim Bentley (trb143)
Related bugs:
  Bug #789143 in OpenLP: "Verse type is being changed on save in Portuguese"
  https://bugs.launchpad.net/openlp/+bug/789143

For more details, see:
https://code.launchpad.net/~googol-hush/openlp/bug-789143/+merge/62790

Hello,

- "fixed" bug #789143

The "bug" lies in from_loose_input:

        verse_index = None
        if len(verse_name) > 1:
            verse_index = VerseType.from_translated_string(verse_name)
            if verse_index is None:
                verse_index = VerseType.from_string(verse_name)
        if verse_index is None:
            verse_index = VerseType.from_translated_tag(verse_name)
        if verse_index is None:
            verse_index = VerseType.from_tag(verse_name)
        return verse_index

If we pass "e" (Ending) to the method it first tries from_translated_tag (which is wrong). It seems that this causes problems when this method is used with English tags (but using a translated GUI).
-- 
https://code.launchpad.net/~googol-hush/openlp/bug-789143/+merge/62790
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/plugins/songs/lib/__init__.py'
--- openlp/plugins/songs/lib/__init__.py	2011-05-26 17:11:22 +0000
+++ openlp/plugins/songs/lib/__init__.py	2011-05-29 12:05:55 +0000
@@ -265,52 +265,57 @@
     whitespace = re.compile(r'\W+', re.UNICODE)
     song.search_title = (whitespace.sub(u' ', song.title).strip() + u'@' +
         whitespace.sub(u' ', song.alternate_title).strip()).strip().lower()
-    # Remove the old "language" attribute from lyrics tag (prior to 1.9.5). This
-    # is not very important, but this keeps the database clean. This can be
-    # removed when everybody has cleaned his songs.
-    song.lyrics = song.lyrics.replace(u'<lyrics language="en">', u'<lyrics>')
-    verses = SongXML().get_verses(song.lyrics)
-    lyrics = u' '.join([whitespace.sub(u' ', verse[1]) for verse in verses])
-    song.search_lyrics = lyrics.lower()
-    # We need a new and clean SongXML instance.
-    sxml = SongXML()
-    # Rebuild the song's verses, to remove any wrong verse names (for example
-    # translated ones), which might have been added prior to 1.9.5.
-    # List for later comparison.
-    compare_order = []
-    for verse in verses:
-        verse_type = VerseType.Tags[VerseType.from_loose_input(
-            verse[0][u'type'])]
-        sxml.add_verse_to_lyrics(
-            verse_type,
-            verse[0][u'label'],
-            verse[1],
-            verse[0][u'lang'] if verse[0].has_key(u'lang') else None
-        )
-        compare_order.append((u'%s%s' % (verse_type, verse[0][u'label'])
-            ).upper())
-        if verse[0][u'label'] == u'1':
-            compare_order.append(verse_type.upper())
-    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.
-    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])]
-        if len(verse_def) > 1:
-            new_order.append((u'%s%s' % (verse_type, verse_def[1:])).upper())
+    # Only do this, if we the song is a 1.9.4 song (or older).
+    if song.lyrics.find(u'<lyrics language="en">') != -1:
+        # Remove the old "language" attribute from lyrics tag (prior to 1.9.5).
+        # This is not very important, but this keeps the database clean. This
+        # can be removed when everybody has cleaned his songs.
+        song.lyrics = song.lyrics.replace(
+            u'<lyrics language="en">', u'<lyrics>')
+        verses = SongXML().get_verses(song.lyrics)
+        lyrics = u' '.join([whitespace.sub(u' ', verse[1]) for verse in verses])
+        song.search_lyrics = lyrics.lower()
+        # We need a new and clean SongXML instance.
+        sxml = SongXML()
+        # Rebuild the song's verses, to remove any wrong verse names (for
+        # example translated ones), which might have been added prior to 1.9.5.
+        # List for later comparison.
+        compare_order = []
+        for verse in verses:
+            verse_type = VerseType.Tags[VerseType.from_loose_input(
+                verse[0][u'type'])]
+            sxml.add_verse_to_lyrics(
+                verse_type,
+                verse[0][u'label'],
+                verse[1],
+                verse[0][u'lang'] if verse[0].has_key(u'lang') else None
+            )
+            compare_order.append((u'%s%s' % (verse_type, verse[0][u'label'])
+                ).upper())
+            if verse[0][u'label'] == u'1':
+                compare_order.append(verse_type.upper())
+        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.
+        if song.verse_order:
+            order = song.verse_order.strip().split()
         else:
-            new_order.append(verse_type.upper())
-    song.verse_order = u' '.join(new_order)
-    # Check if the verse order contains tags for verses which do not exist.
-    for order in new_order:
-        if order not in compare_order:
-            song.verse_order = u''
-            break
+            order = []
+        new_order = []
+        for verse_def in order:
+            verse_type = VerseType.Tags[
+                VerseType.from_loose_input(verse_def[0])]
+            if len(verse_def) > 1:
+                new_order.append(
+                    (u'%s%s' % (verse_type, verse_def[1:])).upper())
+            else:
+                new_order.append(verse_type.upper())
+        song.verse_order = u' '.join(new_order)
+        # Check if the verse order contains tags for verses which do not exist.
+        for order in new_order:
+            if order not in compare_order:
+                song.verse_order = u''
+                break
     # The song does not have any author, add one.
     if not song.authors:
         name = SongStrings.AuthorUnknown


Follow ups