← Back to team overview

openlp-core team mailing list archive

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

 

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

Requested reviews:
  OpenLP Core (openlp-core)
Related bugs:
  Bug #1096450 in OpenLP: "Opensong Import - some lines missing"
  https://bugs.launchpad.net/openlp/+bug/1096450

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

Fixes #1096450 Stripping the leading and trailing spaces at the end rather than begginning (the space means something, see added comments)
Semi-colons (;) denotes comments ONLY when it is the first char of the line ie the whole line is a comment
Finally fixed an issue when a verse was being added to the verse order multiple times, thus repeating it over and over and ....
-- 
https://code.launchpad.net/~phill-ridout/openlp/1096450_2.0/+merge/178455
Your team OpenLP Core is requested to review the proposed merge of lp:~phill-ridout/openlp/1096450_2.0 into lp:openlp/2.0.
=== modified file 'openlp/plugins/songs/lib/opensongimport.py'
--- openlp/plugins/songs/lib/opensongimport.py	2012-12-30 19:41:24 +0000
+++ openlp/plugins/songs/lib/opensongimport.py	2013-08-04 13:22:25 +0000
@@ -49,6 +49,9 @@
     the OpenSong web site. However, it doesn't describe the <lyrics> section,
     so here's an attempt:
 
+    If the first charachter of a line is a space, then the rest of that line
+    is lyrics. If it is not a space the following applies.
+
     Verses can be expressed in one of 2 ways, either in complete verses, or by
     line grouping, i.e. grouping all line 1's of a verse together, all line 2's
     of a verse together, and so on.
@@ -171,13 +174,11 @@
         else:
             lyrics = u''
         for this_line in lyrics.split(u'\n'):
-            # remove comments
-            semicolon = this_line.find(u';')
-            if semicolon >= 0:
-                this_line = this_line[:semicolon]
-            this_line = this_line.strip()
             if not this_line:
                 continue
+            # skip this line if it is a comment
+            if this_line.startswith(u';'):
+                continue
             # skip guitar chords and page and column breaks
             if this_line.startswith(u'.') or this_line.startswith(u'---') \
                 or this_line.startswith(u'-!!'):
@@ -212,7 +213,6 @@
             if this_line[0].isdigit():
                 verse_num = this_line[0]
                 this_line = this_line[1:].strip()
-                our_verse_order.append([verse_tag, verse_num, inst])
             verses.setdefault(verse_tag, {})
             verses[verse_tag].setdefault(verse_num, {})
             if inst not in verses[verse_tag][verse_num]:
@@ -222,6 +222,7 @@
             this_line = self.tidyText(this_line)
             this_line = this_line.replace(u'_', u'')
             this_line = this_line.replace(u'|', u'\n')
+            this_line = this_line.strip()
             verses[verse_tag][verse_num][inst].append(this_line)
         # done parsing
         # add verses in original order


Follow ups