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: 340 lines (+203/-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 (+142/-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
Jonathan Corwin (community) Needs Fixing
Andreas Preikschat Pending
Review via email: mp+99213@code.launchpad.net

This proposal supersedes a proposal from 2012-03-24.

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

Description of the change

Adds DreamBeam song importer.
Small fix for SongShowPlus importer.
Removed errant print statment

Fixed doc string

To post a comment you must log in.
Revision history for this message
Andreas Preikschat (googol-deactivatedaccount) wrote : Posted in a previous version of this proposal

The docstring should rather look like this:

    An example of DreamBeam xml mark-up::

        <?xml version="1.0"?>
        <DreamSong xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xmlns:xsd="http://www.w3.org/2001/XMLSchema">
          <WordWrap>false</WordWrap>
          <Version>0.80</Version>
          <Title>Amazing Grace</Title>
          <Author>John Newton</Author>
          <Collection />
          <Number />
          <Notes />
          <KeyRangeLow>F</KeyRangeLow>
          <KeyRangeHigh>G</KeyRangeHigh>
          <MinorKey>false</MinorKey>
          <DualLanguage>false</DualLanguage>
          <SongLyrics>
            <LyricsItem Type="Verse" Number="1">Amazing Grace, how sweet the sound,
            That saved a wretch like me.
            I once was lost but now am found,
            Was blind, but now, I see.</LyricsItem>
            <LyricsItem Type="Verse" Number="2">T’was Grace that taught my heart to fear.
        And Grace, my fears relieved.
        How precious did that Grace appear…
        the hour I first believed.</LyricsItem>
          </SongLyrics>
          <Sequence>
            <LyricsSequenceItem Type="Verse" Number="1" />
            <LyricsSequenceItem Type="Verse" Number="2" />
          </Sequence>
          <ShowRectangles>false</ShowRectangles>
        </DreamSong>

    Valid extensions for a DreamBeam song file are:

        * \*.xml

My version: http://rst.ninjs.org/?n=8cccf5fe3208cfcc6825032d63484a78&theme=basic
Your version: http://rst.ninjs.org/?n=992060bbf63648d8cda3ae1b7e3b07cc&theme=basic

review: Needs Fixing
Revision history for this message
Jonathan Corwin (j-corwin) wrote :

162: Just one space after the comma
167-170: Just one blank line please
218: Fix comment to say DreamBeam
251: field not feild
340: Spacing is SongShow Plus

review: Needs Fixing
lp:~phill-ridout/openlp/DreamBeam updated
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-27 20:15:24 +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-27 20:15:24 +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-27 20:15:24 +0000
128@@ -0,0 +1,142 @@
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+log = logging.getLogger(__name__)
169+
170+class DreamBeamImport(SongImport):
171+ """
172+ The :class:`DreamBeamImport` class provides the ability to import song files from
173+ DreamBeam.
174+
175+ An example of DreamBeam xml mark-up::
176+
177+ <?xml version="1.0"?>
178+ <DreamSong xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
179+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
180+ <WordWrap>false</WordWrap>
181+ <Version>0.80</Version>
182+ <Title>Amazing Grace</Title>
183+ <Author>John Newton</Author>
184+ <Collection />
185+ <Number />
186+ <Notes />
187+ <KeyRangeLow>F</KeyRangeLow>
188+ <KeyRangeHigh>G</KeyRangeHigh>
189+ <MinorKey>false</MinorKey>
190+ <DualLanguage>false</DualLanguage>
191+ <SongLyrics>
192+ <LyricsItem Type="Verse" Number="1">Amazing Grace, how sweet the sound,
193+ That saved a wretch like me.
194+ I once was lost but now am found,
195+ Was blind, but now, I see.</LyricsItem>
196+ <LyricsItem Type="Verse" Number="2">T’was Grace that taught my heart to fear.
197+ And Grace, my fears relieved.
198+ How precious did that Grace appear…
199+ the hour I first believed.</LyricsItem>
200+ </SongLyrics>
201+ <Sequence>
202+ <LyricsSequenceItem Type="Verse" Number="1" />
203+ <LyricsSequenceItem Type="Verse" Number="2" />
204+ </Sequence>
205+ <ShowRectangles>false</ShowRectangles>
206+ </DreamSong>
207+
208+ Valid extensions for a DreamBeam song file are:
209+
210+ * \*.xml
211+ """
212+
213+ def __init__(self, manager, **kwargs):
214+ """
215+ Initialise the DreamBeam importer.
216+ """
217+ SongImport.__init__(self, manager, **kwargs)
218+
219+ def doImport(self):
220+ """
221+ Receive a single file or a list of files to import.
222+ """
223+ if isinstance(self.importSource, list):
224+ self.importWizard.progressBar.setMaximum(len(self.importSource))
225+ for file in self.importSource:
226+ if self.stopImportFlag:
227+ return
228+ self.setDefaults()
229+ parser = etree.XMLParser(remove_blank_text=True)
230+ try:
231+ parsed_file = etree.parse(open(file, u'r'), parser)
232+ except etree.XMLSyntaxError:
233+ log.exception(u'XML syntax error in file %s' % file)
234+ self.logError(file, SongStrings.XMLSyntaxError)
235+ continue
236+ xml = unicode(etree.tostring(parsed_file))
237+ song_xml = objectify.fromstring(xml)
238+ if song_xml.tag != u'DreamSong':
239+ self.logError(file, unicode(
240+ translate('SongsPlugin.DreamBeamImport',
241+ ('Invalid DreamBeam song file. Missing '
242+ 'DreamSong tag.'))))
243+ continue
244+ if hasattr(song_xml, u'Title'):
245+ self.title = unicode(song_xml.Title.text)
246+ if hasattr(song_xml, u'Author'):
247+ # DreamBeam does not have a copyright field, instead it
248+ # some times uses the author field
249+ self.addCopyright(unicode(song_xml.Author.text))
250+ self.parseAuthor(unicode(song_xml.Author.text))
251+ if hasattr(song_xml, u'SongLyrics'):
252+ for lyrics_item in song_xml.SongLyrics.iterchildren():
253+ verse_type = lyrics_item.get(u'Type')
254+ verse_number = lyrics_item.get(u'Number')
255+ verse_text = unicode(lyrics_item.text)
256+ self.addVerse(verse_text,
257+ (u'%s%s' % (verse_type[:1], verse_number)))
258+ if hasattr(song_xml, u'Collection'):
259+ self.songBookName = unicode(song_xml.Collection.text)
260+ if hasattr(song_xml, u'Number'):
261+ self.songNumber = unicode(song_xml.Number.text)
262+ if hasattr(song_xml, u'Sequence'):
263+ for LyricsSequenceItem in song_xml.Sequence.iterchildren():
264+ self.verseOrderList.append(
265+ "%s%s" % (LyricsSequenceItem.get(u'Type')[:1],
266+ LyricsSequenceItem.get(u'Number')))
267+ if hasattr(song_xml, u'Notes'):
268+ self.comments = unicode(song_xml.Notes.text)
269+ if not self.finish():
270+ self.logError(file)
271
272=== modified file 'openlp/plugins/songs/lib/importer.py'
273--- openlp/plugins/songs/lib/importer.py 2011-12-31 14:18:05 +0000
274+++ openlp/plugins/songs/lib/importer.py 2012-03-27 20:15:24 +0000
275@@ -35,6 +35,7 @@
276 from openlyricsimport import OpenLyricsImport
277 from wowimport import WowImport
278 from cclifileimport import CCLIFileImport
279+from dreambeamimport import DreamBeamImport
280 from ewimport import EasyWorshipSongImport
281 from songbeamerimport import SongBeamerImport
282 from songshowplusimport import SongShowPlusImport
283@@ -73,15 +74,16 @@
284 OpenLP1 = 2
285 Generic = 3
286 CCLI = 4
287- EasySlides = 5
288- EasyWorship = 6
289- FoilPresenter = 7
290- OpenSong = 8
291- SongBeamer = 9
292- SongShowPlus = 10
293- SongsOfFellowship = 11
294- WordsOfWorship = 12
295- #CSV = 13
296+ DreamBeam = 5
297+ EasySlides = 6
298+ EasyWorship = 7
299+ FoilPresenter = 8
300+ OpenSong = 9
301+ SongBeamer = 10
302+ SongShowPlus = 11
303+ SongsOfFellowship = 12
304+ WordsOfWorship = 13
305+ #CSV = 14
306
307 @staticmethod
308 def get_class(format):
309@@ -107,6 +109,8 @@
310 return OooImport
311 elif format == SongFormat.CCLI:
312 return CCLIFileImport
313+ elif format == SongFormat.DreamBeam:
314+ return DreamBeamImport
315 elif format == SongFormat.EasySlides:
316 return EasySlidesImport
317 elif format == SongFormat.EasyWorship:
318@@ -130,6 +134,7 @@
319 SongFormat.OpenLP1,
320 SongFormat.Generic,
321 SongFormat.CCLI,
322+ SongFormat.DreamBeam,
323 SongFormat.EasySlides,
324 SongFormat.EasyWorship,
325 SongFormat.FoilPresenter,
326
327=== modified file 'openlp/plugins/songs/lib/songshowplusimport.py'
328--- openlp/plugins/songs/lib/songshowplusimport.py 2011-12-27 10:33:55 +0000
329+++ openlp/plugins/songs/lib/songshowplusimport.py 2012-03-27 20:15:24 +0000
330@@ -25,8 +25,8 @@
331 # Temple Place, Suite 330, Boston, MA 02111-1307 USA #
332 ###############################################################################
333 """
334-The :mod:`wowimport` module provides the functionality for importing Words of
335-Worship songs into the OpenLP database.
336+The :mod:`songshowplusimport` module provides the functionality for importing
337+SongShow Plus songs into the OpenLP database.
338 """
339 import os
340 import logging