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
=== modified file 'openlp/core/ui/wizard.py'
--- openlp/core/ui/wizard.py 2011-12-31 14:18:05 +0000
+++ openlp/core/ui/wizard.py 2012-03-27 20:15:24 +0000
@@ -46,6 +46,7 @@
46 # the writers translating their own product name.46 # the writers translating their own product name.
47 CCLI = u'CCLI/SongSelect'47 CCLI = u'CCLI/SongSelect'
48 CSV = u'CSV'48 CSV = u'CSV'
49 DB = u'DreamBeam'
49 EW = u'EasyWorship'50 EW = u'EasyWorship'
50 ES = u'EasySlides'51 ES = u'EasySlides'
51 FP = u'Foilpresenter'52 FP = u'Foilpresenter'
5253
=== modified file 'openlp/plugins/songs/forms/songimportform.py'
--- openlp/plugins/songs/forms/songimportform.py 2011-12-31 14:18:05 +0000
+++ openlp/plugins/songs/forms/songimportform.py 2012-03-27 20:15:24 +0000
@@ -129,6 +129,12 @@
129 QtCore.QObject.connect(self.ccliRemoveButton,129 QtCore.QObject.connect(self.ccliRemoveButton,
130 QtCore.SIGNAL(u'clicked()'),130 QtCore.SIGNAL(u'clicked()'),
131 self.onCCLIRemoveButtonClicked)131 self.onCCLIRemoveButtonClicked)
132 QtCore.QObject.connect(self.dreamBeamAddButton,
133 QtCore.SIGNAL(u'clicked()'),
134 self.onDreamBeamAddButtonClicked)
135 QtCore.QObject.connect(self.dreamBeamRemoveButton,
136 QtCore.SIGNAL(u'clicked()'),
137 self.onDreamBeamRemoveButtonClicked)
132 QtCore.QObject.connect(self.songsOfFellowshipAddButton,138 QtCore.QObject.connect(self.songsOfFellowshipAddButton,
133 QtCore.SIGNAL(u'clicked()'),139 QtCore.SIGNAL(u'clicked()'),
134 self.onSongsOfFellowshipAddButtonClicked)140 self.onSongsOfFellowshipAddButtonClicked)
@@ -201,6 +207,8 @@
201 self.addFileSelectItem(u'generic', None, True)207 self.addFileSelectItem(u'generic', None, True)
202 # CCLI File import208 # CCLI File import
203 self.addFileSelectItem(u'ccli')209 self.addFileSelectItem(u'ccli')
210 # DreamBeam
211 self.addFileSelectItem(u'dreamBeam')
204 # EasySlides212 # EasySlides
205 self.addFileSelectItem(u'easySlides', single_select=True)213 self.addFileSelectItem(u'easySlides', single_select=True)
206 # EasyWorship214 # EasyWorship
@@ -248,6 +256,8 @@
248 'Generic Document/Presentation'))256 'Generic Document/Presentation'))
249 self.formatComboBox.setItemText(SongFormat.CCLI, WizardStrings.CCLI)257 self.formatComboBox.setItemText(SongFormat.CCLI, WizardStrings.CCLI)
250 self.formatComboBox.setItemText(258 self.formatComboBox.setItemText(
259 SongFormat.DreamBeam, WizardStrings.DB)
260 self.formatComboBox.setItemText(
251 SongFormat.EasySlides, WizardStrings.ES)261 SongFormat.EasySlides, WizardStrings.ES)
252 self.formatComboBox.setItemText(262 self.formatComboBox.setItemText(
253 SongFormat.EasyWorship, WizardStrings.EW)263 SongFormat.EasyWorship, WizardStrings.EW)
@@ -291,6 +301,10 @@
291 translate('SongsPlugin.ImportWizardForm', 'Add Files...'))301 translate('SongsPlugin.ImportWizardForm', 'Add Files...'))
292 self.ccliRemoveButton.setText(302 self.ccliRemoveButton.setText(
293 translate('SongsPlugin.ImportWizardForm', 'Remove File(s)'))303 translate('SongsPlugin.ImportWizardForm', 'Remove File(s)'))
304 self.dreamBeamAddButton.setText(
305 translate('SongsPlugin.ImportWizardForm', 'Add Files...'))
306 self.dreamBeamRemoveButton.setText(
307 translate('SongsPlugin.ImportWizardForm', 'Remove File(s)'))
294 self.songsOfFellowshipAddButton.setText(308 self.songsOfFellowshipAddButton.setText(
295 translate('SongsPlugin.ImportWizardForm', 'Add Files...'))309 translate('SongsPlugin.ImportWizardForm', 'Add Files...'))
296 self.songsOfFellowshipRemoveButton.setText(310 self.songsOfFellowshipRemoveButton.setText(
@@ -397,6 +411,12 @@
397 WizardStrings.YouSpecifyFile % WizardStrings.CCLI)411 WizardStrings.YouSpecifyFile % WizardStrings.CCLI)
398 self.ccliAddButton.setFocus()412 self.ccliAddButton.setFocus()
399 return False413 return False
414 elif source_format == SongFormat.DreamBeam:
415 if self.dreamBeamFileListWidget.count() == 0:
416 critical_error_message_box(UiStrings().NFSp,
417 WizardStrings.YouSpecifyFile % WizardStrings.DB)
418 self.dreamBeamAddButton.setFocus()
419 return False
400 elif source_format == SongFormat.SongsOfFellowship:420 elif source_format == SongFormat.SongsOfFellowship:
401 if self.songsOfFellowshipFileListWidget.count() == 0:421 if self.songsOfFellowshipFileListWidget.count() == 0:
402 critical_error_message_box(UiStrings().NFSp,422 critical_error_message_box(UiStrings().NFSp,
@@ -433,7 +453,7 @@
433 if self.songShowPlusFileListWidget.count() == 0:453 if self.songShowPlusFileListWidget.count() == 0:
434 critical_error_message_box(UiStrings().NFSp,454 critical_error_message_box(UiStrings().NFSp,
435 WizardStrings.YouSpecifyFile % WizardStrings.SSP)455 WizardStrings.YouSpecifyFile % WizardStrings.SSP)
436 self.wordsOfWorshipAddButton.setFocus()456 self.songShowPlusAddButton.setFocus()
437 return False457 return False
438 elif source_format == SongFormat.FoilPresenter:458 elif source_format == SongFormat.FoilPresenter:
439 if self.foilPresenterFileListWidget.count() == 0:459 if self.foilPresenterFileListWidget.count() == 0:
@@ -562,6 +582,22 @@
562 """582 """
563 self.removeSelectedItems(self.ccliFileListWidget)583 self.removeSelectedItems(self.ccliFileListWidget)
564584
585 def onDreamBeamAddButtonClicked(self):
586 """
587 Get DreamBeam song database files
588 """
589 self.getFiles(WizardStrings.OpenTypeFile % WizardStrings.DB,
590 self.dreamBeamFileListWidget, u'%s (*.xml)'
591 % translate('SongsPlugin.ImportWizardForm',
592 'DreamBeam Song Files')
593 )
594
595 def onDreamBeamRemoveButtonClicked(self):
596 """
597 Remove selected DreamBeam files from the import list
598 """
599 self.removeSelectedItems(self.dreamBeamFileListWidget)
600
565 def onSongsOfFellowshipAddButtonClicked(self):601 def onSongsOfFellowshipAddButtonClicked(self):
566 """602 """
567 Get Songs of Fellowship song database files603 Get Songs of Fellowship song database files
@@ -671,6 +707,7 @@
671 self.openSongFileListWidget.clear()707 self.openSongFileListWidget.clear()
672 self.wordsOfWorshipFileListWidget.clear()708 self.wordsOfWorshipFileListWidget.clear()
673 self.ccliFileListWidget.clear()709 self.ccliFileListWidget.clear()
710 self.dreamBeamFileListWidget.clear()
674 self.songsOfFellowshipFileListWidget.clear()711 self.songsOfFellowshipFileListWidget.clear()
675 self.genericFileListWidget.clear()712 self.genericFileListWidget.clear()
676 self.easySlidesFilenameEdit.setText(u'')713 self.easySlidesFilenameEdit.setText(u'')
@@ -732,6 +769,12 @@
732 importer = self.plugin.importSongs(SongFormat.CCLI,769 importer = self.plugin.importSongs(SongFormat.CCLI,
733 filenames=self.getListOfFiles(self.ccliFileListWidget)770 filenames=self.getListOfFiles(self.ccliFileListWidget)
734 )771 )
772 elif source_format == SongFormat.DreamBeam:
773 # Import DreamBeam songs
774 importer = self.plugin.importSongs(SongFormat.DreamBeam,
775 filenames=self.getListOfFiles(
776 self.dreamBeamFileListWidget)
777 )
735 elif source_format == SongFormat.SongsOfFellowship:778 elif source_format == SongFormat.SongsOfFellowship:
736 # Import a Songs of Fellowship RTF file779 # Import a Songs of Fellowship RTF file
737 importer = self.plugin.importSongs(SongFormat.SongsOfFellowship,780 importer = self.plugin.importSongs(SongFormat.SongsOfFellowship,
738781
=== added file 'openlp/plugins/songs/lib/dreambeamimport.py'
--- openlp/plugins/songs/lib/dreambeamimport.py 1970-01-01 00:00:00 +0000
+++ openlp/plugins/songs/lib/dreambeamimport.py 2012-03-27 20:15:24 +0000
@@ -0,0 +1,142 @@
1# -*- coding: utf-8 -*-
2# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
3
4###############################################################################
5# OpenLP - Open Source Lyrics Projection #
6# --------------------------------------------------------------------------- #
7# Copyright (c) 2008-2012 Raoul Snyman #
8# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan #
9# Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, #
10# Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias #
11# Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, #
12# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Frode Woldsund #
13# --------------------------------------------------------------------------- #
14# This program is free software; you can redistribute it and/or modify it #
15# under the terms of the GNU General Public License as published by the Free #
16# Software Foundation; version 2 of the License. #
17# #
18# This program is distributed in the hope that it will be useful, but WITHOUT #
19# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
20# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
21# more details. #
22# #
23# You should have received a copy of the GNU General Public License along #
24# with this program; if not, write to the Free Software Foundation, Inc., 59 #
25# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
26###############################################################################
27"""
28The :mod:`dreambeamimport` module provides the functionality for importing
29DreamBeam songs into the OpenLP database.
30"""
31import os, sys
32import logging
33
34from lxml import etree, objectify
35
36from openlp.core.lib import translate
37from openlp.plugins.songs.lib.songimport import SongImport
38from openlp.plugins.songs.lib.ui import SongStrings
39
40log = logging.getLogger(__name__)
41
42class DreamBeamImport(SongImport):
43 """
44 The :class:`DreamBeamImport` class provides the ability to import song files from
45 DreamBeam.
46
47 An example of DreamBeam xml mark-up::
48
49 <?xml version="1.0"?>
50 <DreamSong xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
51 xmlns:xsd="http://www.w3.org/2001/XMLSchema">
52 <WordWrap>false</WordWrap>
53 <Version>0.80</Version>
54 <Title>Amazing Grace</Title>
55 <Author>John Newton</Author>
56 <Collection />
57 <Number />
58 <Notes />
59 <KeyRangeLow>F</KeyRangeLow>
60 <KeyRangeHigh>G</KeyRangeHigh>
61 <MinorKey>false</MinorKey>
62 <DualLanguage>false</DualLanguage>
63 <SongLyrics>
64 <LyricsItem Type="Verse" Number="1">Amazing Grace, how sweet the sound,
65 That saved a wretch like me.
66 I once was lost but now am found,
67 Was blind, but now, I see.</LyricsItem>
68 <LyricsItem Type="Verse" Number="2">T’was Grace that taught my heart to fear.
69 And Grace, my fears relieved.
70 How precious did that Grace appear…
71 the hour I first believed.</LyricsItem>
72 </SongLyrics>
73 <Sequence>
74 <LyricsSequenceItem Type="Verse" Number="1" />
75 <LyricsSequenceItem Type="Verse" Number="2" />
76 </Sequence>
77 <ShowRectangles>false</ShowRectangles>
78 </DreamSong>
79
80 Valid extensions for a DreamBeam song file are:
81
82 * \*.xml
83 """
84
85 def __init__(self, manager, **kwargs):
86 """
87 Initialise the DreamBeam importer.
88 """
89 SongImport.__init__(self, manager, **kwargs)
90
91 def doImport(self):
92 """
93 Receive a single file or a list of files to import.
94 """
95 if isinstance(self.importSource, list):
96 self.importWizard.progressBar.setMaximum(len(self.importSource))
97 for file in self.importSource:
98 if self.stopImportFlag:
99 return
100 self.setDefaults()
101 parser = etree.XMLParser(remove_blank_text=True)
102 try:
103 parsed_file = etree.parse(open(file, u'r'), parser)
104 except etree.XMLSyntaxError:
105 log.exception(u'XML syntax error in file %s' % file)
106 self.logError(file, SongStrings.XMLSyntaxError)
107 continue
108 xml = unicode(etree.tostring(parsed_file))
109 song_xml = objectify.fromstring(xml)
110 if song_xml.tag != u'DreamSong':
111 self.logError(file, unicode(
112 translate('SongsPlugin.DreamBeamImport',
113 ('Invalid DreamBeam song file. Missing '
114 'DreamSong tag.'))))
115 continue
116 if hasattr(song_xml, u'Title'):
117 self.title = unicode(song_xml.Title.text)
118 if hasattr(song_xml, u'Author'):
119 # DreamBeam does not have a copyright field, instead it
120 # some times uses the author field
121 self.addCopyright(unicode(song_xml.Author.text))
122 self.parseAuthor(unicode(song_xml.Author.text))
123 if hasattr(song_xml, u'SongLyrics'):
124 for lyrics_item in song_xml.SongLyrics.iterchildren():
125 verse_type = lyrics_item.get(u'Type')
126 verse_number = lyrics_item.get(u'Number')
127 verse_text = unicode(lyrics_item.text)
128 self.addVerse(verse_text,
129 (u'%s%s' % (verse_type[:1], verse_number)))
130 if hasattr(song_xml, u'Collection'):
131 self.songBookName = unicode(song_xml.Collection.text)
132 if hasattr(song_xml, u'Number'):
133 self.songNumber = unicode(song_xml.Number.text)
134 if hasattr(song_xml, u'Sequence'):
135 for LyricsSequenceItem in song_xml.Sequence.iterchildren():
136 self.verseOrderList.append(
137 "%s%s" % (LyricsSequenceItem.get(u'Type')[:1],
138 LyricsSequenceItem.get(u'Number')))
139 if hasattr(song_xml, u'Notes'):
140 self.comments = unicode(song_xml.Notes.text)
141 if not self.finish():
142 self.logError(file)
0143
=== modified file 'openlp/plugins/songs/lib/importer.py'
--- openlp/plugins/songs/lib/importer.py 2011-12-31 14:18:05 +0000
+++ openlp/plugins/songs/lib/importer.py 2012-03-27 20:15:24 +0000
@@ -35,6 +35,7 @@
35from openlyricsimport import OpenLyricsImport35from openlyricsimport import OpenLyricsImport
36from wowimport import WowImport36from wowimport import WowImport
37from cclifileimport import CCLIFileImport37from cclifileimport import CCLIFileImport
38from dreambeamimport import DreamBeamImport
38from ewimport import EasyWorshipSongImport39from ewimport import EasyWorshipSongImport
39from songbeamerimport import SongBeamerImport40from songbeamerimport import SongBeamerImport
40from songshowplusimport import SongShowPlusImport41from songshowplusimport import SongShowPlusImport
@@ -73,15 +74,16 @@
73 OpenLP1 = 274 OpenLP1 = 2
74 Generic = 375 Generic = 3
75 CCLI = 476 CCLI = 4
76 EasySlides = 577 DreamBeam = 5
77 EasyWorship = 678 EasySlides = 6
78 FoilPresenter = 779 EasyWorship = 7
79 OpenSong = 880 FoilPresenter = 8
80 SongBeamer = 981 OpenSong = 9
81 SongShowPlus = 1082 SongBeamer = 10
82 SongsOfFellowship = 1183 SongShowPlus = 11
83 WordsOfWorship = 1284 SongsOfFellowship = 12
84 #CSV = 1385 WordsOfWorship = 13
86 #CSV = 14
8587
86 @staticmethod88 @staticmethod
87 def get_class(format):89 def get_class(format):
@@ -107,6 +109,8 @@
107 return OooImport109 return OooImport
108 elif format == SongFormat.CCLI:110 elif format == SongFormat.CCLI:
109 return CCLIFileImport111 return CCLIFileImport
112 elif format == SongFormat.DreamBeam:
113 return DreamBeamImport
110 elif format == SongFormat.EasySlides:114 elif format == SongFormat.EasySlides:
111 return EasySlidesImport115 return EasySlidesImport
112 elif format == SongFormat.EasyWorship:116 elif format == SongFormat.EasyWorship:
@@ -130,6 +134,7 @@
130 SongFormat.OpenLP1,134 SongFormat.OpenLP1,
131 SongFormat.Generic,135 SongFormat.Generic,
132 SongFormat.CCLI,136 SongFormat.CCLI,
137 SongFormat.DreamBeam,
133 SongFormat.EasySlides,138 SongFormat.EasySlides,
134 SongFormat.EasyWorship, 139 SongFormat.EasyWorship,
135 SongFormat.FoilPresenter,140 SongFormat.FoilPresenter,
136141
=== modified file 'openlp/plugins/songs/lib/songshowplusimport.py'
--- openlp/plugins/songs/lib/songshowplusimport.py 2011-12-27 10:33:55 +0000
+++ openlp/plugins/songs/lib/songshowplusimport.py 2012-03-27 20:15:24 +0000
@@ -25,8 +25,8 @@
25# Temple Place, Suite 330, Boston, MA 02111-1307 USA #25# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
26###############################################################################26###############################################################################
27"""27"""
28The :mod:`wowimport` module provides the functionality for importing Words of28The :mod:`songshowplusimport` module provides the functionality for importing
29Worship songs into the OpenLP database.29SongShow Plus songs into the OpenLP database.
30"""30"""
31import os31import os
32import logging32import logging