openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #03928
[Merge] lp:~crichter/openlp/testing into lp:openlp
rimach has proposed merging lp:~crichter/openlp/testing into lp:openlp.
Requested reviews:
OpenLP Core (openlp-core)
add songbeamer import
--
https://code.launchpad.net/~crichter/openlp/testing/+merge/36773
Your team OpenLP Core is requested to review the proposed merge of lp:~crichter/openlp/testing into lp:openlp.
=== modified file 'openlp/core/utils/__init__.py'
--- openlp/core/utils/__init__.py 2010-09-16 20:40:12 +0000
+++ openlp/core/utils/__init__.py 2010-09-27 18:57:46 +0000
@@ -133,7 +133,13 @@
path = os.path.join(os.getenv(u'HOME'), u'.openlp')
return path
elif dir_type == AppLocation.DataDir:
- if sys.platform == u'win32':
+ settings = QtCore.QSettings()
+ settings.beginGroup(u'general')
+ extDbPath = settings.value(u'ext db path', QtCore.QVariant(u'')).toString()
+ if settings.value(u'ext db usage', QtCore.QVariant(False)).toBool()\
+ and QtCore.QDir(extDbPath).exists():
+ path = os.path.abspath(str(settings.value(u'ext db path', QtCore.QVariant(u'')).toString()))
+ elif sys.platform == u'win32':
path = os.path.join(os.getenv(u'APPDATA'), u'openlp', u'data')
elif sys.platform == u'darwin':
path = os.path.join(os.getenv(u'HOME'), u'Library',
=== modified file 'openlp/plugins/songs/forms/songimportform.py'
--- openlp/plugins/songs/forms/songimportform.py 2010-09-21 18:12:46 +0000
+++ openlp/plugins/songs/forms/songimportform.py 2010-09-27 18:57:46 +0000
@@ -112,6 +112,12 @@
QtCore.QObject.connect(self.ewBrowseButton,
QtCore.SIGNAL(u'clicked()'),
self.onEWBrowseButtonClicked)
+ QtCore.QObject.connect(self.songBeamerAddButton,
+ QtCore.SIGNAL(u'clicked()'),
+ self.onSongBeamerAddButtonClicked)
+ QtCore.QObject.connect(self.songBeamerRemoveButton,
+ QtCore.SIGNAL(u'clicked()'),
+ self.onSongBeamerRemoveButtonClicked)
QtCore.QObject.connect(self.cancelButton,
QtCore.SIGNAL(u'clicked(bool)'),
self.onCancelButtonClicked)
@@ -227,6 +233,16 @@
'file to import from.'))
self.ewBrowseButton.setFocus()
return False
+ elif source_format == SongFormat.SongBeamer:
+ if self.songBeamerFileListWidget.count() == 0:
+ QtGui.QMessageBox.critical(self,
+ translate('SongsPlugin.ImportWizardForm',
+ 'No SongBeamer File Selected'),
+ translate('SongsPlugin.ImportWizardForm',
+ 'You need to add at least one SongBeamer '
+ 'file to import from.'))
+ self.songBeamerAddButton.setFocus()
+ return False
return True
elif self.currentId() == 2:
# Progress page
@@ -342,6 +358,16 @@
self.ewFilenameEdit
)
+ def onSongBeamerAddButtonClicked(self):
+ self.getFiles(
+ translate('SongsPlugin.ImportWizardForm',
+ 'Select SongBeamer Files'),
+ self.songBeamerFileListWidget
+ )
+
+ def onSongBeamerRemoveButtonClicked(self):
+ self.removeSelectedItems(self.songBeamerFileListWidget)
+
def onCancelButtonClicked(self, checked):
"""
Stop the import on pressing the cancel button.
@@ -373,6 +399,7 @@
self.songsOfFellowshipFileListWidget.clear()
self.genericFileListWidget.clear()
self.ewFilenameEdit.setText(u'')
+ self.songBeamerFileListWidget.clear()
#self.csvFilenameEdit.setText(u'')
def incrementProgressBar(self, status_text, increment=1):
@@ -448,6 +475,12 @@
importer = self.plugin.importSongs(SongFormat.EasyWorship,
filename=unicode(self.ewFilenameEdit.text())
)
+ elif source_format == SongFormat.SongBeamer:
+ # Import SongBeamer songs
+ importer = self.plugin.importSongs(SongFormat.SongBeamer,
+ filenames=self.getListOfFiles(
+ self.songBeamerFileListWidget)
+ )
success = importer.do_import()
if success:
# reload songs
=== modified file 'openlp/plugins/songs/forms/songimportwizard.py'
--- openlp/plugins/songs/forms/songimportwizard.py 2010-09-23 19:23:56 +0000
+++ openlp/plugins/songs/forms/songimportwizard.py 2010-09-27 18:57:46 +0000
@@ -116,6 +116,8 @@
self.addMultiFileSelectItem(u'generic', None, True)
# EasyWorship
self.addSingleFileSelectItem(u'ew')
+ # Words of Worship
+ self.addMultiFileSelectItem(u'songBeamer')
# Commented out for future use.
# self.addSingleFileSelectItem(u'csv', u'CSV')
self.sourceLayout.addWidget(self.formatStackedWidget)
@@ -180,6 +182,8 @@
'Generic Document/Presentation'))
self.formatComboBox.setItemText(8,
translate('SongsPlugin.ImportWizardForm', 'EasyWorship'))
+ self.formatComboBox.setItemText(9,
+ translate('SongsPlugin.ImportWizardForm', 'SongBeamer'))
# self.formatComboBox.setItemText(9,
# translate('SongsPlugin.ImportWizardForm', 'CSV'))
self.openLP2FilenameLabel.setText(
@@ -236,6 +240,10 @@
translate('SongsPlugin.ImportWizardForm', 'Filename:'))
self.ewBrowseButton.setText(
translate('SongsPlugin.ImportWizardForm', 'Browse...'))
+ self.songBeamerAddButton.setText(
+ translate('SongsPlugin.ImportWizardForm', 'Add Files...'))
+ self.songBeamerRemoveButton.setText(
+ translate('SongsPlugin.ImportWizardForm', 'Remove File(s)'))
# self.csvFilenameLabel.setText(
# translate('SongsPlugin.ImportWizardForm', 'Filename:'))
# self.csvBrowseButton.setText(
=== modified file 'openlp/plugins/songs/lib/importer.py'
--- openlp/plugins/songs/lib/importer.py 2010-09-20 18:22:57 +0000
+++ openlp/plugins/songs/lib/importer.py 2010-09-27 18:57:46 +0000
@@ -29,6 +29,7 @@
from wowimport import WowImport
from cclifileimport import CCLIFileImport
from ewimport import EasyWorshipSongImport
+from songbeamerimport import SongBeamerImport
# Imports that might fail
try:
from olp1import import OpenLP1SongImport
@@ -64,6 +65,7 @@
Generic = 7
#CSV = 8
EasyWorship = 8
+ SongBeamer = 9
@staticmethod
def get_class(format):
@@ -89,6 +91,8 @@
return CCLIFileImport
elif format == SongFormat.EasyWorship:
return EasyWorshipSongImport
+ elif format == SongFormat.SongBeamer:
+ return SongBeamerImport
# else:
return None
@@ -106,7 +110,8 @@
SongFormat.CCLI,
SongFormat.SongsOfFellowship,
SongFormat.Generic,
- SongFormat.EasyWorship
+ SongFormat.EasyWorship,
+ SongFormat.SongBeamer
]
@staticmethod
=== added file 'openlp/plugins/songs/lib/songbeamerimport.py'
--- openlp/plugins/songs/lib/songbeamerimport.py 1970-01-01 00:00:00 +0000
+++ openlp/plugins/songs/lib/songbeamerimport.py 2010-09-27 18:57:46 +0000
@@ -0,0 +1,229 @@
+# -*- coding: utf-8 -*-
+# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
+
+###############################################################################
+# OpenLP - Open Source Lyrics Projection #
+# --------------------------------------------------------------------------- #
+# Copyright (c) 2008-2010 Raoul Snyman #
+# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael #
+# Gorven, Scott Guerrieri, Meinert Jordan, Andreas Preikschat, Christian #
+# Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon Tibble, #
+# Carsten Tinggaard, Frode Woldsund #
+# --------------------------------------------------------------------------- #
+# This program is free software; you can redistribute it and/or modify it #
+# under the terms of the GNU General Public License as published by the Free #
+# Software Foundation; version 2 of the License. #
+# #
+# This program is distributed in the hope that it will be useful, but WITHOUT #
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
+# more details. #
+# #
+# You should have received a copy of the GNU General Public License along #
+# with this program; if not, write to the Free Software Foundation, Inc., 59 #
+# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
+###############################################################################
+"""
+The :mod:`songbeamerimport` module provides the functionality for importing
+ SongBeamer songs into the OpenLP database.
+"""
+import os
+import re
+import logging
+
+from openlp.plugins.songs.lib.songimport import SongImport
+
+log = logging.getLogger(__name__)
+
+class SongBeamerTypes(object):
+ MarkTypes = {
+ u'Refrain': u'C',
+ u'Chorus': u'C',
+ u'Vers': u'V',
+ u'Verse': u'V',
+ u'Strophe': u'V',
+ u'Intro': u'I',
+ u'Coda': u'E',
+ u'Ending': u'E',
+ u'Bridge': u'B',
+ u'Interlude': u'B',
+ u'Zwischenspiel': u'B',
+ u'Pre-Chorus': u'P',
+ u'Pre-Refrain': u'P',
+ u'Pre-Bridge': u'O',
+ u'Pre-Coda': u'O',
+ u'Unbekannt': u'O',
+ u'Unknown': u'O'
+ }
+
+class SongBeamerImport(SongImport):
+ """
+ """
+
+ def __init__(self, master_manager, **kwargs):
+ """
+ Initialise the import.
+
+ ``master_manager``
+ The song manager for the running OpenLP installation.
+ """
+ SongImport.__init__(self, master_manager)
+ self.master_manager = master_manager
+ if kwargs.has_key(u'filename'):
+ self.import_source = kwargs[u'filename']
+ if kwargs.has_key(u'filenames'):
+ self.import_source = kwargs[u'filenames']
+ log.debug(self.import_source)
+
+ def do_import(self):
+ """
+ Recieve a single file, or a list of files to import.
+ """
+
+ if isinstance(self.import_source, list):
+ self.import_wizard.importProgressBar.setMaximum(
+ len(self.import_source))
+ for file in self.import_source:
+ # TODO: check that it is a valid SongBeamer file
+ self.current_verse = u''
+ self.current_verse_type = u'V'
+ self.file_name = os.path.split(file)[1]
+ self.import_wizard.incrementProgressBar(
+ "Importing %s" % (self.file_name), 0)
+ self.songFile = open(file, 'r')
+ self.songData = self.songFile.read().decode('utf8')
+ self.songData = self.songData.splitlines()
+ self.songFile.close()
+ for line in self.songData:
+ if line.startswith('#'):
+ log.debug(u'find tag: %s' % line)
+ if not self.parse_tags(line):
+ return False
+ elif line.startswith('---'):
+ log.debug(u'find ---')
+ if len(self.current_verse) > 0:
+ self.add_verse(self.current_verse, self.current_verse_type)
+ self.current_verse = u''
+ self.current_verse_type = u'V'
+ self.read_verse = True
+ self.verse_start = True
+ elif self.read_verse:
+ if self.verse_start:
+ self.check_verse_marks(line)
+ self.verse_start = False
+ else:
+ self.current_verse += u'%s\n' % line
+ if len(self.current_verse) > 0:
+ self.add_verse(self.current_verse, self.current_verse_type)
+ self.finish()
+ self.import_wizard.incrementProgressBar(
+ "Importing %s" % (self.file_name))
+ return True
+
+ def parse_tags(self, line):
+ tag_val = line.split('=')
+ if len(tag_val[0]) == 0 or \
+ len(tag_val[1]) == 0:
+ return True
+ if tag_val[0] == '#(c)':
+ self.add_copyright(tag_val[1])
+ elif tag_val[0] == '#AddCopyrightInfo':
+ pass
+ elif tag_val[0] == '#Author':
+ #TODO split Authors
+ self.add_author(tag_val[1])
+ elif tag_val[0] == '#BackgroundImage':
+ pass
+ elif tag_val[0] == '#Bible':
+ pass
+ elif tag_val[0] == '#Categories':
+ pass
+ elif tag_val[0] == '#CCLI':
+ self.ccli_number = tag_val[1]
+ elif tag_val[0] == '#Chords':
+ pass
+ elif tag_val[0] == '#ChurchSongID':
+ pass
+ elif tag_val[0] == '#ColorChords':
+ pass
+ elif tag_val[0] == '#Comments':
+ self.comments = tag_val[1]
+ elif tag_val[0] == '#Editor':
+ pass
+ elif tag_val[0] == '#Font':
+ pass
+ elif tag_val[0] == '#FontLang2':
+ pass
+ elif tag_val[0] == '#FontSize':
+ pass
+ elif tag_val[0] == '#Format':
+ pass
+ elif tag_val[0] == '#Format_PreLine':
+ pass
+ elif tag_val[0] == '#Format_PrePage':
+ pass
+ elif tag_val[0] == '#ID':
+ pass
+ elif tag_val[0] == '#Key':
+ pass
+ elif tag_val[0] == '#Keywords':
+ pass
+ elif tag_val[0] == '#LangCount':
+ pass
+ elif tag_val[0] == '#Melody':
+ #TODO split Authors
+ self.add_author(tag_val[1])
+ elif tag_val[0] == '#NatCopyright':
+ pass
+ elif tag_val[0] == '#OTitle':
+ pass
+ elif tag_val[0] == '#OutlineColor':
+ pass
+ elif tag_val[0] == '#OutlinedFont':
+ pass
+ elif tag_val[0] == '#QuickFind':
+ pass
+ elif tag_val[0] == '#Rights':
+ song_book_pub = tag_val[1]
+ elif tag_val[0] == '#Songbook':
+ book_num = tag_val[1].split(' / ')
+ self.song_book_name = book_num[0]
+ if len(book_num) == book_num[1]:
+ self.song_number = u''
+ elif tag_val[0] == '#Speed':
+ pass
+ elif tag_val[0] == '#TextAlign':
+ pass
+ elif tag_val[0] == '#Title':
+ self.title = u'%s' % tag_val[1]
+ elif tag_val[0] == '#TitleAlign':
+ pass
+ elif tag_val[0] == '#TitleFontSize':
+ pass
+ elif tag_val[0] == '#TitleLang2':
+ pass
+ elif tag_val[0] == '#TitleLang3':
+ pass
+ elif tag_val[0] == '#TitleLang4':
+ pass
+ elif tag_val[0] == '#Translation':
+ pass
+ elif tag_val[0] == '#Transpose':
+ pass
+ elif tag_val[0] == '#TransposeAccidental':
+ pass
+ elif tag_val[0] == '#Version':
+ pass
+ else:
+ pass
+ return True
+
+
+ def check_verse_marks(self, line):
+ marks = line.split(' ')
+ if len(marks) <= 2 and \
+ marks[0] in SongBeamerTypes.MarkTypes:
+ self.current_verse_type = SongBeamerTypes.MarkTypes[marks[0]]
+ if len(marks) == 2:
+ #TODO: may check, because of only digits are allowed
+ self.current_verse_type += marks[1]
Follow ups