From d9a26ae4d92a37c7b096e18e29058c00d819c384 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Mon, 14 Feb 2011 20:32:19 +0000 Subject: [PATCH 1/3] Cleanups --- openlp/core/lib/mediamanageritem.py | 1 - openlp/core/lib/serviceitem.py | 1 - openlp/core/lib/theme.py | 4 +- openlp/core/ui/settingsdialog.py | 1 - openlp/core/ui/thememanager.py | 1 - openlp/plugins/songs/forms/songimportform.py | 6 +- .../songs/forms/songmaintenanceform.py | 4 +- openlp/plugins/songs/lib/importer.py | 2 +- .../plugins/songs/lib/songshowplusimport.py | 62 +++++++++---------- 9 files changed, 38 insertions(+), 44 deletions(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index f74ba63a9..d4fdfff17 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -252,7 +252,6 @@ class MediaManagerItem(QtGui.QWidget): self.pageLayout.addWidget(self.listView) # define and add the context menu self.listView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) - name_string = self.plugin.getString(StringContent.Name) if self.hasEditIcon: self.listView.addAction( context_menu_action( diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index 31852709a..f9d690ba2 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -436,7 +436,6 @@ class ServiceItem(object): """ Returns the start and finish time for a media item """ - tooltip = None start = None end = None if self.start_time != 0: diff --git a/openlp/core/lib/theme.py b/openlp/core/lib/theme.py index 4189452bc..225e1335c 100644 --- a/openlp/core/lib/theme.py +++ b/openlp/core/lib/theme.py @@ -178,9 +178,9 @@ class HorizontalType(object): """ Return a string representation of a horizontal type. """ - if horizontal_type == Horizontal.Right: + if horizontal_type == HorizontalType.Right: return u'right' - elif horizontal_type == Horizontal.Center: + elif horizontal_type == HorizontalType.Center: return u'center' else: return u'left' diff --git a/openlp/core/ui/settingsdialog.py b/openlp/core/ui/settingsdialog.py index 99acadc14..41b6baccb 100644 --- a/openlp/core/ui/settingsdialog.py +++ b/openlp/core/ui/settingsdialog.py @@ -36,7 +36,6 @@ class Ui_SettingsDialog(object): settingsDialog.setWindowIcon( build_icon(u':/system/system_settings.png')) self.settingsLayout = QtGui.QVBoxLayout(settingsDialog) - margins = self.settingsLayout.contentsMargins() self.settingsLayout.setObjectName(u'settingsLayout') self.settingsTabWidget = QtGui.QTabWidget(settingsDialog) self.settingsTabWidget.setObjectName(u'settingsTabWidget') diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 69028ad76..739de7182 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -314,7 +314,6 @@ class ThemeManager(QtGui.QWidget): translate('OpenLP.ThemeManager', 'You must select a theme to edit.')): item = self.themeListWidget.currentItem() - themeName = unicode(item.text()) theme = self.getThemeData( unicode(item.data(QtCore.Qt.UserRole).toString())) if theme.background_type == u'image': diff --git a/openlp/plugins/songs/forms/songimportform.py b/openlp/plugins/songs/forms/songimportform.py index 6e2a45b45..eda3d6750 100644 --- a/openlp/plugins/songs/forms/songimportform.py +++ b/openlp/plugins/songs/forms/songimportform.py @@ -480,7 +480,7 @@ class SongImportForm(OpenLPWizard): The file extension filters. It should contain the file descriptions as well as the file extensions. For example:: - u'SongBeamer files (*.sng)' + u'SongBeamer Files (*.sng)' """ if filters: filters += u';;' @@ -609,7 +609,7 @@ class SongImportForm(OpenLPWizard): 'Select Songs of Fellowship Files'), self.songsOfFellowshipFileListWidget, u'%s (*.rtf)' % translate('SongsPlugin.ImportWizardForm', - 'Songs Of Felloship Song Files') + 'Songs Of Fellowship Song Files') ) def onSongsOfFellowshipRemoveButtonClicked(self): @@ -659,7 +659,7 @@ class SongImportForm(OpenLPWizard): translate('SongsPlugin.ImportWizardForm', 'Select SongBeamer Files'), self.songBeamerFileListWidget, u'%s (*.sng)' % - translate('SongsPlugin.ImportWizardForm', 'SongBeamer files') + translate('SongsPlugin.ImportWizardForm', 'SongBeamer Files') ) def onSongBeamerRemoveButtonClicked(self): diff --git a/openlp/plugins/songs/forms/songmaintenanceform.py b/openlp/plugins/songs/forms/songmaintenanceform.py index 1eb63fbf4..1f693223c 100644 --- a/openlp/plugins/songs/forms/songmaintenanceform.py +++ b/openlp/plugins/songs/forms/songmaintenanceform.py @@ -457,7 +457,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): def onTopicDeleteButtonClick(self): """ - Delete the Book is the Book is not attached to any songs. + Delete the Book if the Book is not attached to any songs. """ self._deleteItem(Topic, self.topicsListWidget, self.resetTopics, translate('SongsPlugin.SongMaintenanceForm', 'Delete Topic'), @@ -470,7 +470,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): def onBookDeleteButtonClick(self): """ - Delete the Book is the Book is not attached to any songs. + Delete the Book if the Book is not attached to any songs. """ self._deleteItem(Book, self.booksListWidget, self.resetBooks, translate('SongsPlugin.SongMaintenanceForm', 'Delete Book'), diff --git a/openlp/plugins/songs/lib/importer.py b/openlp/plugins/songs/lib/importer.py index cbe5c6922..230dcd8d0 100644 --- a/openlp/plugins/songs/lib/importer.py +++ b/openlp/plugins/songs/lib/importer.py @@ -68,11 +68,11 @@ class SongFormat(object): CCLI = 5 SongsOfFellowship = 6 Generic = 7 - #CSV = 8 EasiSlides = 8 EasyWorship = 9 SongBeamer = 10 SongShowPlus = 11 + #CSV = 12 @staticmethod def get_class(format): diff --git a/openlp/plugins/songs/lib/songshowplusimport.py b/openlp/plugins/songs/lib/songshowplusimport.py index 78c2e838d..5df36a5b1 100644 --- a/openlp/plugins/songs/lib/songshowplusimport.py +++ b/openlp/plugins/songs/lib/songshowplusimport.py @@ -42,7 +42,7 @@ CHORUS = 20 TOPIC = 29 COMMENTS = 30 VERSE_ORDER = 31 -SONG_BOOK = 35 +SONG_BOOK = 35 SONG_NUMBER = 36 CUSTOM_VERSE = 37 @@ -50,32 +50,32 @@ log = logging.getLogger(__name__) class SongShowPlusImport(SongImport): """ - The :class:`SongShowPlusImport` class provides the ability to import song + The :class:`SongShowPlusImport` class provides the ability to import song files from SongShow Plus. **SongShow Plus Song File Format:** The SongShow Plus song file format is as follows: - - * Each piece of data in the song file has some information that precedes + + * Each piece of data in the song file has some information that precedes it. * The general format of this data is as follows: - 4 Bytes, forming a 32 bit number, a key if you will, this describes what + 4 Bytes, forming a 32 bit number, a key if you will, this describes what the data is (see blockKey below) - 4 Bytes, forming a 32 bit number, which is the number of bytes until the + 4 Bytes, forming a 32 bit number, which is the number of bytes until the next block starts 1 Byte, which tells how namy bytes follows - 1 or 4 Bytes, describes how long the string is, if its 1 byte, the string + 1 or 4 Bytes, describes how long the string is, if its 1 byte, the string is less than 255 The next bytes are the actuall data. The next block of data follows on. - - This description does differ for verses. Which includes extra bytes - stating the verse type or number. In some cases a "custom" verse is used, - in that case, this block will in include 2 strings, with the associated - string length descriptors. The first string is the name of the verse, the + + This description does differ for verses. Which includes extra bytes + stating the verse type or number. In some cases a "custom" verse is used, + in that case, this block will in include 2 strings, with the associated + string length descriptors. The first string is the name of the verse, the second is the verse content. - + The file is ended with four null bytes. Valid extensions for a SongShow Plus song file are: @@ -98,7 +98,7 @@ class SongShowPlusImport(SongImport): if kwargs.has_key(u'filenames'): self.import_source = kwargs[u'filenames'] log.debug(self.import_source) - + def do_import(self): """ Receive a single file or a list of files to import. @@ -107,38 +107,36 @@ class SongShowPlusImport(SongImport): self.import_wizard.progressBar.setMaximum(len(self.import_source)) for file in self.import_source: author = u'' - copyright = u'' self.sspVerseOrderList = [] otherCount = 0 otherList = {} file_name = os.path.split(file)[1] self.import_wizard.incrementProgressBar( - u'Importing %s' % (file_name), 0) + u'Importing %s' % (file_name), 0) songData = open(file, 'rb') while (1): - blockKey, = struct.unpack("I",songData.read(4)) + blockKey, = struct.unpack("I", songData.read(4)) # The file ends with 4 NUL's if blockKey == 0: break - nextBlockStarts, = struct.unpack("I",songData.read(4)) + nextBlockStarts, = struct.unpack("I", songData.read(4)) if blockKey == VERSE or blockKey == CHORUS: - null, verseNo, = struct.unpack("BB",songData.read(2)) + null, verseNo, = struct.unpack("BB", songData.read(2)) elif blockKey == CUSTOM_VERSE: - null, verseNameLength, = struct.unpack("BB", + null, verseNameLength, = struct.unpack("BB", songData.read(2)) verseName = songData.read(verseNameLength) - lengthDescriptorSize, = struct.unpack("B",songData.read(1)) + lengthDescriptorSize, = struct.unpack("B", songData.read(1)) # Detect if/how long the length descriptor is if lengthDescriptorSize == 12: - lengthDescriptor, = struct.unpack("I",songData.read(4)) + lengthDescriptor, = struct.unpack("I", songData.read(4)) elif lengthDescriptorSize == 2: lengthDescriptor = 1 elif lengthDescriptorSize == 9: lengthDescriptor = 0 - else: - lengthDescriptor, = struct.unpack("B",songData.read(1)) + else: + lengthDescriptor, = struct.unpack("B", songData.read(1)) data = songData.read(lengthDescriptor) - if blockKey == TITLE: self.title = unicode(data, u'cp1252') elif blockKey == AUTHOR: @@ -146,17 +144,17 @@ class SongShowPlusImport(SongImport): for author in authors: if author.find(",") !=-1: authorParts = author.split(", ") - author = authorParts[1] + " " + authorParts[0] - self.parse_author(unicode(author, u'cp1252')) + author = authorParts[1] + " " + authorParts[0] + self.parse_author(unicode(author, u'cp1252')) elif blockKey == COPYRIGHT: self.add_copyright(unicode(data, u'cp1252')) elif blockKey == CCLI_NO: self.ccli_number = int(data) elif blockKey == VERSE: - self.add_verse(unicode(data, u'cp1252'), + self.add_verse(unicode(data, u'cp1252'), "V%s" % verseNo) elif blockKey == CHORUS: - self.add_verse(unicode(data, u'cp1252'), + self.add_verse(unicode(data, u'cp1252'), "C%s" % verseNo) elif blockKey == TOPIC: self.topics.append(unicode(data, u'cp1252')) @@ -182,9 +180,9 @@ class SongShowPlusImport(SongImport): self.import_wizard.incrementProgressBar( u'Importing %s' % (file_name)) return True - + def toOpenLPVerseTag(self, verseName): - if verseName.find(" ")!=-1: + if verseName.find(" ") !=-1: verseParts = verseName.split(" ") verseType = verseParts[0] verseNumber = verseParts[1] @@ -203,7 +201,7 @@ class SongShowPlusImport(SongImport): elif verseType == "bridge": verseTag = "B" else: - if not self.otherList.has_key(verseName): + if not self.otherList.has_key(verseName): self.otherCount = self.otherCount + 1 self.otherList[verseName] = str(self.otherCount) verseTag = "O" From 847dfdaafc685d5592443d00d1273292485b3152 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Mon, 14 Feb 2011 21:07:05 +0000 Subject: [PATCH 2/3] Unused imports --- openlp/core/ui/printserviceorderform.py | 1 - openlp/plugins/bibles/bibleplugin.py | 1 - openlp/plugins/custom/customplugin.py | 1 - 3 files changed, 3 deletions(-) diff --git a/openlp/core/ui/printserviceorderform.py b/openlp/core/ui/printserviceorderform.py index 70128cb89..b5160e61c 100644 --- a/openlp/core/ui/printserviceorderform.py +++ b/openlp/core/ui/printserviceorderform.py @@ -24,7 +24,6 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### import datetime -import os from PyQt4 import QtCore, QtGui diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index de0ea11f1..b992552f1 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -29,7 +29,6 @@ import logging from PyQt4 import QtCore, QtGui from openlp.core.lib import Plugin, StringContent, build_icon, translate -from openlp.core.lib.ui import UiStrings from openlp.plugins.bibles.lib import BibleManager, BiblesTab, BibleMediaItem log = logging.getLogger(__name__) diff --git a/openlp/plugins/custom/customplugin.py b/openlp/plugins/custom/customplugin.py index 5a32d4657..65245fc8a 100644 --- a/openlp/plugins/custom/customplugin.py +++ b/openlp/plugins/custom/customplugin.py @@ -30,7 +30,6 @@ from forms import EditCustomForm from openlp.core.lib import Plugin, StringContent, build_icon, translate from openlp.core.lib.db import Manager -from openlp.core.lib.ui import UiStrings from openlp.plugins.custom.lib import CustomMediaItem, CustomTab from openlp.plugins.custom.lib.db import CustomSlide, init_schema From cc96d96a6a0d8b19fa6d77deb833bad97dd6808c Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Tue, 15 Feb 2011 01:58:18 +0000 Subject: [PATCH 3/3] Fix song overwriting --- openlp/plugins/songs/forms/editsongform.py | 1 + 1 file changed, 1 insertion(+) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 8536d38b8..39f1ba256 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -161,6 +161,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): def newSong(self): log.debug(u'New Song') + self.song = None self.initialise() self.songTabWidget.setCurrentIndex(0) self.titleEdit.setText(u'')