Merge lp:~phill-ridout/openlp/DreamBeam into lp:openlp

Proposed by Phill
Status: Superseded
Proposed branch: lp:~phill-ridout/openlp/DreamBeam
Merge into: lp:openlp
Diff against target: 343 lines (+206/-12)
5 files modified
openlp/core/ui/wizard.py (+1/-0)
openlp/plugins/songs/forms/songimportform.py (+44/-1)
openlp/plugins/songs/lib/dreambeamimport.py (+145/-0)
openlp/plugins/songs/lib/importer.py (+14/-9)
openlp/plugins/songs/lib/songshowplusimport.py (+2/-2)
To merge this branch: bzr merge lp:~phill-ridout/openlp/DreamBeam
Reviewer Review Type Date Requested Status
OpenLP Core Pending
Review via email: mp+99177@code.launchpad.net

This proposal has been superseded by a proposal from 2012-03-24.

Description of the change

Adds DreamBeam song importer.
Small fix for SongShowPlus importer.

To post a comment you must log in.
lp:~phill-ridout/openlp/DreamBeam updated
1918. By Phill

Removed errant print statment

1919. By Phill

Changed Restructured text layout

1920. By Phill

Made changes as to Jonathan's requests

1921. By Phill

Remove constructor as per Raouls comment.

1922. By Phill

Made changes as per Andreas comments.

1923. By Phill

Added support for ALL DreamBeam file formats.

1924. By Phill

Fixed case when there is no version information

1925. By Phill

changed file version handeling.

Added check for (c) symbol if not use it for the author

1926. By Phill

removed import that sliped in!

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'openlp/core/ui/wizard.py'
2--- openlp/core/ui/wizard.py 2011-12-31 14:18:05 +0000
3+++ openlp/core/ui/wizard.py 2012-03-24 18:23:20 +0000
4@@ -46,6 +46,7 @@
5 # the writers translating their own product name.
6 CCLI = u'CCLI/SongSelect'
7 CSV = u'CSV'
8+ DB = u'DreamBeam'
9 EW = u'EasyWorship'
10 ES = u'EasySlides'
11 FP = u'Foilpresenter'
12
13=== modified file 'openlp/plugins/songs/forms/songimportform.py'
14--- openlp/plugins/songs/forms/songimportform.py 2011-12-31 14:18:05 +0000
15+++ openlp/plugins/songs/forms/songimportform.py 2012-03-24 18:23:20 +0000
16@@ -129,6 +129,12 @@
17 QtCore.QObject.connect(self.ccliRemoveButton,
18 QtCore.SIGNAL(u'clicked()'),
19 self.onCCLIRemoveButtonClicked)
20+ QtCore.QObject.connect(self.dreamBeamAddButton,
21+ QtCore.SIGNAL(u'clicked()'),
22+ self.onDreamBeamAddButtonClicked)
23+ QtCore.QObject.connect(self.dreamBeamRemoveButton,
24+ QtCore.SIGNAL(u'clicked()'),
25+ self.onDreamBeamRemoveButtonClicked)
26 QtCore.QObject.connect(self.songsOfFellowshipAddButton,
27 QtCore.SIGNAL(u'clicked()'),
28 self.onSongsOfFellowshipAddButtonClicked)
29@@ -201,6 +207,8 @@
30 self.addFileSelectItem(u'generic', None, True)
31 # CCLI File import
32 self.addFileSelectItem(u'ccli')
33+ # DreamBeam
34+ self.addFileSelectItem(u'dreamBeam')
35 # EasySlides
36 self.addFileSelectItem(u'easySlides', single_select=True)
37 # EasyWorship
38@@ -248,6 +256,8 @@
39 'Generic Document/Presentation'))
40 self.formatComboBox.setItemText(SongFormat.CCLI, WizardStrings.CCLI)
41 self.formatComboBox.setItemText(
42+ SongFormat.DreamBeam, WizardStrings.DB)
43+ self.formatComboBox.setItemText(
44 SongFormat.EasySlides, WizardStrings.ES)
45 self.formatComboBox.setItemText(
46 SongFormat.EasyWorship, WizardStrings.EW)
47@@ -291,6 +301,10 @@
48 translate('SongsPlugin.ImportWizardForm', 'Add Files...'))
49 self.ccliRemoveButton.setText(
50 translate('SongsPlugin.ImportWizardForm', 'Remove File(s)'))
51+ self.dreamBeamAddButton.setText(
52+ translate('SongsPlugin.ImportWizardForm', 'Add Files...'))
53+ self.dreamBeamRemoveButton.setText(
54+ translate('SongsPlugin.ImportWizardForm', 'Remove File(s)'))
55 self.songsOfFellowshipAddButton.setText(
56 translate('SongsPlugin.ImportWizardForm', 'Add Files...'))
57 self.songsOfFellowshipRemoveButton.setText(
58@@ -397,6 +411,12 @@
59 WizardStrings.YouSpecifyFile % WizardStrings.CCLI)
60 self.ccliAddButton.setFocus()
61 return False
62+ elif source_format == SongFormat.DreamBeam:
63+ if self.dreamBeamFileListWidget.count() == 0:
64+ critical_error_message_box(UiStrings().NFSp,
65+ WizardStrings.YouSpecifyFile % WizardStrings.DB)
66+ self.dreamBeamAddButton.setFocus()
67+ return False
68 elif source_format == SongFormat.SongsOfFellowship:
69 if self.songsOfFellowshipFileListWidget.count() == 0:
70 critical_error_message_box(UiStrings().NFSp,
71@@ -433,7 +453,7 @@
72 if self.songShowPlusFileListWidget.count() == 0:
73 critical_error_message_box(UiStrings().NFSp,
74 WizardStrings.YouSpecifyFile % WizardStrings.SSP)
75- self.wordsOfWorshipAddButton.setFocus()
76+ self.songShowPlusAddButton.setFocus()
77 return False
78 elif source_format == SongFormat.FoilPresenter:
79 if self.foilPresenterFileListWidget.count() == 0:
80@@ -562,6 +582,22 @@
81 """
82 self.removeSelectedItems(self.ccliFileListWidget)
83
84+ def onDreamBeamAddButtonClicked(self):
85+ """
86+ Get DreamBeam song database files
87+ """
88+ self.getFiles(WizardStrings.OpenTypeFile % WizardStrings.DB,
89+ self.dreamBeamFileListWidget, u'%s (*.xml)'
90+ % translate('SongsPlugin.ImportWizardForm',
91+ 'DreamBeam Song Files')
92+ )
93+
94+ def onDreamBeamRemoveButtonClicked(self):
95+ """
96+ Remove selected DreamBeam files from the import list
97+ """
98+ self.removeSelectedItems(self.dreamBeamFileListWidget)
99+
100 def onSongsOfFellowshipAddButtonClicked(self):
101 """
102 Get Songs of Fellowship song database files
103@@ -671,6 +707,7 @@
104 self.openSongFileListWidget.clear()
105 self.wordsOfWorshipFileListWidget.clear()
106 self.ccliFileListWidget.clear()
107+ self.dreamBeamFileListWidget.clear()
108 self.songsOfFellowshipFileListWidget.clear()
109 self.genericFileListWidget.clear()
110 self.easySlidesFilenameEdit.setText(u'')
111@@ -732,6 +769,12 @@
112 importer = self.plugin.importSongs(SongFormat.CCLI,
113 filenames=self.getListOfFiles(self.ccliFileListWidget)
114 )
115+ elif source_format == SongFormat.DreamBeam:
116+ # Import DreamBeam songs
117+ importer = self.plugin.importSongs(SongFormat.DreamBeam,
118+ filenames=self.getListOfFiles(
119+ self.dreamBeamFileListWidget)
120+ )
121 elif source_format == SongFormat.SongsOfFellowship:
122 # Import a Songs of Fellowship RTF file
123 importer = self.plugin.importSongs(SongFormat.SongsOfFellowship,
124
125=== added file 'openlp/plugins/songs/lib/dreambeamimport.py'
126--- openlp/plugins/songs/lib/dreambeamimport.py 1970-01-01 00:00:00 +0000
127+++ openlp/plugins/songs/lib/dreambeamimport.py 2012-03-24 18:23:20 +0000
128@@ -0,0 +1,145 @@
129+# -*- coding: utf-8 -*-
130+# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
131+
132+###############################################################################
133+# OpenLP - Open Source Lyrics Projection #
134+# --------------------------------------------------------------------------- #
135+# Copyright (c) 2008-2012 Raoul Snyman #
136+# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan #
137+# Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, #
138+# Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias #
139+# Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, #
140+# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Frode Woldsund #
141+# --------------------------------------------------------------------------- #
142+# This program is free software; you can redistribute it and/or modify it #
143+# under the terms of the GNU General Public License as published by the Free #
144+# Software Foundation; version 2 of the License. #
145+# #
146+# This program is distributed in the hope that it will be useful, but WITHOUT #
147+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
148+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
149+# more details. #
150+# #
151+# You should have received a copy of the GNU General Public License along #
152+# with this program; if not, write to the Free Software Foundation, Inc., 59 #
153+# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
154+###############################################################################
155+"""
156+The :mod:`dreambeamimport` module provides the functionality for importing
157+DreamBeam songs into the OpenLP database.
158+"""
159+import os, sys
160+import logging
161+
162+from lxml import etree, objectify
163+
164+from openlp.core.lib import translate
165+from openlp.plugins.songs.lib.songimport import SongImport
166+from openlp.plugins.songs.lib.ui import SongStrings
167+
168+
169+
170+
171+log = logging.getLogger(__name__)
172+
173+class DreamBeamImport(SongImport):
174+ """
175+ The :class:`DreamBeamImport` class provides the ability to import song files from
176+ DreamBeam.
177+
178+ An example of DreamBeam xml mark-up:
179+
180+ <?xml version="1.0"?>
181+ <DreamSong xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
182+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
183+ <WordWrap>false</WordWrap>
184+ <Version>0.80</Version>
185+ <Title>Amazing Grace</Title>
186+ <Author>John Newton</Author>
187+ <Collection />
188+ <Number />
189+ <Notes />
190+ <KeyRangeLow>F</KeyRangeLow>
191+ <KeyRangeHigh>G</KeyRangeHigh>
192+ <MinorKey>false</MinorKey>
193+ <DualLanguage>false</DualLanguage>
194+ <SongLyrics>
195+ <LyricsItem Type="Verse" Number="1">Amazing Grace, how sweet the sound,
196+ That saved a wretch like me.
197+ I once was lost but now am found,
198+ Was blind, but now, I see.</LyricsItem>
199+ <LyricsItem Type="Verse" Number="2">T’was Grace that taught my heart to fear.
200+ And Grace, my fears relieved.
201+ How precious did that Grace appear…
202+ the hour I first believed.</LyricsItem>
203+ </SongLyrics>
204+ <Sequence>
205+ <LyricsSequenceItem Type="Verse" Number="1" />
206+ <LyricsSequenceItem Type="Verse" Number="2" />
207+ </Sequence>
208+ <ShowRectangles>false</ShowRectangles>
209+ </DreamSong>
210+
211+ Valid extensions for a DreamBeam song file are:
212+
213+ * .xml
214+ """
215+
216+ def __init__(self, manager, **kwargs):
217+ """
218+ Initialise the Words of Worship importer.
219+ """
220+ SongImport.__init__(self, manager, **kwargs)
221+
222+ def doImport(self):
223+ """
224+ Receive a single file or a list of files to import.
225+ """
226+ if isinstance(self.importSource, list):
227+ self.importWizard.progressBar.setMaximum(len(self.importSource))
228+ for file in self.importSource:
229+ if self.stopImportFlag:
230+ return
231+ self.setDefaults()
232+ parser = etree.XMLParser(remove_blank_text=True)
233+ try:
234+ parsed_file = etree.parse(open(file, u'r'), parser)
235+ except etree.XMLSyntaxError:
236+ log.exception(u'XML syntax error in file %s' % file)
237+ self.logError(file, SongStrings.XMLSyntaxError)
238+ continue
239+ xml = unicode(etree.tostring(parsed_file))
240+ song_xml = objectify.fromstring(xml)
241+ if song_xml.tag != u'DreamSong':
242+ self.logError(file, unicode(
243+ translate('SongsPlugin.DreamBeamImport',
244+ ('Invalid DreamBeam song file. Missing '
245+ 'DreamSong tag.'))))
246+ continue
247+ if hasattr(song_xml, u'Title'):
248+ self.title = unicode(song_xml.Title.text)
249+ if hasattr(song_xml, u'Author'):
250+ # Dreambeam does not have a copyright field, instead it
251+ # some times uses the author feild
252+ self.addCopyright(unicode(song_xml.Author.text))
253+ self.parseAuthor(unicode(song_xml.Author.text))
254+ if hasattr(song_xml, u'SongLyrics'):
255+ for lyrics_item in song_xml.SongLyrics.iterchildren():
256+ verse_type = lyrics_item.get(u'Type')
257+ verse_number = lyrics_item.get(u'Number')
258+ verse_text = unicode(lyrics_item.text)
259+ self.addVerse(verse_text,
260+ (u'%s%s' % (verse_type[:1], verse_number)))
261+ if hasattr(song_xml, u'Collection'):
262+ self.songBookName = unicode(song_xml.Collection.text)
263+ if hasattr(song_xml, u'Number'):
264+ self.songNumber = unicode(song_xml.Number.text)
265+ if hasattr(song_xml, u'Sequence'):
266+ for LyricsSequenceItem in song_xml.Sequence.iterchildren():
267+ self.verseOrderList.append(
268+ "%s%s" % (LyricsSequenceItem.get(u'Type')[:1],
269+ LyricsSequenceItem.get(u'Number')))
270+ if hasattr(song_xml, u'Notes'):
271+ self.comments = unicode(song_xml.Notes.text)
272+ if not self.finish():
273+ self.logError(file)
274
275=== modified file 'openlp/plugins/songs/lib/importer.py'
276--- openlp/plugins/songs/lib/importer.py 2011-12-31 14:18:05 +0000
277+++ openlp/plugins/songs/lib/importer.py 2012-03-24 18:23:20 +0000
278@@ -35,6 +35,7 @@
279 from openlyricsimport import OpenLyricsImport
280 from wowimport import WowImport
281 from cclifileimport import CCLIFileImport
282+from dreambeamimport import DreamBeamImport
283 from ewimport import EasyWorshipSongImport
284 from songbeamerimport import SongBeamerImport
285 from songshowplusimport import SongShowPlusImport
286@@ -73,15 +74,16 @@
287 OpenLP1 = 2
288 Generic = 3
289 CCLI = 4
290- EasySlides = 5
291- EasyWorship = 6
292- FoilPresenter = 7
293- OpenSong = 8
294- SongBeamer = 9
295- SongShowPlus = 10
296- SongsOfFellowship = 11
297- WordsOfWorship = 12
298- #CSV = 13
299+ DreamBeam = 5
300+ EasySlides = 6
301+ EasyWorship = 7
302+ FoilPresenter = 8
303+ OpenSong = 9
304+ SongBeamer = 10
305+ SongShowPlus = 11
306+ SongsOfFellowship = 12
307+ WordsOfWorship = 13
308+ #CSV = 14
309
310 @staticmethod
311 def get_class(format):
312@@ -107,6 +109,8 @@
313 return OooImport
314 elif format == SongFormat.CCLI:
315 return CCLIFileImport
316+ elif format == SongFormat.DreamBeam:
317+ return DreamBeamImport
318 elif format == SongFormat.EasySlides:
319 return EasySlidesImport
320 elif format == SongFormat.EasyWorship:
321@@ -130,6 +134,7 @@
322 SongFormat.OpenLP1,
323 SongFormat.Generic,
324 SongFormat.CCLI,
325+ SongFormat.DreamBeam,
326 SongFormat.EasySlides,
327 SongFormat.EasyWorship,
328 SongFormat.FoilPresenter,
329
330=== modified file 'openlp/plugins/songs/lib/songshowplusimport.py'
331--- openlp/plugins/songs/lib/songshowplusimport.py 2011-12-27 10:33:55 +0000
332+++ openlp/plugins/songs/lib/songshowplusimport.py 2012-03-24 18:23:20 +0000
333@@ -25,8 +25,8 @@
334 # Temple Place, Suite 330, Boston, MA 02111-1307 USA #
335 ###############################################################################
336 """
337-The :mod:`wowimport` module provides the functionality for importing Words of
338-Worship songs into the OpenLP database.
339+The :mod:`songshowplusimport` module provides the functionality for importing
340+Song Show Plus songs into the OpenLP database.
341 """
342 import os
343 import logging