← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~j-corwin/openlp/general into lp:openlp

 

Jonathan Corwin has proposed merging lp:~j-corwin/openlp/general into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)
Related bugs:
  Bug #634771 in OpenLP: "OpenLP 1.9.2+bzr1016-0ubuntu1~lucid1 does not start"
  https://bugs.launchpad.net/openlp/+bug/634771
  Bug #646718 in OpenLP: "Songbook, Number will not loaded, Title will not be saved"
  https://bugs.launchpad.net/openlp/+bug/646718
  Bug #696013 in OpenLP: "song import from powerpoint crashes every second time"
  https://bugs.launchpad.net/openlp/+bug/696013
  Bug #696021 in OpenLP: "presentation loader does not work fine in Windows using Powerpoint Viewer 2007"
  https://bugs.launchpad.net/openlp/+bug/696021
  Bug #696637 in OpenLP: "Alert not positioned correctly in single screen"
  https://bugs.launchpad.net/openlp/+bug/696637
  Bug #727732 in OpenLP: "Openlp 1.9.?? crashes on start"
  https://bugs.launchpad.net/openlp/+bug/727732
  Bug #735039 in OpenLP: "Cannot import PowerPoint Presentations with PowerPoint 2010"
  https://bugs.launchpad.net/openlp/+bug/735039
  Bug #759586 in OpenLP: "Some OpenSong songs won't import"
  https://bugs.launchpad.net/openlp/+bug/759586

For more details, see:
https://code.launchpad.net/~j-corwin/openlp/general/+merge/59003

Fix issues when importing some OpenSong songs. Bug 759586
-- 
https://code.launchpad.net/~j-corwin/openlp/general/+merge/59003
Your team OpenLP Core is requested to review the proposed merge of lp:~j-corwin/openlp/general into lp:openlp.
=== modified file 'openlp/plugins/songs/lib/opensongimport.py'
--- openlp/plugins/songs/lib/opensongimport.py	2011-04-20 17:36:16 +0000
+++ openlp/plugins/songs/lib/opensongimport.py	2011-04-25 22:42:26 +0000
@@ -193,7 +193,10 @@
         verse_num = u'1'
         # for the case where song has several sections with same marker
         inst = 1
-        lyrics = unicode(root.lyrics)
+        if u'lyrics' in fields:
+            lyrics = unicode(root.lyrics)
+        else:
+            lyrics = u''
         for this_line in lyrics.split(u'\n'):
             # remove comments
             semicolon = this_line.find(u';')
@@ -214,7 +217,7 @@
                 # have we got any digits?
                 # If so, verse number is everything from the digits
                 # to the end (even if there are some alpha chars on the end)
-                match = re.match(u'(.*)(\d+.*)', content)
+                match = re.match(u'(\D*)(\d+.*)', content)
                 if match is not None:
                     verse_tag = match.group(1)
                     verse_num = match.group(2)
@@ -223,12 +226,13 @@
                     # the verse tag
                     verse_tag = content
                     verse_num = u'1'
+                verse_index = VerseType.from_loose_input(verse_tag)
+                verse_tag = VerseType.Tags[verse_index]
                 inst = 1
                 if [verse_tag, verse_num, inst] in our_verse_order \
                     and verses.has_key(verse_tag) \
                     and verses[verse_tag].has_key(verse_num):
                     inst = len(verses[verse_tag][verse_num]) + 1
-                our_verse_order.append([verse_tag, verse_num, inst])
                 continue
             # number at start of line.. it's verse number
             if this_line[0].isdigit():
@@ -241,6 +245,7 @@
                 verses[verse_tag][verse_num] = {}
             if not verses[verse_tag][verse_num].has_key(inst):
                 verses[verse_tag][verse_num][inst] = []
+                our_verse_order.append([verse_tag, verse_num, inst])
             # Tidy text and remove the ____s from extended words
             this_line = self.tidy_text(this_line)
             this_line = this_line.replace(u'_', u'')
@@ -252,6 +257,8 @@
             verse_def = u'%s%s' % (verse_tag, verse_num)
             lines = u'\n'.join(verses[verse_tag][verse_num][inst])
             self.add_verse(lines, verse_def)
+        if not self.verses:
+            self.add_verse('')
         # figure out the presentation order, if present
         if u'presentation' in fields and root.presentation:
             order = unicode(root.presentation)
@@ -259,7 +266,7 @@
             # and then split into a list on the whitespace
             order = order.lower().split()
             for verse_def in order:
-                match = re.match(u'(.*)(\d+.*)', verse_def)
+                match = re.match(u'(\D*)(\d+.*)', verse_def)
                 if match is not None:
                     verse_tag = match.group(1)
                     verse_num = match.group(2)


Follow ups