← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~tomasgroth/openlp/videopsalm-fix-24 into lp:openlp/2.4

 

Tomas Groth has proposed merging lp:~tomasgroth/openlp/videopsalm-fix-24 into lp:openlp/2.4.

Requested reviews:
  OpenLP Core (openlp-core)
Related bugs:
  Bug #1594945 in OpenLP: "VideoPsalm import with control chars or escaped quotes causes traceback"
  https://bugs.launchpad.net/openlp/+bug/1594945

For more details, see:
https://code.launchpad.net/~tomasgroth/openlp/videopsalm-fix-24/+merge/298065

Fix handeling of control chars and escaped chars in VideoPsalm import. Fixes bug 1594945.
-- 
Your team OpenLP Core is requested to review the proposed merge of lp:~tomasgroth/openlp/videopsalm-fix-24 into lp:openlp/2.4.
=== modified file 'openlp/plugins/songs/lib/importers/videopsalm.py'
--- openlp/plugins/songs/lib/importers/videopsalm.py	2016-01-08 19:52:24 +0000
+++ openlp/plugins/songs/lib/importers/videopsalm.py	2016-06-21 20:18:55 +0000
@@ -73,6 +73,14 @@
                         processed_content += c
                         c = next(file_content_it)
                     processed_content += '"' + c
+                # Remove control characters
+                elif (c < chr(32)):
+                    processed_content += ' '
+                # Handle escaped characters
+                elif c == '\\':
+                    processed_content += c
+                    c = next(file_content_it)
+                    processed_content += c
                 else:
                     processed_content += c
             songbook = json.loads(processed_content.strip())
@@ -117,6 +125,6 @@
                 if not self.finish():
                     self.log_error('Could not import %s' % self.title)
         except Exception as e:
-            self.log_error(translate('SongsPlugin.VideoPsalmImport', 'File %s' % file.name),
+            self.log_error(song_file.name,
                            translate('SongsPlugin.VideoPsalmImport', 'Error: %s') % e)
         song_file.close()

=== modified file 'tests/functional/openlp_plugins/songs/test_videopsalm.py'
--- tests/functional/openlp_plugins/songs/test_videopsalm.py	2016-01-08 19:52:24 +0000
+++ tests/functional/openlp_plugins/songs/test_videopsalm.py	2016-06-21 20:18:55 +0000
@@ -46,3 +46,5 @@
         """
         self.file_import(os.path.join(TEST_PATH, 'videopsalm-as-safe-a-stronghold.json'),
                          self.load_external_result_data(os.path.join(TEST_PATH, 'as-safe-a-stronghold.json')))
+        self.file_import(os.path.join(TEST_PATH, 'videopsalm-as-safe-a-stronghold2.json'),
+                         self.load_external_result_data(os.path.join(TEST_PATH, 'as-safe-a-stronghold2.json')))

=== added file 'tests/resources/videopsalmsongs/as-safe-a-stronghold2.json'
--- tests/resources/videopsalmsongs/as-safe-a-stronghold2.json	1970-01-01 00:00:00 +0000
+++ tests/resources/videopsalmsongs/as-safe-a-stronghold2.json	2016-06-21 20:18:55 +0000
@@ -0,0 +1,35 @@
+{
+    "authors": [
+        ["Martin Luther", "words"],
+        ["Unknown", "music"]
+    ],
+    "ccli_number": "12345",
+    "comments": "This is\nthe first comment\nThis is\nthe second comment\nThis is\nthe third comment\n",
+    "copyright": "Public Domain",
+    "song_book_name": "SongBook1",
+    "song_number": 0,
+    "title": "A Safe Stronghold Our God is Still",
+    "topics": [
+        "tema1",
+        "tema2"
+    ],
+    "verse_order_list": [],
+    "verses": [
+        [
+            "As safe a stronghold our God is still,\nA trusty shield and weapon;\nHe’ll help us clear from all the ill\nThat hath us now o’ertaken.\nThe ancient prince of hell\nHath risen with purpose fell;\nStrong mail of craft and power\nHe weareth in this hour;\nOn earth is not His fellow.",
+            "v"
+        ],
+        [
+            "With \"force\" of arms we nothing can,\nFull soon were we down-ridden;\nBut for us fights \\ the proper Man,\nWhom God Himself hath bidden.\nAsk ye: Who is this same?\nChrist Jesus is His name,\nThe Lord Sabaoth’s Son;\nHe, and no other one,\nShall conquer in the battle.",
+            "v"
+        ],
+        [
+            "And were this world all devils o’er,\nAnd watching to devour us,\nWe lay it not to heart so sore;\nNot they can overpower us.\nAnd let the prince of ill\nLook grim as e’er he will,\nHe harms us not a whit;\nFor why? his doom is writ;\nA word shall quickly slay him.",
+            "v"
+        ],
+        [
+            "God’s word, for all their craft and force,\nOne moment will not linger,\nBut, spite of hell, shall have its course;\n’Tis written by His finger.\nAnd though they take our life,\nGoods, honour, children, wife,\nYet is their profit small:\nThese things shall vanish all;\nThe city of God remaineth.",
+            "v"
+        ]
+    ]
+}

=== added file 'tests/resources/videopsalmsongs/videopsalm-as-safe-a-stronghold2.json'
--- tests/resources/videopsalmsongs/videopsalm-as-safe-a-stronghold2.json	1970-01-01 00:00:00 +0000
+++ tests/resources/videopsalmsongs/videopsalm-as-safe-a-stronghold2.json	2016-06-21 20:18:55 +0000
@@ -0,0 +1,47 @@
+{Abbreviation:"SB1",Copyright:"Public domain",Songs:[{ID:3,Composer:"Unknown",Author:"Martin Luther",Copyright:"Public
+Domain",Theme:"tema1
+tema2",CCLI:"12345",Alias:"A safe stronghold",Memo1:"This is
+the first comment
+",Memo2:"This is
+the second comment
+",Memo3:"This is
+the third comment
+",Reference:"reference",Guid:"jtCkrJdPIUOmECjaQylg/g",Verses:[{
+Text:"As safe a stronghold our God is still,
+A trusty shield and weapon;
+He’ll help us clear from all the ill
+That hath us now o’ertaken.
+The ancient prince of hell
+Hath risen with purpose fell;
+Strong mail of craft and power
+He weareth in this hour;
+On earth is not His fellow."},{ID:2,
+Text:"With \"force\" of arms we nothing can,
+Full soon were we down-ridden;
+But for us fights \\ the proper Man,
+Whom God Himself hath bidden.
+Ask ye: Who is this same?
+Christ Jesus is His name,
+The Lord Sabaoth’s Son;
+He, and no other one,
+Shall conquer in the battle."},{ID:3,
+Text:"And	were this world all devils o’er,
+And watching to devour us,
+We lay it not to heart so sore;
+Not they can overpower us.
+And let the prince of ill
+Look grim as e’er he will,
+He harms us not a whit;
+For why? his doom is writ;
+A word shall quickly slay him."},{ID:4,
+Text:"God’s word, for all their craft and force,
+One moment will not linger,
+But, spite of hell, shall have its course;
+’Tis written by His finger.
+And though they take our life,
+Goods, honour, children, wife,
+Yet is their profit small:
+These things shall vanish all;
+The city of God remaineth."}],AudioFile:"282.mp3",IsAudioFileEnabled:1,
+Text:"A Safe Stronghold Our God is Still"}],Guid:"khiHU2blX0Kb41dGdbDLhA",VersionDate:"20121012000000",
+Text:"SongBook1"}


References