← Back to team overview

openlp-core team mailing list archive

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

 

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

Requested reviews:
  OpenLP Core (openlp-core)

For more details, see:
https://code.launchpad.net/~googol-hush/openlp/OpenLyrics/+merge/53899

Hello

- fixed adding "Verse" instead of "v" to the database.
- add "other" if the verse_tag is unknown
-- 
https://code.launchpad.net/~googol-hush/openlp/OpenLyrics/+merge/53899
Your team OpenLP Core is requested to review the proposed merge of lp:~googol-hush/openlp/OpenLyrics into lp:openlp.
=== modified file 'openlp/plugins/songs/lib/xml.py'
--- openlp/plugins/songs/lib/xml.py	2011-03-15 18:24:13 +0000
+++ openlp/plugins/songs/lib/xml.py	2011-03-17 20:49:19 +0000
@@ -89,8 +89,8 @@
         Add a verse to the ``<lyrics>`` tag.
 
         ``type``
-            A string denoting the type of verse. Possible values are *Verse*,
-            *Chorus*, *Bridge*, *Pre-Chorus*, *Intro*, *Ending* and *Other*.
+            A string denoting the type of verse. Possible values are *v*,
+            *c*, *b*, *p*, *i*, *e* and *o*.
             Any other type is **not** allowed, this also includes translated
             types.
 
@@ -128,8 +128,8 @@
 
         The returned list has the following format::
 
-            [[{'lang': 'en', 'type': 'Verse', 'label': '1'}, u"English verse"],
-            [{'lang': 'en', 'type': 'Chorus', 'label': '1'}, u"English chorus"]]
+            [[{'lang': 'en', 'type': 'v', 'label': '1'}, u"English verse"],
+            [{'lang': 'en', 'type': 'c', 'label': '1'}, u"English chorus"]]
         """
         self.song_xml = None
         if xml[:5] == u'<?xml':
@@ -451,10 +451,12 @@
                 if text:
                     text += u'\n'
                 text += u'\n'.join([unicode(line) for line in lines.line])
-            verse_name = self._get(verse, u'name')
-            verse_type_index = VerseType.from_tag(verse_name[0])
-            verse_type = VerseType.Names[verse_type_index]
-            verse_number = re.compile(u'[a-zA-Z]*').sub(u'', verse_name)
+            verse_def = self._get(verse, u'name').lower()
+            if verse_def[0] in VerseType.Tags:
+                verse_tag = verse_def[0]
+            else:
+                verse_tag = VerseType.Tags[VerseType.Other]
+            verse_number = re.compile(u'[a-zA-Z]*').sub(u'', verse_def)
             # OpenLyrics allows e. g. "c", but we need "c1". However, this does
             # not correct the verse order.
             if not verse_number:
@@ -462,7 +464,7 @@
             lang = None
             if self._get(verse, u'lang'):
                 lang = self._get(verse, u'lang')
-            sxml.add_verse_to_lyrics(verse_type, verse_number, text, lang)
+            sxml.add_verse_to_lyrics(verse_tag, verse_number, text, lang)
         song.lyrics = unicode(sxml.extract_xml(), u'utf-8')
         # Process verse order
         if hasattr(properties, u'verseOrder'):


Follow ups