← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~gerald-britton/openlp/bugs into lp:openlp

 

jerryb has proposed merging lp:~gerald-britton/openlp/bugs into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)

For more details, see:
https://code.launchpad.net/~gerald-britton/openlp/bugs/+merge/60225

Fix for bug 762856:

1. Adds support for song bridge
2. Beefs up error handling for unrecognized section types

-- 
https://code.launchpad.net/~gerald-britton/openlp/bugs/+merge/60225
Your team OpenLP Core is requested to review the proposed merge of lp:~gerald-britton/openlp/bugs into lp:openlp.
=== modified file 'openlp/plugins/songs/lib/songshowplusimport.py'
--- openlp/plugins/songs/lib/songshowplusimport.py	2011-05-06 04:36:22 +0000
+++ openlp/plugins/songs/lib/songshowplusimport.py	2011-05-06 18:02:24 +0000
@@ -47,6 +47,7 @@
 SONG_BOOK = 35
 SONG_NUMBER = 36
 CUSTOM_VERSE = 37
+BRIDGE = 24
 
 log = logging.getLogger(__name__)
 
@@ -100,6 +101,7 @@
         if not isinstance(self.import_source, list):
             return
         self.import_wizard.progressBar.setMaximum(len(self.import_source))
+
         for file in self.import_source:
             self.sspVerseOrderList = []
             otherCount = 0
@@ -108,13 +110,15 @@
             self.import_wizard.incrementProgressBar(
                 WizardStrings.ImportingType % file_name, 0)
             songData = open(file, 'rb')
+
             while True:
                 blockKey, = struct.unpack("I", songData.read(4))
                 # The file ends with 4 NUL's
                 if blockKey == 0:
                     break
                 nextBlockStarts, = struct.unpack("I", songData.read(4))
-                if blockKey == VERSE or blockKey == CHORUS:
+                nextBlockStarts += songData.tell()
+                if blockKey in (VERSE, CHORUS, BRIDGE):
                     null, verseNo,  = struct.unpack("BB", songData.read(2))
                 elif blockKey == CUSTOM_VERSE:
                     null, verseNameLength, = struct.unpack("BB",
@@ -150,6 +154,9 @@
                 elif blockKey == CHORUS:
                     self.add_verse(unicode(data, u'cp1252'),
                         "C%s" % verseNo)
+                elif blockKey == BRIDGE:
+                    self.add_verse(unicode(data, u'cp1252'),
+                        "B%s" % verseNo)
                 elif blockKey == TOPIC:
                     self.topics.append(unicode(data, u'cp1252'))
                 elif blockKey == COMMENTS:
@@ -169,6 +176,7 @@
                 else:
                     log.debug("Unrecognised blockKey: %s, data: %s"
                         % (blockKey, data))
+                    songData.seek(nextBlockStarts)
             self.verse_order_list = self.sspVerseOrderList
             songData.close()
             if not self.finish():


Follow ups