From a34957297c02b440f45bebdb77dc9779ea14b246 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Sat, 19 Jun 2010 18:56:21 +0100 Subject: [PATCH 1/4] Cleanups --- openlp/core/lib/themexmlhandler.py | 6 ++++-- openlp/core/theme/theme.py | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/openlp/core/lib/themexmlhandler.py b/openlp/core/lib/themexmlhandler.py index b2850d6ec..779dc3507 100644 --- a/openlp/core/lib/themexmlhandler.py +++ b/openlp/core/lib/themexmlhandler.py @@ -339,7 +339,8 @@ class ThemeXML(object): """ Pull out the XML string formatted for human consumption """ - return self.theme_xml.toprettyxml(indent=u' ', newl=u'\n', encoding=u'utf-8') + return self.theme_xml.toprettyxml(indent=u' ', newl=u'\n', + encoding=u'utf-8') def parse(self, xml): """ @@ -364,7 +365,8 @@ class ThemeXML(object): ``xml`` The XML string to parse. """ - theme_xml = ElementTree(element=XML(xml.encode(u'ascii', u'xmlcharrefreplace'))) + theme_xml = ElementTree(element=XML(xml.encode(u'ascii', + u'xmlcharrefreplace'))) xml_iter = theme_xml.getiterator() master = u'' for element in xml_iter: diff --git a/openlp/core/theme/theme.py b/openlp/core/theme/theme.py index b75b55a2e..2ea13d01b 100644 --- a/openlp/core/theme/theme.py +++ b/openlp/core/theme/theme.py @@ -175,7 +175,8 @@ class Theme(object): ``xml`` The data to apply to the theme """ - root = ElementTree(element=XML(xml.encode(u'ascii', u'xmlcharrefreplace'))) + root = ElementTree(element=XML(xml.encode(u'ascii', + u'xmlcharrefreplace'))) xml_iter = root.getiterator() for element in xml_iter: delphi_color_change = False From 1005a3c1b1b3e32e44a3683e64362f1ed6623ca9 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Sat, 19 Jun 2010 19:29:18 +0100 Subject: [PATCH 2/4] Cleanup unneeded trailing backslashes --- openlp/core/lib/mediamanageritem.py | 28 +++++++++---------- openlp/core/ui/servicemanager.py | 2 +- openlp/core/ui/thememanager.py | 2 +- openlp/plugins/alerts/lib/alertstab.py | 2 +- .../songusage/forms/songusagedetailform.py | 7 ++--- openlp/plugins/songusage/lib/manager.py | 2 +- 6 files changed, 21 insertions(+), 22 deletions(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index c0f016f94..a011a1c94 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -208,40 +208,40 @@ class MediaManagerItem(QtGui.QWidget): ## Import Button ## if self.hasImportIcon: self.addToolbarButton( - unicode(translate('MediaManagerItem', 'Import %s')) % \ + unicode(translate('MediaManagerItem', 'Import %s')) % self.PluginNameShort, - unicode(translate('MediaManagerItem', 'Import a %s')) % \ + unicode(translate('MediaManagerItem', 'Import a %s')) % self.PluginNameVisible, u':/general/general_import.png', self.onImportClick) ## File Button ## if self.hasFileIcon: self.addToolbarButton( - unicode(translate('MediaManagerItem', 'Load %s')) % \ + unicode(translate('MediaManagerItem', 'Load %s')) % self.PluginNameShort, - unicode(translate('MediaManagerItem', 'Load a new %s')) % \ + unicode(translate('MediaManagerItem', 'Load a new %s')) % self.PluginNameVisible, u':/general/general_open.png', self.onFileClick) ## New Button ## if self.hasNewIcon: self.addToolbarButton( - unicode(translate('MediaManagerItem', 'New %s')) % \ + unicode(translate('MediaManagerItem', 'New %s')) % self.PluginNameShort, - unicode(translate('MediaManagerItem', 'Add a new %s')) % \ + unicode(translate('MediaManagerItem', 'Add a new %s')) % self.PluginNameVisible, u':/general/general_new.png', self.onNewClick) ## Edit Button ## if self.hasEditIcon: self.addToolbarButton( - unicode(translate('MediaManagerItem', 'Edit %s')) % \ + unicode(translate('MediaManagerItem', 'Edit %s')) % self.PluginNameShort, unicode(translate( - 'MediaManagerItem', 'Edit the selected %s')) % \ + 'MediaManagerItem', 'Edit the selected %s')) % self.PluginNameVisible, u':/general/general_edit.png', self.onEditClick) ## Delete Button ## if self.hasDeleteIcon: self.addToolbarButton( - unicode(translate('MediaManagerItem', 'Delete %s')) % \ + unicode(translate('MediaManagerItem', 'Delete %s')) % self.PluginNameShort, translate('MediaManagerItem', 'Delete the selected item'), u':/general/general_delete.png', self.onDeleteClick) @@ -249,7 +249,7 @@ class MediaManagerItem(QtGui.QWidget): self.addToolbarSeparator() ## Preview ## self.addToolbarButton( - unicode(translate('MediaManagerItem', 'Preview %s')) % \ + unicode(translate('MediaManagerItem', 'Preview %s')) % self.PluginNameShort, translate('MediaManagerItem', 'Preview the selected item'), u':/general/general_preview.png', self.onPreviewClick) @@ -260,7 +260,7 @@ class MediaManagerItem(QtGui.QWidget): u':/general/general_live.png', self.onLiveClick) ## Add to service Button ## self.addToolbarButton( - unicode(translate('MediaManagerItem', 'Add %s to Service')) % \ + unicode(translate('MediaManagerItem', 'Add %s to Service')) % self.PluginNameShort, translate('MediaManagerItem', 'Add the selected item(s) to the service'), @@ -285,7 +285,7 @@ class MediaManagerItem(QtGui.QWidget): self.ListView.addAction( context_menu_action( self.ListView, u':/general/general_edit.png', - unicode(translate('MediaManagerItem', '&Edit %s')) % \ + unicode(translate('MediaManagerItem', '&Edit %s')) % self.PluginNameVisible, self.onEditClick)) self.ListView.addAction(context_menu_separator(self.ListView)) @@ -293,14 +293,14 @@ class MediaManagerItem(QtGui.QWidget): self.ListView.addAction( context_menu_action( self.ListView, u':/general/general_delete.png', - unicode(translate('MediaManagerItem', '&Delete %s')) % \ + unicode(translate('MediaManagerItem', '&Delete %s')) % self.PluginNameVisible, self.onDeleteClick)) self.ListView.addAction(context_menu_separator(self.ListView)) self.ListView.addAction( context_menu_action( self.ListView, u':/general/general_preview.png', - unicode(translate('MediaManagerItem', '&Preview %s')) % \ + unicode(translate('MediaManagerItem', '&Preview %s')) % self.PluginNameVisible, self.onPreviewClick)) self.ListView.addAction( diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index cccd34195..b317c6bf9 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -677,7 +677,7 @@ class ServiceManager(QtGui.QWidget): translate('ServiceManager', 'File is not a valid service.\n' 'The content encoding is not UTF-8.')) - log.exception(u'Filename "%s" is not valid UTF-8' % \ + log.exception(u'Filename "%s" is not valid UTF-8' % file.decode(u'utf-8', u'replace')) continue osfile = unicode(QtCore.QDir.toNativeSeparators(ucsfile)) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 431b1d450..b645e541b 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -398,7 +398,7 @@ class ThemeManager(QtGui.QWidget): self, translate('ThemeManager', 'Error'), translate('ThemeManager', 'File is not a valid theme.\n' 'The content encoding is not UTF-8.')) - log.exception(u'Filename "%s" is not valid UTF-8' % \ + log.exception(u'Filename "%s" is not valid UTF-8' % file.decode(u'utf-8', u'replace')) continue osfile = unicode(QtCore.QDir.toNativeSeparators(ucsfile)) diff --git a/openlp/plugins/alerts/lib/alertstab.py b/openlp/plugins/alerts/lib/alertstab.py index 15f27df6d..fd8722ca9 100644 --- a/openlp/plugins/alerts/lib/alertstab.py +++ b/openlp/plugins/alerts/lib/alertstab.py @@ -294,5 +294,5 @@ class AlertsTab(SettingsTab): font.setBold(True) font.setPointSize(self.font_size) self.FontPreview.setFont(font) - self.FontPreview.setStyleSheet(u'background-color: %s; color: %s' % \ + self.FontPreview.setStyleSheet(u'background-color: %s; color: %s' % (self.bg_color, self.font_color)) diff --git a/openlp/plugins/songusage/forms/songusagedetailform.py b/openlp/plugins/songusage/forms/songusagedetailform.py index fb1d1c73d..50ea87abe 100644 --- a/openlp/plugins/songusage/forms/songusagedetailform.py +++ b/openlp/plugins/songusage/forms/songusagedetailform.py @@ -71,12 +71,11 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog): def accept(self): log.debug(u'Detailed report generated') - filename = u'usage_detail_%s_%s.txt' % \ + filename = u'usage_detail_%s_%s.txt' % (self.FromDate.selectedDate().toString(u'ddMMyyyy'), self.ToDate.selectedDate().toString(u'ddMMyyyy')) - usage = self.parent.songusagemanager.get_all_songusage(\ - self.FromDate.selectedDate(), \ - self.ToDate.selectedDate()) + usage = self.parent.songusagemanager.get_all_songusage( + self.FromDate.selectedDate(), self.ToDate.selectedDate()) outname = os.path.join(unicode(self.FileLineEdit.text()), filename) file = None try: diff --git a/openlp/plugins/songusage/lib/manager.py b/openlp/plugins/songusage/lib/manager.py index b830fdafd..2339136d0 100644 --- a/openlp/plugins/songusage/lib/manager.py +++ b/openlp/plugins/songusage/lib/manager.py @@ -53,7 +53,7 @@ class SongUsageManager(object): db_type = unicode( settings.value(u'db type', QtCore.QVariant(u'sqlite')).toString()) if db_type == u'sqlite': - self.db_url = u'sqlite:///%s/songusage.sqlite' % \ + self.db_url = u'sqlite:///%s/songusage.sqlite' % AppLocation.get_section_data_path(u'songusage') else: self.db_url = u'%s://%s:%s@%s/%s' % (db_type, From e3a07c1e57a0a2bdc2f181c12b9bcddfa7573133 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Sat, 19 Jun 2010 21:21:36 +0100 Subject: [PATCH 3/4] Cleanups --- openlp/core/ui/thememanager.py | 4 ++-- openlp/plugins/songusage/forms/songusagedetailform.py | 6 +++--- openlp/plugins/songusage/lib/manager.py | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index b645e541b..7849175a3 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -424,8 +424,8 @@ class ThemeManager(QtGui.QWidget): xml_data = xml_data.decode(u'utf-8') except UnicodeDecodeError: log.exception(u'Theme XML is not UTF-8 ' - 'encoded.') - break; + u'encoded.') + break if self.checkVersion1(xml_data): # upgrade theme xml filexml = self.migrateVersion122(xml_data) diff --git a/openlp/plugins/songusage/forms/songusagedetailform.py b/openlp/plugins/songusage/forms/songusagedetailform.py index 50ea87abe..80bb18d77 100644 --- a/openlp/plugins/songusage/forms/songusagedetailform.py +++ b/openlp/plugins/songusage/forms/songusagedetailform.py @@ -71,9 +71,9 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog): def accept(self): log.debug(u'Detailed report generated') - filename = u'usage_detail_%s_%s.txt' % - (self.FromDate.selectedDate().toString(u'ddMMyyyy'), - self.ToDate.selectedDate().toString(u'ddMMyyyy')) + filename = u'usage_detail_%s_%s.txt' % ( + self.FromDate.selectedDate().toString(u'ddMMyyyy'), + self.ToDate.selectedDate().toString(u'ddMMyyyy')) usage = self.parent.songusagemanager.get_all_songusage( self.FromDate.selectedDate(), self.ToDate.selectedDate()) outname = os.path.join(unicode(self.FileLineEdit.text()), filename) diff --git a/openlp/plugins/songusage/lib/manager.py b/openlp/plugins/songusage/lib/manager.py index 2339136d0..b830fdafd 100644 --- a/openlp/plugins/songusage/lib/manager.py +++ b/openlp/plugins/songusage/lib/manager.py @@ -53,7 +53,7 @@ class SongUsageManager(object): db_type = unicode( settings.value(u'db type', QtCore.QVariant(u'sqlite')).toString()) if db_type == u'sqlite': - self.db_url = u'sqlite:///%s/songusage.sqlite' % + self.db_url = u'sqlite:///%s/songusage.sqlite' % \ AppLocation.get_section_data_path(u'songusage') else: self.db_url = u'%s://%s:%s@%s/%s' % (db_type, From e7b4e1640579ac5bea654391e3eb4542b2e2cbb3 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Sun, 20 Jun 2010 14:03:06 +0100 Subject: [PATCH 4/4] Couple o' Cleanups --- openlp/plugins/songs/forms/editsongform.py | 5 +++-- openlp/plugins/songs/lib/songimport.py | 1 - 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index e3bec84c2..063fdd71f 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -649,12 +649,13 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): text = text + re.sub(r'\W+', u' ', unicode(self.VerseListWidget.item(i, 0).text())) + u' ' if (bits[1] > u'1') and (bits[0][0] not in multiple): - multiple.append(bits[0][0]) + multiple.append(bits[0][0]) self.song.search_lyrics = text self.song.lyrics = unicode(sxml.extract_xml(), u'utf-8') for verse in multiple: self.song.verse_order = re.sub(u'([' + verse.upper() + - verse.lower() + u'])(\W|$)', r'\g<1>1\2', self.song.verse_order) + verse.lower() + u'])(\W|$)', r'\g<1>1\2', + self.song.verse_order) except: log.exception(u'Problem processing song Lyrics \n%s', sxml.dump_xml()) diff --git a/openlp/plugins/songs/lib/songimport.py b/openlp/plugins/songs/lib/songimport.py index 479828ddd..dbc9fa08d 100644 --- a/openlp/plugins/songs/lib/songimport.py +++ b/openlp/plugins/songs/lib/songimport.py @@ -23,7 +23,6 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -import string import re from PyQt4 import QtGui