Merge lp:~sam92/openlp/worshipassistant-import into lp:openlp

Proposed by Samuel Mehrbrodt
Status: Merged
Approved by: Tim Bentley
Approved revision: 2405
Merged at revision: 2396
Proposed branch: lp:~sam92/openlp/worshipassistant-import
Merge into: lp:openlp
Diff against target: 558 lines (+360/-24)
14 files modified
openlp/plugins/bibles/lib/http.py (+2/-2)
openlp/plugins/songs/lib/cclifileimport.py (+1/-1)
openlp/plugins/songs/lib/importer.py (+22/-9)
openlp/plugins/songs/lib/worshipassistantimport.py (+171/-0)
tests/functional/openlp_plugins/songs/test_opensongimport.py (+3/-3)
tests/functional/openlp_plugins/songs/test_propresenterimport.py (+1/-1)
tests/functional/openlp_plugins/songs/test_songshowplusimport.py (+3/-3)
tests/functional/openlp_plugins/songs/test_worshipassistantimport.py (+56/-0)
tests/helpers/songfileimport.py (+1/-1)
tests/resources/worshipassistantsongs/du_herr.csv (+30/-0)
tests/resources/worshipassistantsongs/du_herr.json (+21/-0)
tests/resources/worshipassistantsongs/would_you_be_free.csv (+30/-0)
tests/resources/worshipassistantsongs/would_you_be_free.json (+19/-0)
tests/utils/test_bzr_tags.py (+0/-4)
To merge this branch: bzr merge lp:~sam92/openlp/worshipassistant-import
Reviewer Review Type Date Requested Status
Raoul Snyman Approve
Tomas Groth Approve
Tim Bentley Approve
Review via email: mp+224956@code.launchpad.net

This proposal supersedes a proposal from 2014-06-26.

To post a comment you must log in.
Revision history for this message
Tomas Groth (tomasgroth) wrote : Posted in a previous version of this proposal

See inline comments.

review: Needs Fixing
Revision history for this message
Samuel Mehrbrodt (sam92) wrote : Posted in a previous version of this proposal

I responded to one issue inline, will fix the others.
Thanks!

Revision history for this message
Tomas Groth (tomasgroth) wrote : Posted in a previous version of this proposal

Looks good to me :)
But after talking to Raoul I'm not sure the bzr tags test needs fixing after all..

Revision history for this message
Tomas Groth (tomasgroth) : Posted in a previous version of this proposal
review: Approve
Revision history for this message
Tim Bentley (trb143) : Posted in a previous version of this proposal
review: Needs Fixing
Revision history for this message
Tim Bentley (trb143) :
review: Approve
Revision history for this message
Tomas Groth (tomasgroth) :
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
=== modified file 'openlp/plugins/bibles/lib/http.py'
--- openlp/plugins/bibles/lib/http.py 2014-05-02 06:42:17 +0000
+++ openlp/plugins/bibles/lib/http.py 2014-06-30 07:21:09 +0000
@@ -225,7 +225,7 @@
225 url_book_name = urllib.parse.quote(book_name.encode("utf-8"))225 url_book_name = urllib.parse.quote(book_name.encode("utf-8"))
226 url_params = 'search=%s+%s&version=%s' % (url_book_name, chapter, version)226 url_params = 'search=%s+%s&version=%s' % (url_book_name, chapter, version)
227 soup = get_soup_for_bible_ref(227 soup = get_soup_for_bible_ref(
228 'http://www.biblegateway.com/passage/?%s' % url_params,228 'http://legacy.biblegateway.com/passage/?%s' % url_params,
229 pre_parse_regex=r'<meta name.*?/>', pre_parse_substitute='')229 pre_parse_regex=r'<meta name.*?/>', pre_parse_substitute='')
230 if not soup:230 if not soup:
231 return None231 return None
@@ -252,7 +252,7 @@
252 """252 """
253 log.debug('BGExtract.get_books_from_http("%s")', version)253 log.debug('BGExtract.get_books_from_http("%s")', version)
254 url_params = urllib.parse.urlencode({'action': 'getVersionInfo', 'vid': '%s' % version})254 url_params = urllib.parse.urlencode({'action': 'getVersionInfo', 'vid': '%s' % version})
255 reference_url = 'http://www.biblegateway.com/versions/?%s#books' % url_params255 reference_url = 'http://legacy.biblegateway.com/versions/?%s#books' % url_params
256 page = get_web_page(reference_url)256 page = get_web_page(reference_url)
257 if not page:257 if not page:
258 send_error_message('download')258 send_error_message('download')
259259
=== modified file 'openlp/plugins/songs/lib/cclifileimport.py'
--- openlp/plugins/songs/lib/cclifileimport.py 2014-05-21 14:47:44 +0000
+++ openlp/plugins/songs/lib/cclifileimport.py 2014-06-30 07:21:09 +0000
@@ -64,7 +64,7 @@
64 filename = str(filename)64 filename = str(filename)
65 log.debug('Importing CCLI File: %s', filename)65 log.debug('Importing CCLI File: %s', filename)
66 if os.path.isfile(filename):66 if os.path.isfile(filename):
67 detect_file = open(filename, 'r')67 detect_file = open(filename, 'rb')
68 detect_content = detect_file.read(2048)68 detect_content = detect_file.read(2048)
69 try:69 try:
70 str(detect_content, 'utf-8')70 str(detect_content, 'utf-8')
7171
=== modified file 'openlp/plugins/songs/lib/importer.py'
--- openlp/plugins/songs/lib/importer.py 2014-06-09 10:27:17 +0000
+++ openlp/plugins/songs/lib/importer.py 2014-06-30 07:21:09 +0000
@@ -50,6 +50,7 @@
50from .foilpresenterimport import FoilPresenterImport50from .foilpresenterimport import FoilPresenterImport
51from .zionworximport import ZionWorxImport51from .zionworximport import ZionWorxImport
52from .propresenterimport import ProPresenterImport52from .propresenterimport import ProPresenterImport
53from .worshipassistantimport import WorshipAssistantImport
53# Imports that might fail54# Imports that might fail
5455
5556
@@ -167,8 +168,9 @@
167 SongsOfFellowship = 16168 SongsOfFellowship = 16
168 SundayPlus = 17169 SundayPlus = 17
169 WordsOfWorship = 18170 WordsOfWorship = 18
170 WorshipCenterPro = 19171 WorshipAssistant = 19
171 ZionWorx = 20172 WorshipCenterPro = 20
173 ZionWorx = 21
172174
173 # Set optional attribute defaults175 # Set optional attribute defaults
174 __defaults__ = {176 __defaults__ = {
@@ -321,6 +323,16 @@
321 'prefix': 'wordsOfWorship',323 'prefix': 'wordsOfWorship',
322 'filter': '%s (*.wsg *.wow-song)' % translate('SongsPlugin.ImportWizardForm', 'Words Of Worship Song Files')324 'filter': '%s (*.wsg *.wow-song)' % translate('SongsPlugin.ImportWizardForm', 'Words Of Worship Song Files')
323 },325 },
326 WorshipAssistant: {
327 'class': WorshipAssistantImport,
328 'name': 'Worship Assistant 0',
329 'prefix': 'worshipAssistant',
330 'selectMode': SongFormatSelect.SingleFile,
331 'filter': '%s (*.csv)' % translate('SongsPlugin.ImportWizardForm', 'Worship Assistant Files'),
332 'comboBoxText': translate('SongsPlugin.ImportWizardForm', 'Worship Assistant (CSV)'),
333 'descriptionText': translate('SongsPlugin.ImportWizardForm',
334 'In Worship Assistant, export your Database to a CSV file.')
335 },
324 WorshipCenterPro: {336 WorshipCenterPro: {
325 'name': 'WorshipCenter Pro',337 'name': 'WorshipCenter Pro',
326 'prefix': 'worshipCenterPro',338 'prefix': 'worshipCenterPro',
@@ -370,16 +382,17 @@
370 SongFormat.SongsOfFellowship,382 SongFormat.SongsOfFellowship,
371 SongFormat.SundayPlus,383 SongFormat.SundayPlus,
372 SongFormat.WordsOfWorship,384 SongFormat.WordsOfWorship,
385 SongFormat.WorshipAssistant,
373 SongFormat.WorshipCenterPro,386 SongFormat.WorshipCenterPro,
374 SongFormat.ZionWorx387 SongFormat.ZionWorx
375 ]388 ]
376389
377 @staticmethod390 @staticmethod
378 def get(format, *attributes):391 def get(song_format, *attributes):
379 """392 """
380 Return requested song format attribute(s).393 Return requested song format attribute(s).
381394
382 :param format: A song format from SongFormat.395 :param song_format: A song format from SongFormat.
383 :param attributes: Zero or more song format attributes from SongFormat.396 :param attributes: Zero or more song format attributes from SongFormat.
384397
385 Return type depends on number of supplied attributes:398 Return type depends on number of supplied attributes:
@@ -389,23 +402,23 @@
389 :>1: Return tuple of requested attribute values.402 :>1: Return tuple of requested attribute values.
390 """403 """
391 if not attributes:404 if not attributes:
392 return SongFormat.__attributes__.get(format)405 return SongFormat.__attributes__.get(song_format)
393 elif len(attributes) == 1:406 elif len(attributes) == 1:
394 default = SongFormat.__defaults__.get(attributes[0])407 default = SongFormat.__defaults__.get(attributes[0])
395 return SongFormat.__attributes__[format].get(attributes[0], default)408 return SongFormat.__attributes__[song_format].get(attributes[0], default)
396 else:409 else:
397 values = []410 values = []
398 for attr in attributes:411 for attr in attributes:
399 default = SongFormat.__defaults__.get(attr)412 default = SongFormat.__defaults__.get(attr)
400 values.append(SongFormat.__attributes__[format].get(attr, default))413 values.append(SongFormat.__attributes__[song_format].get(attr, default))
401 return tuple(values)414 return tuple(values)
402415
403 @staticmethod416 @staticmethod
404 def set(format, attribute, value):417 def set(song_format, attribute, value):
405 """418 """
406 Set specified song format attribute to the supplied value.419 Set specified song format attribute to the supplied value.
407 """420 """
408 SongFormat.__attributes__[format][attribute] = value421 SongFormat.__attributes__[song_format][attribute] = value
409422
410423
411SongFormat.set(SongFormat.SongsOfFellowship, 'availability', HAS_SOF)424SongFormat.set(SongFormat.SongsOfFellowship, 'availability', HAS_SOF)
412425
=== added file 'openlp/plugins/songs/lib/worshipassistantimport.py'
--- openlp/plugins/songs/lib/worshipassistantimport.py 1970-01-01 00:00:00 +0000
+++ openlp/plugins/songs/lib/worshipassistantimport.py 2014-06-30 07:21:09 +0000
@@ -0,0 +1,171 @@
1# -*- coding: utf-8 -*-
2# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
3
4###############################################################################
5# OpenLP - Open Source Lyrics Projection #
6# --------------------------------------------------------------------------- #
7# Copyright (c) 2008-2014 Raoul Snyman #
8# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan #
9# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, #
10# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. #
11# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, #
12# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, #
13# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, #
14# Frode Woldsund, Martin Zibricky, Patrick Zimmermann #
15# --------------------------------------------------------------------------- #
16# This program is free software; you can redistribute it and/or modify it #
17# under the terms of the GNU General Public License as published by the Free #
18# Software Foundation; version 2 of the License. #
19# #
20# This program is distributed in the hope that it will be useful, but WITHOUT #
21# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
22# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
23# more details. #
24# #
25# You should have received a copy of the GNU General Public License along #
26# with this program; if not, write to the Free Software Foundation, Inc., 59 #
27# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
28###############################################################################
29"""
30The :mod:`worshipassistantimport` module provides the functionality for importing
31Worship Assistant songs into the OpenLP database.
32"""
33import chardet
34import csv
35import logging
36import re
37
38from openlp.core.common import translate
39from openlp.plugins.songs.lib import VerseType
40from openlp.plugins.songs.lib.songimport import SongImport
41
42log = logging.getLogger(__name__)
43
44EMPTY_STR = 'NULL'
45
46
47class WorshipAssistantImport(SongImport):
48 """
49 The :class:`WorshipAssistantImport` class provides the ability to import songs
50 from Worship Assistant, via a dump of the database to a CSV file.
51
52 The following fields are in the exported CSV file:
53
54 * ``SONGNR`` Song ID (Discarded by importer)
55 * ``TITLE`` Song title
56 * ``AUTHOR`` Song author.
57 * ``COPYRIGHT`` Copyright information
58 * ``FIRSTLINE`` Unknown (Discarded by importer)
59 * ``PRIKEY`` Primary chord key (Discarded by importer)
60 * ``ALTKEY`` Alternate chord key (Discarded by importer)
61 * ``TEMPO`` Tempo (Discarded by importer)
62 * ``FOCUS`` Unknown (Discarded by importer)
63 * ``THEME`` Theme (Discarded by importer)
64 * ``SCRIPTURE`` Associated scripture (Discarded by importer)
65 * ``ACTIVE`` Boolean value (Discarded by importer)
66 * ``SONGBOOK`` Boolean value (Discarded by importer)
67 * ``TIMESIG`` Unknown (Discarded by importer)
68 * ``INTRODUCED`` Date the song was created (Discarded by importer)
69 * ``LASTUSED`` Date the song was last used (Discarded by importer)
70 * ``TIMESUSED`` How many times the song was used (Discarded by importer)
71 * ``CCLINR`` CCLI Number
72 * ``USER1`` User Field 1 (Discarded by importer)
73 * ``USER2`` User Field 2 (Discarded by importer)
74 * ``USER3`` User Field 3 (Discarded by importer)
75 * ``USER4`` User Field 4 (Discarded by importer)
76 * ``USER5`` User Field 5 (Discarded by importer)
77 * ``ROADMAP`` Verse order used for the presentation
78 * ``FILELINK1`` Associated file 1 (Discarded by importer)
79 * ``OVERMAP`` Verse order used for printing (Discarded by importer)
80 * ``FILELINK2`` Associated file 2 (Discarded by importer)
81 * ``LYRICS`` The song lyrics used for printing (Discarded by importer, LYRICS2 is used instead)
82 * ``INFO`` Unknown (Discarded by importer)
83 * ``LYRICS2`` The song lyrics used for the presentation
84 * ``BACKGROUND`` Custom background (Discarded by importer)
85 """
86 def do_import(self):
87 """
88 Receive a CSV file to import.
89 """
90 # Get encoding
91 detect_file = open(self.import_source, 'rb')
92 detect_content = detect_file.read()
93 details = chardet.detect(detect_content)
94 detect_file.close()
95 songs_file = open(self.import_source, 'r', encoding=details['encoding'])
96 songs_reader = csv.DictReader(songs_file)
97 try:
98 records = list(songs_reader)
99 except csv.Error as e:
100 self.log_error(translate('SongsPlugin.WorshipAssistantImport', 'Error reading CSV file.'),
101 translate('SongsPlugin.WorshipAssistantImport', 'Line %d: %s') %
102 (songs_reader.line_num, e))
103 return
104 num_records = len(records)
105 log.info('%s records found in CSV file' % num_records)
106 self.import_wizard.progress_bar.setMaximum(num_records)
107 for index, record in enumerate(records, 1):
108 if self.stop_import_flag:
109 return
110 # Ensure that all keys are uppercase
111 record = dict((field.upper(), value) for field, value in record.items())
112 # The CSV file has a line in the middle of the file where the headers are repeated.
113 # We need to skip this line.
114 if record['TITLE'] == "TITLE" and record['AUTHOR'] == 'AUTHOR' and record['LYRICS2'] == 'LYRICS2':
115 continue
116 self.set_defaults()
117 verse_order_list = []
118 try:
119 self.title = record['TITLE']
120 if record['AUTHOR'] != EMPTY_STR:
121 self.parse_author(record['AUTHOR'])
122 print(record['AUTHOR'])
123 if record['COPYRIGHT'] != EMPTY_STR:
124 self.add_copyright(record['COPYRIGHT'])
125 if record['CCLINR'] != EMPTY_STR:
126 self.ccli_number = record['CCLINR']
127 if record['ROADMAP'] != EMPTY_STR:
128 verse_order_list = record['ROADMAP'].split(',')
129 lyrics = record['LYRICS2']
130 except UnicodeDecodeError as e:
131 self.log_error(translate('SongsPlugin.WorshipAssistantImport', 'Record %d' % index),
132 translate('SongsPlugin.WorshipAssistantImport', 'Decoding error: %s') % e)
133 continue
134 except TypeError as e:
135 self.log_error(translate('SongsPlugin.WorshipAssistantImport',
136 'File not valid WorshipAssistant CSV format.'), 'TypeError: %s' % e)
137 return
138 verse = ''
139 for line in lyrics.splitlines():
140 if line.startswith('['): # verse marker
141 # drop the square brackets
142 right_bracket = line.find(']')
143 content = line[1:right_bracket].lower()
144 match = re.match('(\D*)(\d+)', content)
145 if match is not None:
146 verse_tag = match.group(1)
147 verse_num = match.group(2)
148 else:
149 # otherwise we assume number 1 and take the whole prefix as the verse tag
150 verse_tag = content
151 verse_num = '1'
152 verse_index = VerseType.from_loose_input(verse_tag) if verse_tag else 0
153 verse_tag = VerseType.tags[verse_index]
154 # Update verse order when the verse name has changed
155 if content != verse_tag + verse_num:
156 for i in range(len(verse_order_list)):
157 if verse_order_list[i].lower() == content.lower():
158 verse_order_list[i] = verse_tag + verse_num
159 elif line and not line.isspace():
160 verse += line + '\n'
161 elif verse:
162 self.add_verse(verse, verse_tag+verse_num)
163 verse = ''
164 if verse:
165 self.add_verse(verse, verse_tag+verse_num)
166 if verse_order_list:
167 self.verse_order_list = verse_order_list
168 if not self.finish():
169 self.log_error(translate('SongsPlugin.WorshipAssistantImport', 'Record %d') % index
170 + (': "' + self.title + '"' if self.title else ''))
171 songs_file.close()
0172
=== modified file 'tests/functional/openlp_plugins/songs/test_opensongimport.py'
--- tests/functional/openlp_plugins/songs/test_opensongimport.py 2014-04-30 20:39:40 +0000
+++ tests/functional/openlp_plugins/songs/test_opensongimport.py 2014-06-30 07:21:09 +0000
@@ -52,11 +52,11 @@
52 """52 """
53 Test that loading an OpenSong file works correctly on various files53 Test that loading an OpenSong file works correctly on various files
54 """54 """
55 self.file_import(os.path.join(TEST_PATH, 'Amazing Grace'),55 self.file_import([os.path.join(TEST_PATH, 'Amazing Grace')],
56 self.load_external_result_data(os.path.join(TEST_PATH, 'Amazing Grace.json')))56 self.load_external_result_data(os.path.join(TEST_PATH, 'Amazing Grace.json')))
57 self.file_import(os.path.join(TEST_PATH, 'Beautiful Garden Of Prayer'),57 self.file_import([os.path.join(TEST_PATH, 'Beautiful Garden Of Prayer')],
58 self.load_external_result_data(os.path.join(TEST_PATH, 'Beautiful Garden Of Prayer.json')))58 self.load_external_result_data(os.path.join(TEST_PATH, 'Beautiful Garden Of Prayer.json')))
59 self.file_import(os.path.join(TEST_PATH, 'One, Two, Three, Four, Five'),59 self.file_import([os.path.join(TEST_PATH, 'One, Two, Three, Four, Five')],
60 self.load_external_result_data(os.path.join(TEST_PATH, 'One, Two, Three, Four, Five.json')))60 self.load_external_result_data(os.path.join(TEST_PATH, 'One, Two, Three, Four, Five.json')))
6161
6262
6363
=== modified file 'tests/functional/openlp_plugins/songs/test_propresenterimport.py'
--- tests/functional/openlp_plugins/songs/test_propresenterimport.py 2014-06-09 10:27:17 +0000
+++ tests/functional/openlp_plugins/songs/test_propresenterimport.py 2014-06-30 07:21:09 +0000
@@ -50,5 +50,5 @@
50 """50 """
51 Test that loading an ProPresenter file works correctly51 Test that loading an ProPresenter file works correctly
52 """52 """
53 self.file_import(os.path.join(TEST_PATH, 'Amazing Grace.pro4'),53 self.file_import([os.path.join(TEST_PATH, 'Amazing Grace.pro4')],
54 self.load_external_result_data(os.path.join(TEST_PATH, 'Amazing Grace.json')))54 self.load_external_result_data(os.path.join(TEST_PATH, 'Amazing Grace.json')))
5555
=== modified file 'tests/functional/openlp_plugins/songs/test_songshowplusimport.py'
--- tests/functional/openlp_plugins/songs/test_songshowplusimport.py 2014-05-11 04:45:30 +0000
+++ tests/functional/openlp_plugins/songs/test_songshowplusimport.py 2014-06-30 07:21:09 +0000
@@ -53,11 +53,11 @@
53 """53 """
54 Test that loading a SongShow Plus file works correctly on various files54 Test that loading a SongShow Plus file works correctly on various files
55 """55 """
56 self.file_import(os.path.join(TEST_PATH, 'Amazing Grace.sbsong'),56 self.file_import([os.path.join(TEST_PATH, 'Amazing Grace.sbsong')],
57 self.load_external_result_data(os.path.join(TEST_PATH, 'Amazing Grace.json')))57 self.load_external_result_data(os.path.join(TEST_PATH, 'Amazing Grace.json')))
58 self.file_import(os.path.join(TEST_PATH, 'Beautiful Garden Of Prayer.sbsong'),58 self.file_import([os.path.join(TEST_PATH, 'Beautiful Garden Of Prayer.sbsong')],
59 self.load_external_result_data(os.path.join(TEST_PATH, 'Beautiful Garden Of Prayer.json')))59 self.load_external_result_data(os.path.join(TEST_PATH, 'Beautiful Garden Of Prayer.json')))
60 self.file_import(os.path.join(TEST_PATH, 'a mighty fortress is our god.sbsong'),60 self.file_import([os.path.join(TEST_PATH, 'a mighty fortress is our god.sbsong')],
61 self.load_external_result_data(os.path.join(TEST_PATH, 'a mighty fortress is our god.json')))61 self.load_external_result_data(os.path.join(TEST_PATH, 'a mighty fortress is our god.json')))
6262
6363
6464
=== added file 'tests/functional/openlp_plugins/songs/test_worshipassistantimport.py'
--- tests/functional/openlp_plugins/songs/test_worshipassistantimport.py 1970-01-01 00:00:00 +0000
+++ tests/functional/openlp_plugins/songs/test_worshipassistantimport.py 2014-06-30 07:21:09 +0000
@@ -0,0 +1,56 @@
1# -*- coding: utf-8 -*-
2# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
3
4###############################################################################
5# OpenLP - Open Source Lyrics Projection #
6# --------------------------------------------------------------------------- #
7# Copyright (c) 2008-2013 Raoul Snyman #
8# Portions copyright (c) 2008-2013 Tim Bentley, Gerald Britton, Jonathan #
9# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, #
10# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. #
11# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, #
12# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, #
13# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, #
14# Frode Woldsund, Martin Zibricky, Patrick Zimmermann #
15# --------------------------------------------------------------------------- #
16# This program is free software; you can redistribute it and/or modify it #
17# under the terms of the GNU General Public License as published by the Free #
18# Software Foundation; version 2 of the License. #
19# #
20# This program is distributed in the hope that it will be useful, but WITHOUT #
21# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
22# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
23# more details. #
24# #
25# You should have received a copy of the GNU General Public License along #
26# with this program; if not, write to the Free Software Foundation, Inc., 59 #
27# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
28###############################################################################
29"""
30The :mod:`worshipassistantimport` module provides the functionality for importing
31WorshipAssistant song files into the current installation database.
32"""
33
34import os
35
36from tests.helpers.songfileimport import SongImportTestHelper
37
38TEST_PATH = os.path.abspath(
39 os.path.join(os.path.dirname(__file__), '..', '..', '..', 'resources', 'worshipassistantsongs'))
40
41
42class TestWorshipAssistantFileImport(SongImportTestHelper):
43
44 def __init__(self, *args, **kwargs):
45 self.importer_class_name = 'WorshipAssistantImport'
46 self.importer_module_name = 'worshipassistantimport'
47 super(TestWorshipAssistantFileImport, self).__init__(*args, **kwargs)
48
49 def test_song_import(self):
50 """
51 Test that loading an Worship Assistant file works correctly
52 """
53 self.file_import(os.path.join(TEST_PATH, 'du_herr.csv'),
54 self.load_external_result_data(os.path.join(TEST_PATH, 'du_herr.json')))
55 self.file_import(os.path.join(TEST_PATH, 'would_you_be_free.csv'),
56 self.load_external_result_data(os.path.join(TEST_PATH, 'would_you_be_free.json')))
057
=== modified file 'tests/helpers/songfileimport.py'
--- tests/helpers/songfileimport.py 2014-06-04 04:54:44 +0000
+++ tests/helpers/songfileimport.py 2014-06-30 07:21:09 +0000
@@ -95,7 +95,7 @@
95 importer.topics = []95 importer.topics = []
9696
97 # WHEN: Importing the source file97 # WHEN: Importing the source file
98 importer.import_source = [source_file_name]98 importer.import_source = source_file_name
99 add_verse_calls = self._get_data(result_data, 'verses')99 add_verse_calls = self._get_data(result_data, 'verses')
100 author_calls = self._get_data(result_data, 'authors')100 author_calls = self._get_data(result_data, 'authors')
101 ccli_number = self._get_data(result_data, 'ccli_number')101 ccli_number = self._get_data(result_data, 'ccli_number')
102102
=== added directory 'tests/resources/worshipassistantsongs'
=== added file 'tests/resources/worshipassistantsongs/du_herr.csv'
--- tests/resources/worshipassistantsongs/du_herr.csv 1970-01-01 00:00:00 +0000
+++ tests/resources/worshipassistantsongs/du_herr.csv 2014-06-30 07:21:09 +0000
@@ -0,0 +1,30 @@
1"SongID","SongNr","Title","Author","Copyright","FirstLine","PriKey","AltKey","Tempo","Focus","Theme","Scripture","Active","Songbook","TimeSig","Introduced","LastUsed","TimesUsed","CCLINr","User1","User2","User3","User4","User5","Roadmap","Overmap","FileLink1","FileLink2","Updated","Lyrics","Info","Lyrics2","Background"
2"4ee399dc-edda-4aa9-891e-a859ca093c78","NULL","Du, Herr, verläßt mich nicht","Carl Brockhaus / Johann Georg Bäßler 1806","NULL","NULL","NULL","NULL","NULL","NULL","NULL","NULL","1","1","NULL","NULL","NULL","NULL","NULL","NULL","NULL","NULL","NULL","NULL","NULL","NULL","NULL","NULL","2014-06-25 12:15:28.317","","NULL","[1]
3Du, Herr, verläßt mich nicht.
4Auf Dich mein Herz allein vertraut,
5Mein Auge glaubend auf Dich schaut.
6Du bist mein Heil, mein Licht,
7Mein Fels, mein sichrer Hort.
8Bin ich versucht, gibt's Not und Leid,
9Du bleibst mein Trost, mein Arm im Streit,
10Mein Licht am dunklen Ort.
11
12[2]
13Ich weiß, daß Du mich liebst.
14Bist mir in jeder Lage nah',
15Wohin ich gehe – Du bist da,
16Ja, Du mir alles gibst.
17Ich überlaß mich Dir;
18Denn Du, Herr, kennst mich ganz und gar
19Und führst mich sicher, wunderbar,
20Und bist selbst alles mir.
21
22[3]
23In dieser Wüste hier
24Find't nirgend meine Seele Ruh',
25Denn meine Ruh' bist, Jesu, Du.
26Wohl mir, ich geh' zu Dir!
27Bald werd' ich bei Dir sein,
28Bald mit den Deinen ewiglich
29Anbeten, loben, preisen Dich,
30Mich Deiner stets erfreun.","NULL"
031
=== added file 'tests/resources/worshipassistantsongs/du_herr.json'
--- tests/resources/worshipassistantsongs/du_herr.json 1970-01-01 00:00:00 +0000
+++ tests/resources/worshipassistantsongs/du_herr.json 2014-06-30 07:21:09 +0000
@@ -0,0 +1,21 @@
1{
2 "authors": [
3 "Carl Brockhaus / Johann Georg Bäßler 1806"
4 ],
5 "title": "Du, Herr, verläßt mich nicht",
6 "verse_order_list": [],
7 "verses": [
8 [
9 "Du, Herr, verläßt mich nicht.\nAuf Dich mein Herz allein vertraut,\nMein Auge glaubend auf Dich schaut.\nDu bist mein Heil, mein Licht,\nMein Fels, mein sichrer Hort.\nBin ich versucht, gibt's Not und Leid,\nDu bleibst mein Trost, mein Arm im Streit,\nMein Licht am dunklen Ort.\n",
10 "v1"
11 ],
12 [
13 "Ich weiß, daß Du mich liebst.\nBist mir in jeder Lage nah',\nWohin ich gehe – Du bist da,\nJa, Du mir alles gibst.\nIch überlaß mich Dir;\nDenn Du, Herr, kennst mich ganz und gar\nUnd führst mich sicher, wunderbar,\nUnd bist selbst alles mir.\n",
14 "v2"
15 ],
16 [
17 "In dieser Wüste hier\nFind't nirgend meine Seele Ruh',\nDenn meine Ruh' bist, Jesu, Du.\nWohl mir, ich geh' zu Dir!\nBald werd' ich bei Dir sein,\nBald mit den Deinen ewiglich\nAnbeten, loben, preisen Dich,\nMich Deiner stets erfreun.\n",
18 "v3"
19 ]
20 ]
21}
022
=== added file 'tests/resources/worshipassistantsongs/would_you_be_free.csv'
--- tests/resources/worshipassistantsongs/would_you_be_free.csv 1970-01-01 00:00:00 +0000
+++ tests/resources/worshipassistantsongs/would_you_be_free.csv 2014-06-30 07:21:09 +0000
@@ -0,0 +1,30 @@
1SONGNR,TITLE,AUTHOR,COPYRIGHT,FIRSTLINE,PRIKEY,ALTKEY,TEMPO,FOCUS,THEME,SCRIPTURE,ACTIVE,SONGBOOK,TIMESIG,INTRODUCED,LASTUSED,TIMESUSED,CCLINR,USER1,USER2,USER3,USER4,USER5,ROADMAP,FILELINK1,OVERMAP,FILELINK2,LYRICS,INFO,LYRICS2,Background
2"7","Would You Be Free","Jones, Lewis E.","Public Domain","Would you be free from your burden of sin?","G","","Moderate","Only To Others","","","N","Y","","1899-12-30","1899-12-30","","","","","","","","1,C,1","","","",".G C G
3 Would you be free from your burden of sin?
4. D D7 G
5 There's power in the blood, power in the blood
6. C G
7 Would you o'er evil a victory win?
8. D D7 G
9 There's wonderful power in the blood
10
11.G C G
12 There is power, power, wonder working power
13.D G
14 In the blood of the Lamb
15. C G
16 There is power, power, wonder working power
17. D G
18 In the precious blood of the Lamb
19","","[1]
20Would you be free from your burden of sin?
21There's power in the blood, power in the blood
22Would you o'er evil a victory win?
23There's wonderful power in the blood
24
25[C]
26There is power, power, wonder working power
27In the blood of the Lamb
28There is power, power, wonder working power
29In the precious blood of the Lamb
30",""
031
=== added file 'tests/resources/worshipassistantsongs/would_you_be_free.json'
--- tests/resources/worshipassistantsongs/would_you_be_free.json 1970-01-01 00:00:00 +0000
+++ tests/resources/worshipassistantsongs/would_you_be_free.json 2014-06-30 07:21:09 +0000
@@ -0,0 +1,19 @@
1{
2 "authors": [
3 "Jones",
4 "Lewis E"
5 ],
6 "title": "Would You Be Free",
7 "verse_order_list": ["v1", "c1", "v1"],
8 "copyright": "Public Domain",
9 "verses": [
10 [
11 "Would you be free from your burden of sin? \nThere's power in the blood, power in the blood \nWould you o'er evil a victory win? \nThere's wonderful power in the blood \n",
12 "v1"
13 ],
14 [
15 "There is power, power, wonder working power \nIn the blood of the Lamb \nThere is power, power, wonder working power \nIn the precious blood of the Lamb \n",
16 "c1"
17 ]
18 ]
19}
020
=== modified file 'tests/utils/test_bzr_tags.py'
--- tests/utils/test_bzr_tags.py 2014-05-03 15:34:13 +0000
+++ tests/utils/test_bzr_tags.py 2014-06-30 07:21:09 +0000
@@ -50,10 +50,6 @@
50 ['1.9.11', '2039'],50 ['1.9.11', '2039'],
51 ['1.9.12', '2063'],51 ['1.9.12', '2063'],
52 ['2.0', '2118'],52 ['2.0', '2118'],
53 ['2.0.1', '?'],
54 ['2.0.2', '?'],
55 ['2.0.3', '?'],
56 ['2.0.4', '?'],
57 ['2.1.0', '2119']53 ['2.1.0', '2119']
58]54]
5955