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

Proposed by Tomas Groth
Status: Merged
Merged at revision: 2640
Proposed branch: lp:~tomasgroth/openlp/videopsalm-fix-24
Merge into: lp:openlp/2.4
Diff against target: 120 lines (+92/-0)
4 files modified
openlp/plugins/songs/lib/importers/videopsalm.py (+8/-0)
tests/functional/openlp_plugins/songs/test_videopsalm.py (+2/-0)
tests/resources/videopsalmsongs/as-safe-a-stronghold2.json (+35/-0)
tests/resources/videopsalmsongs/videopsalm-as-safe-a-stronghold2.json (+47/-0)
To merge this branch: bzr merge lp:~tomasgroth/openlp/videopsalm-fix-24
Reviewer Review Type Date Requested Status
Raoul Snyman Approve
Tim Bentley Approve
Review via email: mp+298065@code.launchpad.net

Description of the change

Fix handeling of control chars and escaped chars in VideoPsalm import. Fixes bug 1594945.

To post a comment you must log in.
Revision history for this message
Tomas Groth (tomasgroth) wrote :
2639. By Tomas Groth

merge trunk

Revision history for this message
Tomas Groth (tomasgroth) wrote :
Revision history for this message
Tim Bentley (trb143) :
review: Approve
Revision history for this message
Raoul Snyman (raoul-snyman) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'openlp/plugins/songs/lib/importers/videopsalm.py'
2--- openlp/plugins/songs/lib/importers/videopsalm.py 2016-06-16 21:00:13 +0000
3+++ openlp/plugins/songs/lib/importers/videopsalm.py 2016-06-21 21:02:11 +0000
4@@ -73,6 +73,14 @@
5 processed_content += c
6 c = next(file_content_it)
7 processed_content += '"' + c
8+ # Remove control characters
9+ elif (c < chr(32)):
10+ processed_content += ' '
11+ # Handle escaped characters
12+ elif c == '\\':
13+ processed_content += c
14+ c = next(file_content_it)
15+ processed_content += c
16 else:
17 processed_content += c
18 songbook = json.loads(processed_content.strip())
19
20=== modified file 'tests/functional/openlp_plugins/songs/test_videopsalm.py'
21--- tests/functional/openlp_plugins/songs/test_videopsalm.py 2016-01-08 19:52:24 +0000
22+++ tests/functional/openlp_plugins/songs/test_videopsalm.py 2016-06-21 21:02:11 +0000
23@@ -46,3 +46,5 @@
24 """
25 self.file_import(os.path.join(TEST_PATH, 'videopsalm-as-safe-a-stronghold.json'),
26 self.load_external_result_data(os.path.join(TEST_PATH, 'as-safe-a-stronghold.json')))
27+ self.file_import(os.path.join(TEST_PATH, 'videopsalm-as-safe-a-stronghold2.json'),
28+ self.load_external_result_data(os.path.join(TEST_PATH, 'as-safe-a-stronghold2.json')))
29
30=== added file 'tests/resources/videopsalmsongs/as-safe-a-stronghold2.json'
31--- tests/resources/videopsalmsongs/as-safe-a-stronghold2.json 1970-01-01 00:00:00 +0000
32+++ tests/resources/videopsalmsongs/as-safe-a-stronghold2.json 2016-06-21 21:02:11 +0000
33@@ -0,0 +1,35 @@
34+{
35+ "authors": [
36+ ["Martin Luther", "words"],
37+ ["Unknown", "music"]
38+ ],
39+ "ccli_number": "12345",
40+ "comments": "This is\nthe first comment\nThis is\nthe second comment\nThis is\nthe third comment\n",
41+ "copyright": "Public Domain",
42+ "song_book_name": "SongBook1",
43+ "song_number": 0,
44+ "title": "A Safe Stronghold Our God is Still",
45+ "topics": [
46+ "tema1",
47+ "tema2"
48+ ],
49+ "verse_order_list": [],
50+ "verses": [
51+ [
52+ "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.",
53+ "v"
54+ ],
55+ [
56+ "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.",
57+ "v"
58+ ],
59+ [
60+ "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.",
61+ "v"
62+ ],
63+ [
64+ "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.",
65+ "v"
66+ ]
67+ ]
68+}
69
70=== added file 'tests/resources/videopsalmsongs/videopsalm-as-safe-a-stronghold2.json'
71--- tests/resources/videopsalmsongs/videopsalm-as-safe-a-stronghold2.json 1970-01-01 00:00:00 +0000
72+++ tests/resources/videopsalmsongs/videopsalm-as-safe-a-stronghold2.json 2016-06-21 21:02:11 +0000
73@@ -0,0 +1,47 @@
74+{Abbreviation:"SB1",Copyright:"Public domain",Songs:[{ID:3,Composer:"Unknown",Author:"Martin Luther",Copyright:"Public
75+Domain",Theme:"tema1
76+tema2",CCLI:"12345",Alias:"A safe stronghold",Memo1:"This is
77+the first comment
78+",Memo2:"This is
79+the second comment
80+",Memo3:"This is
81+the third comment
82+",Reference:"reference",Guid:"jtCkrJdPIUOmECjaQylg/g",Verses:[{
83+Text:"As safe a stronghold our God is still,
84+A trusty shield and weapon;
85+He’ll help us clear from all the ill
86+That hath us now o’ertaken.
87+The ancient prince of hell
88+Hath risen with purpose fell;
89+Strong mail of craft and power
90+He weareth in this hour;
91+On earth is not His fellow."},{ID:2,
92+Text:"With \"force\" of arms we nothing can,
93+Full soon were we down-ridden;
94+But for us fights \\ the proper Man,
95+Whom God Himself hath bidden.
96+Ask ye: Who is this same?
97+Christ Jesus is His name,
98+The Lord Sabaoth’s Son;
99+He, and no other one,
100+Shall conquer in the battle."},{ID:3,
101+Text:"And were this world all devils o’er,
102+And watching to devour us,
103+We lay it not to heart so sore;
104+Not they can overpower us.
105+And let the prince of ill
106+Look grim as e’er he will,
107+He harms us not a whit;
108+For why? his doom is writ;
109+A word shall quickly slay him."},{ID:4,
110+Text:"God’s word, for all their craft and force,
111+One moment will not linger,
112+But, spite of hell, shall have its course;
113+’Tis written by His finger.
114+And though they take our life,
115+Goods, honour, children, wife,
116+Yet is their profit small:
117+These things shall vanish all;
118+The city of God remaineth."}],AudioFile:"282.mp3",IsAudioFileEnabled:1,
119+Text:"A Safe Stronghold Our God is Still"}],Guid:"khiHU2blX0Kb41dGdbDLhA",VersionDate:"20121012000000",
120+Text:"SongBook1"}

Subscribers

People subscribed via source and target branches

to all changes: