From bdf3109aaa9e02897568244297a70bb0e4f63af5 Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Thu, 1 May 2014 10:46:45 +0200 Subject: [PATCH] Fix SongShowPlus Import for certain cases Fixes: https://launchpad.net/bugs/1310623 --- .../plugins/songs/lib/songshowplusimport.py | 7 +++-- .../songs/test_songshowplusimport.py | 2 ++ .../a mighty fortress is our god.json | 29 ++++++++++++++++++ .../a mighty fortress is our god.sbsong | Bin 0 -> 1342 bytes 4 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 tests/resources/songshowplussongs/a mighty fortress is our god.json create mode 100644 tests/resources/songshowplussongs/a mighty fortress is our god.sbsong diff --git a/openlp/plugins/songs/lib/songshowplusimport.py b/openlp/plugins/songs/lib/songshowplusimport.py index 0a8dc4650..c1c6d04cb 100644 --- a/openlp/plugins/songs/lib/songshowplusimport.py +++ b/openlp/plugins/songs/lib/songshowplusimport.py @@ -121,7 +121,7 @@ class SongShowPlusImport(SongImport): null, verse_no, = struct.unpack("BB", song_data.read(2)) elif block_key == CUSTOM_VERSE: null, verse_name_length, = struct.unpack("BB", song_data.read(2)) - verse_name = song_data.read(verse_name_length) + verse_name = self.decode(song_data.read(verse_name_length)) length_descriptor_size, = struct.unpack("B", song_data.read(1)) log.debug(length_descriptor_size) # Detect if/how long the length descriptor is @@ -147,7 +147,10 @@ class SongShowPlusImport(SongImport): elif block_key == COPYRIGHT: self.add_copyright(self.decode(data)) elif block_key == CCLI_NO: - self.ccli_number = int(data) + try: + self.ccli_number = int(data) + except ValueError: + continue elif block_key == VERSE: self.add_verse(self.decode(data), "%s%s" % (VerseType.tags[VerseType.Verse], verse_no)) elif block_key == CHORUS: diff --git a/tests/functional/openlp_plugins/songs/test_songshowplusimport.py b/tests/functional/openlp_plugins/songs/test_songshowplusimport.py index 7292bb2b0..08400fdc5 100644 --- a/tests/functional/openlp_plugins/songs/test_songshowplusimport.py +++ b/tests/functional/openlp_plugins/songs/test_songshowplusimport.py @@ -57,6 +57,8 @@ class TestSongShowPlusFileImport(SongImportTestHelper): self.load_external_result_data(os.path.join(TEST_PATH, 'Amazing Grace.json'))) self.file_import(os.path.join(TEST_PATH, 'Beautiful Garden Of Prayer.sbsong'), self.load_external_result_data(os.path.join(TEST_PATH, 'Beautiful Garden Of Prayer.json'))) + self.file_import(os.path.join(TEST_PATH, 'a mighty fortress is our god.sbsong'), + self.load_external_result_data(os.path.join(TEST_PATH, 'a mighty fortress is our god.json'))) class TestSongShowPlusImport(TestCase): diff --git a/tests/resources/songshowplussongs/a mighty fortress is our god.json b/tests/resources/songshowplussongs/a mighty fortress is our god.json new file mode 100644 index 000000000..7e3d400b4 --- /dev/null +++ b/tests/resources/songshowplussongs/a mighty fortress is our god.json @@ -0,0 +1,29 @@ +{ + "authors": [ + "Martin Luther" + ], + "comments": "", + "copyright": "Public Domain", + "song_number": 0, + "title": "A Mighty Fortress is our God", + "topics": [], + "verse_order_list": [], + "verses": [ + [ + "A mighty fortress is our God, a bulwark never failing;\r\nOur helper He, amid the flood of mortal ills prevailing:\r\nFor still our ancient foe doth seek to work us woe;\r\nHis craft and power are great, and, armed with cruel hate,\r\nOn earth is not his equal.\r\n", + "v1" + ], + [ + "Did we in our own strength confide, our striving would be losing;\r\nWere not the right Man on our side, the Man of God’s own choosing:\r\nDost ask who that may be? Christ Jesus, it is He;\r\nLord Sabaoth, His Name, from age to age the same,\r\nAnd He must win the battle.\r\n", + "v2" + ], + [ + "And though this world, with devils filled, should threaten to undo us,\r\nWe will not fear, for God hath willed His truth to triumph through us:\r\nThe Prince of Darkness grim, we tremble not for him;\r\nHis rage we can endure, for lo, his doom is sure,\r\nOne little word shall fell him.\r\n", + "v3" + ], + [ + "That word above all earthly powers, no thanks to them, abideth;\r\nThe Spirit and the gifts are ours through Him Who with us sideth:\r\nLet goods and kindred go, this mortal life also;\r\nThe body they may kill: God’s truth abideth still,\r\nHis kingdom is forever.\r\n", + "v4" + ] + ] +} \ No newline at end of file diff --git a/tests/resources/songshowplussongs/a mighty fortress is our god.sbsong b/tests/resources/songshowplussongs/a mighty fortress is our god.sbsong new file mode 100644 index 0000000000000000000000000000000000000000..b66d52b2b73ef827e1427a90d8b54dfae1808508 GIT binary patch literal 1342 zcmZXU%We}f6o$j4Ekq3<=n5fp7F@cB5H01RvOrZM2&gTUTG6#9J~OuBv4ibNlpU|Z z>+vG+pP8tN#9}-iU(V(G&zTp!UT;&L+ppj6eYkAg%Eeze!JJ+-4nDw!{x%Go%V%ppMdqi~?Tls%%LsC>UZlU6oJkL2&sjRcU z`Z(x+NBD-_42xsN!P;s<;8eO0G=-9C*i(+IbBSh==iSZ2K_3t(WvsUdl%H7knaaSV zLpGF{r<4ON0=zZ}Z-%=uh)tp@GbyiW78dZUB2yJvWw`emL#$cT!otWTHtfi#%tM6g ziNV$gbssVry!mIN+^a!fh&)~+vcI#9uMv`2FhLDbDJ(n!j_fP39DHdtGL{{z+BtY2 z$i`_Zm|RF5pDRXm;!U7LK}@F#_BxZPH6dH=VkwpI=htsk1$<3RXsv+NC?sT@rnE2t zmQ_{;| zWGieWXN~L>!Y>&EY_51cTH|%Fvw^Qm(XPFqiZExAOKnlQWmnA*(YF%&DRPw=BXU)s zP_jX&lHkS6Mkp;EAQDx!%&F}H)FLjec#LgLS16ZO3p9|_S~g&G!kH>`C+@())OsDk zwnCn*gsX;iwv_NvSUD|%UW&VATY6K7b$DH^ohGXwyQT&rQ47{9-GKv4`F8-#OEjDO Nw;tl@?XG{w!aqH)mM#DQ literal 0 HcmV?d00001