From 98ea9141f4ac614fb546c79c69c81d7a99c3f2dc Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Mon, 21 Sep 2009 18:56:36 +0100 Subject: [PATCH] More white space and line length fixes --- openlp/core/lib/mediamanageritem.py | 75 ++++++++++------ openlp/core/lib/pluginmanager.py | 2 +- openlp/core/lib/renderer.py | 13 +-- openlp/core/lib/rendermanager.py | 13 +-- openlp/core/ui/__init__.py | 2 +- openlp/core/ui/alertstab.py | 39 ++++++--- openlp/core/ui/amendthemeform.py | 2 +- openlp/core/ui/maindisplay.py | 7 +- openlp/core/ui/mainwindow.py | 4 +- openlp/core/ui/plugindialoglistform.py | 22 +++-- openlp/core/ui/servicemanager.py | 8 +- openlp/core/ui/slidecontroller.py | 47 ++++++---- openlp/core/ui/splashscreen.py | 22 +++-- openlp/core/ui/thememanager.py | 17 ++-- openlp/core/ui/themestab.py | 51 +++++++---- openlp/migration/migratesongs.py | 25 +++--- openlp/plugins/audit/auditplugin.py | 11 ++- openlp/plugins/audit/lib/audittab.py | 17 ++-- openlp/plugins/bibles/bibleplugin.py | 4 +- .../plugins/bibles/forms/bibleimportform.py | 37 ++++---- openlp/plugins/bibles/lib/bibleCSVimpl.py | 5 +- openlp/plugins/bibles/lib/bibleDBimpl.py | 4 +- openlp/plugins/bibles/lib/bibleHTTPimpl.py | 80 +++++++++++------ openlp/plugins/bibles/lib/bibleOSISimpl.py | 20 ++--- openlp/plugins/bibles/lib/biblestab.py | 86 ++++++++++++------- openlp/plugins/bibles/lib/manager.py | 14 +-- openlp/plugins/bibles/lib/mediaitem.py | 20 ++--- openlp/plugins/custom/forms/editcustomform.py | 19 ++-- openlp/plugins/custom/lib/mediaitem.py | 5 +- openlp/plugins/images/imageplugin.py | 2 +- openlp/plugins/images/lib/imagetab.py | 9 +- openlp/plugins/images/lib/mediaitem.py | 13 +-- openlp/plugins/media/lib/mediaitem.py | 2 +- openlp/plugins/media/lib/mediatab.py | 11 ++- .../presentations/lib/impresscontroller.py | 2 +- openlp/plugins/presentations/lib/mediaitem.py | 19 ++-- .../presentations/lib/messagelistener.py | 6 +- .../presentations/lib/presentationtab.py | 47 ++++++---- .../presentations/presentationplugin.py | 2 +- openlp/plugins/remotes/lib/remotetab.py | 26 ++++-- openlp/plugins/remotes/remoteclient-cli.py | 2 +- openlp/plugins/remotes/remoteplugin.py | 4 +- openlp/plugins/songs/lib/manager.py | 2 +- openlp/plugins/songs/lib/mediaitem.py | 6 +- openlp/plugins/songs/lib/songxml.py | 55 ++++++------ openlp/plugins/songs/lib/tables.py | 44 ++++++---- openlp/plugins/songs/songsplugin.py | 6 +- openlp/plugins/songs/test/test_song_basic.py | 17 ++-- openlpcnv.pyw | 2 +- 49 files changed, 580 insertions(+), 368 deletions(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index b8e299211..136d9fb82 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -136,7 +136,8 @@ class MediaManagerItem(QtGui.QWidget): self.Toolbar = OpenLPToolbar(self) self.PageLayout.addWidget(self.Toolbar) - def addToolbarButton(self, title, tooltip, icon, slot=None, objectname=None): + def addToolbarButton(self, title, tooltip, icon, slot=None, + objectname=None): """ A method to help developers easily add a button to the toolbar. @@ -192,31 +193,43 @@ class MediaManagerItem(QtGui.QWidget): ## File Button ## if self.hasFileIcon: self.addToolbarButton( - translate(self.TranslationContext, u'Load '+self.PluginTextShort), - translate(self.TranslationContext, u'Load a new '+self.PluginTextShort), - u':'+self.IconPath+ u'_load.png', self.onFileClick, self.PluginTextShort+u'FileItem') + translate(self.TranslationContext, + u'Load ' + self.PluginTextShort), + translate(self.TranslationContext, + u'Load a new ' + self.PluginTextShort), + u':' + self.IconPath + u'_load.png', self.onFileClick, + self.PluginTextShort + u'FileItem') ## New Button ## if self.hasNewIcon: self.addToolbarButton( - translate(self.TranslationContext, u'New '+self.PluginTextShort), - translate(self.TranslationContext, u'Add a new '+self.PluginTextShort), - u':'+self.IconPath+ u'_new.png', self.onNewClick, self.PluginTextShort+u'NewItem') + translate(self.TranslationContext, + u'New ' + self.PluginTextShort), + translate(self.TranslationContext, + u'Add a new ' + self.PluginTextShort), + u':' + self.IconPath + u'_new.png', self.onNewClick, + self.PluginTextShort + u'NewItem') ## Edit Button ## if self.hasEditIcon: self.addToolbarButton( - translate(self.TranslationContext, u'Edit '+self.PluginTextShort), - translate(self.TranslationContext, u'Edit the selected '+self.PluginTextShort), - u':'+self.IconPath+ u'_edit.png', self.onEditClick, self.PluginTextShort+u'EditItem') + translate(self.TranslationContext, + u'Edit ' + self.PluginTextShort), + translate(self.TranslationContext, + u'Edit the selected ' + self.PluginTextShort), + u':' + self.IconPath + u'_edit.png', self.onEditClick, + self.PluginTextShort + u'EditItem') ## Delete Button ## self.addToolbarButton( - translate(self.TranslationContext, u'Delete '+self.PluginTextShort), + translate(self.TranslationContext, + u'Delete ' + self.PluginTextShort), translate(self.TranslationContext, u'Delete the selected item'), - u':'+self.IconPath+ u'_delete.png', self.onDeleteClick, self.PluginTextShort+u'DeleteItem') + u':' + self.IconPath + u'_delete.png', self.onDeleteClick, + self.PluginTextShort + u'DeleteItem') ## Separator Line ## self.addToolbarSeparator() ## Preview ## self.addToolbarButton( - translate(self.TranslationContext, u'Preview '+self.PluginTextShort), + translate(self.TranslationContext, + u'Preview ' + self.PluginTextShort), translate(self.TranslationContext, u'Preview the selected item'), u':/system/system_preview.png', self.onPreviewClick, u'PreviewItem') ## Live Button ## @@ -226,9 +239,12 @@ class MediaManagerItem(QtGui.QWidget): u':/system/system_live.png', self.onLiveClick, u'LiveItem') ## Add to service Button ## self.addToolbarButton( - translate(self.TranslationContext, u'Add '+self.PluginTextShort+u' To Service'), - translate(self.TranslationContext, u'Add the selected item(s) to the service'), - u':/system/system_add.png', self.onAddClick, self.PluginTextShort+u'AddItem') + translate(self.TranslationContext, + u'Add ' + self.PluginTextShort + u' To Service'), + translate(self.TranslationContext, + u'Add the selected item(s) to the service'), + u':/system/system_add.png', self.onAddClick, + self.PluginTextShort + u'AddItem') def addListViewToToolBar(self): #Add the List widget @@ -236,7 +252,8 @@ class MediaManagerItem(QtGui.QWidget): self.ListView.uniformItemSizes = True self.ListView.setGeometry(QtCore.QRect(10, 100, 256, 591)) self.ListView.setSpacing(1) - self.ListView.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection) + self.ListView.setSelectionMode( + QtGui.QAbstractItemView.ExtendedSelection) self.ListView.setAlternatingRowColors(True) self.ListView.setDragEnabled(True) self.ListView.setObjectName(self.PluginTextShort+u'ListView') @@ -247,12 +264,14 @@ class MediaManagerItem(QtGui.QWidget): if self.hasEditIcon: self.ListView.addAction(contextMenuAction(self.ListView, ':' +self.IconPath+u'_new.png', - translate(self.TranslationContext, u'&Edit '+self.PluginTextShort), + translate(self.TranslationContext, + u'&Edit ' + self.PluginTextShort), self.onEditClick)) self.ListView.addAction(contextMenuSeparator(self.ListView)) self.ListView.addAction(contextMenuAction( self.ListView, ':/system/system_preview.png', - translate(self.TranslationContext, u'&Preview '+self.PluginTextShort), + translate(self.TranslationContext, + u'&Preview ' + self.PluginTextShort), self.onPreviewClick)) self.ListView.addAction(contextMenuAction( self.ListView, ':/system/system_live.png', @@ -301,20 +320,23 @@ class MediaManagerItem(QtGui.QWidget): count = 0 filelist = [] while count < self.ListView.count(): - bitem = self.ListView.item(count) + bitem = self.ListView.item(count) filename = unicode((bitem.data(QtCore.Qt.UserRole)).toString()) filelist.append(filename) count += 1 return filelist def loadList(self, list): - raise NotImplementedError(u'MediaManagerItem.loadList needs to be defined by the plugin') + raise NotImplementedError( + u'MediaManagerItem.loadList needs to be defined by the plugin') def onNewClick(self): - raise NotImplementedError(u'MediaManagerItem.onNewClick needs to be defined by the plugin') + raise NotImplementedError( + u'MediaManagerItem.onNewClick needs to be defined by the plugin') def onEditClick(self): - raise NotImplementedError(u'MediaManagerItem.onEditClick needs to be defined by the plugin') + raise NotImplementedError( + u'MediaManagerItem.onEditClick needs to be defined by the plugin') def onDeleteClick(self): raise NotImplementedError(u'MediaManagerItem.onDeleteClick needs to be defined by the plugin') @@ -323,7 +345,7 @@ class MediaManagerItem(QtGui.QWidget): raise NotImplementedError(u'MediaManagerItem.generateSlideData needs to be defined by the plugin') def onPreviewClick(self): - log.debug(self.PluginTextShort+u' Preview Requested') + log.debug(self.PluginTextShort + u' Preview Requested') service_item = self.buildServiceItem() if service_item is not None: self.parent.preview_controller.addServiceItem(service_item) @@ -335,7 +357,7 @@ class MediaManagerItem(QtGui.QWidget): self.parent.live_controller.addServiceItem(service_item) def onAddClick(self): - log.debug(self.PluginTextShort+u' Add Requested') + log.debug(self.PluginTextShort + u' Add Requested') service_item = self.buildServiceItem() if service_item is not None: self.parent.service_manager.addServiceItem(service_item) @@ -345,7 +367,8 @@ class MediaManagerItem(QtGui.QWidget): Common method for generating a service item """ service_item = ServiceItem(self.parent) - service_item.addIcon(u':/media/media_'+self.PluginTextShort.lower()+u'.png') + service_item.addIcon( + u':/media/media_' + self.PluginTextShort.lower() + u'.png') if self.generateSlideData(service_item): self.ListView.clearSelection() return service_item diff --git a/openlp/core/lib/pluginmanager.py b/openlp/core/lib/pluginmanager.py index eeb60bcb7..13c17b3a6 100644 --- a/openlp/core/lib/pluginmanager.py +++ b/openlp/core/lib/pluginmanager.py @@ -26,7 +26,7 @@ import os import sys import logging -from openlp.core.lib import Plugin, PluginStatus +from openlp.core.lib import Plugin, PluginStatus class PluginManager(object): """ diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index 9548d0057..368589515 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -188,13 +188,13 @@ class Renderer(object): else: pos = len(line) split_text = line - while metrics.width(split_text, -1) > line_width: + while metrics.width(split_text, -1) > line_width: #Find the next space to the left pos = line[:pos].rfind(u' ') #no more spaces found if pos == 0: split_text = line - while metrics.width(split_text, -1) > line_width: + while metrics.width(split_text, -1) > line_width: split_text = split_text[:-1] pos = len(split_text) else: @@ -242,7 +242,7 @@ class Renderer(object): # reset the frame. first time do not worry about what you paint on. self._frame = QtGui.QImage(self.bg_frame) x, y = self._correctAlignment(self._rect, bbox) - bbox = self._render_lines_unaligned(lines, False, (x, y), True) + bbox = self._render_lines_unaligned(lines, False, (x, y), True) if footer_lines is not None: bbox = self._render_lines_unaligned(footer_lines, True, (self._rect_footer.left(), self._rect_footer.top()), True) @@ -327,7 +327,8 @@ class Renderer(object): # centre align y = rect.top() + (rect.height() - bbox.height()) / 2 else: - log.error(u'Invalid value for theme.VerticalAlign:%s' % self._theme.display_verticalAlign) + log.error(u'Invalid value for theme.VerticalAlign:%s', + self._theme.display_verticalAlign) return x, y def _render_lines_unaligned(self, lines, footer, tlcorner=(0, 0), @@ -400,7 +401,7 @@ class Renderer(object): startx = x starty = y rightextent = None - #print "inputs", startx, starty, maxx, maxy + #print "inputs", startx, starty, maxx, maxy # dont allow alignment messing with footers if footer: align = 0 @@ -412,7 +413,7 @@ class Renderer(object): for linenum in range(len(lines)): line = lines[linenum] #find out how wide line is - w, h = self._get_extent_and_render(line, footer, tlcorner=(x, y), + w, h = self._get_extent_and_render(line, footer, tlcorner=(x, y), draw=False) if self._theme.display_shadow: w += shadow_offset diff --git a/openlp/core/lib/rendermanager.py b/openlp/core/lib/rendermanager.py index 23043b85a..751397562 100644 --- a/openlp/core/lib/rendermanager.py +++ b/openlp/core/lib/rendermanager.py @@ -121,7 +121,8 @@ class RenderManager(object): else: if theme is not None: self.theme = theme - elif self.global_style == u'Song' or self.global_style == u'Service': + elif self.global_style == u'Song' or \ + self.global_style == u'Service': if self.service_theme == u'': self.theme = self.global_theme else: @@ -129,9 +130,10 @@ class RenderManager(object): else: self.theme = self.global_theme if self.theme != self.renderer.theme_name: - log.debug(u'theme is now %s', self.theme) + log.debug(u'theme is now %s', self.theme) self.themedata = self.theme_manager.getThemeData(self.theme) - self.calculate_default(self.screen_list[self.current_display][u'size']) + self.calculate_default( + self.screen_list[self.current_display][u'size']) self.renderer.set_theme(self.themedata) self.build_text_rectangle(self.themedata) @@ -212,7 +214,7 @@ class RenderManager(object): self.renderer.set_frame_dest(self.width, self.height) return self.renderer.generate_frame_from_lines(main_text, footer_text) - def resize_image(self, image, width = 0, height = 0): + def resize_image(self, image, width=0, height=0): """ Resize an image to fit on the current screen. @@ -253,6 +255,7 @@ class RenderManager(object): self.width = screen.width() self.height = screen.height() self.screen_ratio = float(self.height) / float(self.width) - log.debug(u'calculate default %d, %d, %f', self.width, self.height, self.screen_ratio ) + log.debug(u'calculate default %d, %d, %f', + self.width, self.height, self.screen_ratio ) # 90% is start of footer self.footer_start = int(self.height * 0.90) diff --git a/openlp/core/ui/__init__.py b/openlp/core/ui/__init__.py index 27be91571..a55d2c2b0 100644 --- a/openlp/core/ui/__init__.py +++ b/openlp/core/ui/__init__.py @@ -39,5 +39,5 @@ from thememanager import ThemeManager from mainwindow import MainWindow __all__ = ['SplashScreen', 'AboutForm', 'SettingsForm', 'MasterToolbar', - 'MainWindow', 'MainDisplay', 'SlideController', 'ServiceManager', + 'MainWindow', 'MainDisplay', 'SlideController', 'ServiceManager', 'ThemeManager', 'AmendThemeForm'] diff --git a/openlp/core/ui/alertstab.py b/openlp/core/ui/alertstab.py index 1d006a473..251033966 100644 --- a/openlp/core/ui/alertstab.py +++ b/openlp/core/ui/alertstab.py @@ -24,7 +24,7 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import SettingsTab, translate +from openlp.core.lib import SettingsTab, translate class AlertsTab(SettingsTab): """ @@ -33,7 +33,8 @@ class AlertsTab(SettingsTab): def __init__(self): self.font_color = '#ffffff' self.bg_color = '#660000' - SettingsTab.__init__(self, translate(u'AlertsTab', u'Alerts'), u'Alerts') + SettingsTab.__init__( + self, translate(u'AlertsTab', u'Alerts'), u'Alerts') def setupUi(self): self.setObjectName(u'AlertsTab') @@ -110,10 +111,12 @@ class AlertsTab(SettingsTab): self.SlideRightLayout.setMargin(0) self.SlideRightLayout.setObjectName(u'SlideRightLayout') self.PreviewGroupBox = QtGui.QGroupBox(self.AlertRightColumn) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Minimum) + sizePolicy = QtGui.QSizePolicy( + QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Minimum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.PreviewGroupBox.sizePolicy().hasHeightForWidth()) + sizePolicy.setHeightForWidth( + self.PreviewGroupBox.sizePolicy().hasHeightForWidth()) self.PreviewGroupBox.setSizePolicy(sizePolicy) self.PreviewGroupBox.setObjectName(u'PreviewGroupBox') self.PreviewLayout = QtGui.QVBoxLayout(self.PreviewGroupBox) @@ -124,7 +127,8 @@ class AlertsTab(SettingsTab): self.FontPreview.setMinimumSize(QtCore.QSize(280, 100)) self.FontPreview.setReadOnly(True) self.FontPreview.setFocusPolicy(QtCore.Qt.NoFocus) - self.FontPreview.setAlignment(QtCore.Qt.AlignHCenter|QtCore.Qt.AlignVCenter) + self.FontPreview.setAlignment( + QtCore.Qt.AlignHCenter|QtCore.Qt.AlignVCenter) self.FontPreview.setObjectName(u'FontPreview') self.PreviewLayout.addWidget(self.FontPreview) self.SlideRightLayout.addWidget(self.PreviewGroupBox) @@ -146,11 +150,13 @@ class AlertsTab(SettingsTab): self.FontGroupBox.setTitle(translate(u'AlertsTab', u'Font')) self.FontLabel.setText(translate(u'AlertsTab', u'Font Name:')) self.FontColorLabel.setText(translate(u'AlertsTab', u'Font Color:')) - self.BackgroundColorLabel.setText(translate(u'AlertsTab', u'Background Color:')) + self.BackgroundColorLabel.setText( + translate(u'AlertsTab', u'Background Color:')) self.TimeoutLabel.setText(translate(u'AlertsTab', u'Alert timeout:')) self.TimeoutSpinBox.setSuffix(translate(u'AlertsTab', u's')) self.PreviewGroupBox.setTitle(translate(u'AlertsTab', u'Preview')) - self.FontPreview.setText(translate(u'AlertsTab', u'openlp.org 2.0 rocks!')) + self.FontPreview.setText( + translate(u'AlertsTab', u'openlp.org 2.0 rocks!')) def onBackgroundColorButtonClicked(self): self.bg_color = QtGui.QColorDialog.getColor( @@ -174,12 +180,17 @@ class AlertsTab(SettingsTab): def load(self): self.timeout = int(self.config.get_config(u'timeout', 5)) - self.font_color = unicode(self.config.get_config(u'font color', u'#ffffff')) - self.bg_color = unicode(self.config.get_config(u'background color', u'#660000')) - self.font_face = unicode(self.config.get_config(u'font face', QtGui.QFont().family())) + self.font_color = unicode( + self.config.get_config(u'font color', u'#ffffff')) + self.bg_color = unicode( + self.config.get_config(u'background color', u'#660000')) + self.font_face = unicode( + self.config.get_config(u'font face', QtGui.QFont().family())) self.TimeoutSpinBox.setValue(self.timeout) - self.FontColorButton.setStyleSheet(u'background-color: %s' % self.font_color) - self.BackgroundColorButton.setStyleSheet(u'background-color: %s' % self.bg_color) + self.FontColorButton.setStyleSheet( + u'background-color: %s' % self.font_color) + self.BackgroundColorButton.setStyleSheet( + u'background-color: %s' % self.bg_color) font = QtGui.QFont() font.setFamily(self.font_face) self.FontComboBox.setCurrentFont(font) @@ -198,5 +209,5 @@ class AlertsTab(SettingsTab): font.setBold(True) font.setPointSize(16) self.FontPreview.setFont(font) - self.FontPreview.setStyleSheet( - u'background-color: %s; color: %s' % (self.bg_color, self.font_color)) + self.FontPreview.setStyleSheet(u'background-color: %s; color: %s' % \ + (self.bg_color, self.font_color)) diff --git a/openlp/core/ui/amendthemeform.py b/openlp/core/ui/amendthemeform.py index f8de5ec80..913995722 100644 --- a/openlp/core/ui/amendthemeform.py +++ b/openlp/core/ui/amendthemeform.py @@ -33,7 +33,7 @@ from amendthemedialog import Ui_AmendThemeDialog log = logging.getLogger(u'AmendThemeForm') -class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): +class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog): def __init__(self, thememanager, parent=None): QtGui.QDialog.__init__(self, parent) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index f9b826981..78d55da28 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -26,7 +26,7 @@ import logging from PyQt4 import QtCore, QtGui from time import sleep -from openlp.core.lib import translate, Receiver +from openlp.core.lib import translate, Receiver class MainDisplay(QtGui.QWidget): """ @@ -129,7 +129,7 @@ class MainDisplay(QtGui.QWidget): self.displayBlank = False self.frameView(self.frame) - def displayAlert(self, text=u''): + def displayAlert(self, text=u''): """ Called from the Alert Tab to display an alert @@ -141,7 +141,8 @@ class MainDisplay(QtGui.QWidget): painter = QtGui.QPainter(alertframe) top = alertframe.rect().height() * 0.9 painter.fillRect( - QtCore.QRect(0, top, alertframe.rect().width(), alertframe.rect().height() - top), + QtCore.QRect(0, top, + alertframe.rect().width(), alertframe.rect().height() - top), QtGui.QColor(alertTab.bg_color)) font = QtGui.QFont() font.setFamily(alertTab.font_face) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index cd6d1d3cb..2c0d89e8e 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -28,7 +28,7 @@ import logging from PyQt4 import QtCore, QtGui from openlp.core.ui import AboutForm, SettingsForm, AlertForm, \ - ServiceManager, ThemeManager, MainDisplay, SlideController, \ + ServiceManager, ThemeManager, MainDisplay, SlideController, \ PluginForm from openlp.core.lib import translate, Plugin, MediaManagerItem, \ SettingsTab, RenderManager, PluginConfig, str_to_bool, OpenLPDockWidget, \ @@ -119,7 +119,7 @@ class Ui_MainWindow(object): # self.MediaManagerDock.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Ignored, # QtGui.QSizePolicy.Maximum)) -# geometry = self.MediaManagerDock.geometry() +# geometry = self.MediaManagerDock.geometry() # geometry.setWidth(self.settingsmanager.mainwindow_left) # self.MediaManagerDock.setGeometry(geometry) # self.MediaManagerDock.setMinimumWidth(10) diff --git a/openlp/core/ui/plugindialoglistform.py b/openlp/core/ui/plugindialoglistform.py index 55effb9de..afcc776ca 100644 --- a/openlp/core/ui/plugindialoglistform.py +++ b/openlp/core/ui/plugindialoglistform.py @@ -9,7 +9,7 @@ import logging from PyQt4 import QtCore, QtGui -from openlp.core.lib import translate, PluginStatus +from openlp.core.lib import translate, PluginStatus class PluginForm(QtGui.QDialog): global log @@ -45,14 +45,18 @@ class PluginForm(QtGui.QDialog): self.ButtonBox.setObjectName(u'ButtonBox') self.retranslateUi(PluginForm) - QtCore.QObject.connect(self.ButtonBox, QtCore.SIGNAL(u'accepted()'), PluginForm.close) + QtCore.QObject.connect(self.ButtonBox, + QtCore.SIGNAL(u'accepted()'), PluginForm.close) QtCore.QMetaObject.connectSlotsByName(PluginForm) def retranslateUi(self, PluginForm): PluginForm.setWindowTitle(translate(u'PluginForm', u'Plugin list')) - self.PluginViewList.horizontalHeaderItem(0).setText(translate(u'PluginForm', u'Name')) - self.PluginViewList.horizontalHeaderItem(1).setText(translate(u'PluginForm', u'Version')) - self.PluginViewList.horizontalHeaderItem(2).setText(translate(u'PluginForm', u'Status')) + self.PluginViewList.horizontalHeaderItem(0).setText( + translate(u'PluginForm', u'Name')) + self.PluginViewList.horizontalHeaderItem(1).setText( + translate(u'PluginForm', u'Version')) + self.PluginViewList.horizontalHeaderItem(2).setText( + translate(u'PluginForm', u'Status')) def load(self): """ @@ -68,14 +72,14 @@ class PluginForm(QtGui.QDialog): item2 = QtGui.QTableWidgetItem(plugin.version) item2.setTextAlignment(QtCore.Qt.AlignVCenter) if plugin.status == PluginStatus.Active: - item3 = QtGui.QTableWidgetItem(translate(u'PluginForm', u'Active')) + item3 = QtGui.QTableWidgetItem( + translate(u'PluginForm', u'Active')) else: - item3 = QtGui.QTableWidgetItem(translate(u'PluginForm', u'Inactive')) + item3 = QtGui.QTableWidgetItem( + translate(u'PluginForm', u'Inactive')) item3.setTextAlignment(QtCore.Qt.AlignVCenter) self.PluginViewList.setItem(row, 0, item1) self.PluginViewList.setItem(row, 1, item2) self.PluginViewList.setItem(row, 2, item3) self.PluginViewList.setRowHeight(row, 15) - - diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 736d6c38d..66c362668 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -33,7 +33,7 @@ import shutil from PyQt4 import QtCore, QtGui from openlp.core.lib import PluginConfig, OpenLPToolbar, ServiceItem, \ RenderManager, translate, buildIcon, ServiceType, \ - contextMenuAction, contextMenuSeparator, Receiver + contextMenuAction, contextMenuSeparator, Receiver from openlp.core.utils import ConfigHelper class ServiceManagerList(QtGui.QTreeWidget): @@ -285,7 +285,7 @@ class ServiceManager(QtGui.QWidget): temp = self.serviceItems[item] self.serviceItems.remove(self.serviceItems[item]) self.serviceItems.insert(item - 1, temp) - self.repaintServiceList(item - 1, count) + self.repaintServiceList(item - 1, count) self.parent.serviceChanged(False, self.serviceName) def onServiceDown(self): @@ -298,7 +298,7 @@ class ServiceManager(QtGui.QWidget): temp = self.serviceItems[item] self.serviceItems.remove(self.serviceItems[item]) self.serviceItems.insert(item + 1, temp) - self.repaintServiceList(item + 1, count) + self.repaintServiceList(item + 1, count) self.parent.serviceChanged(False, self.serviceName) def onServiceEnd(self): @@ -539,7 +539,7 @@ class ServiceManager(QtGui.QWidget): pos = 0 count = 0 for item in items: - parentitem = item.parent() + parentitem = item.parent() if parentitem is None: pos = item.data(0, QtCore.Qt.UserRole).toInt()[0] else: diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index a6c08164c..b26b4eacc 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -60,8 +60,8 @@ class SlideList(QtGui.QTableWidget): class SlideController(QtGui.QWidget): """ - SlideController is the slide controller widget. This widget is what the user - uses to control the displaying of verses/slides/etc on the screen. + SlideController is the slide controller widget. This widget is what the + user uses to control the displaying of verses/slides/etc on the screen. """ global log log = logging.getLogger(u'SlideController') @@ -74,7 +74,8 @@ class SlideController(QtGui.QWidget): self.settingsmanager = settingsmanager self.isLive = isLive self.parent = parent - self.image_list = [u'Start Loop', u'Stop Loop', u'Loop Separator', u'Image SpinBox'] + self.image_list = [ + u'Start Loop', u'Stop Loop', u'Loop Separator', u'Image SpinBox'] self.timer_id = 0 self.commandItem = None self.Panel = QtGui.QWidget(parent.ControlSplitter) @@ -177,7 +178,8 @@ class SlideController(QtGui.QWidget): sizePolicy.setHeightForWidth( self.SlidePreview.sizePolicy().hasHeightForWidth()) self.SlidePreview.setSizePolicy(sizePolicy) - self.SlidePreview.setFixedSize(QtCore.QSize(self.settingsmanager.slidecontroller_image, 225)) + self.SlidePreview.setFixedSize( + QtCore.QSize(self.settingsmanager.slidecontroller_image, 225)) self.SlidePreview.setFrameShape(QtGui.QFrame.Box) self.SlidePreview.setFrameShadow(QtGui.QFrame.Plain) self.SlidePreview.setLineWidth(1) @@ -238,7 +240,8 @@ class SlideController(QtGui.QWidget): """ log.debug(u'addServiceItem') #If old item was a command tell it to stop - if self.commandItem is not None and self.commandItem.service_item_type == ServiceType.Command: + if self.commandItem is not None and \ + self.commandItem.service_item_type == ServiceType.Command: Receiver().send_message(u'%s_stop'% self.commandItem.name.lower()) self.commandItem = item before = time.time() @@ -246,8 +249,9 @@ class SlideController(QtGui.QWidget): log.info(u'Rendering took %4s' % (time.time() - before)) self.enableToolBar(item) if item.service_item_type == ServiceType.Command: - Receiver().send_message(u'%s_start'%item.name.lower(), \ - [item.shortname, item.service_item_path, item.service_frames[0][u'title']]) + Receiver().send_message(u'%s_start' % item.name.lower(), \ + [item.shortname, item.service_item_path, + item.service_frames[0][u'title']]) else: self.displayServiceManagerItems(item, 0) @@ -259,13 +263,15 @@ class SlideController(QtGui.QWidget): """ log.debug(u'addServiceItem') #If old item was a command tell it to stop - if self.commandItem is not None and self.commandItem.service_item_type == ServiceType.Command: + if self.commandItem is not None and \ + self.commandItem.service_item_type == ServiceType.Command: Receiver().send_message(u'%s_stop'% self.commandItem.name.lower()) self.commandItem = item self.enableToolBar(item) if item.service_item_type == ServiceType.Command: - Receiver().send_message(u'%s_start'%item.name.lower(), \ - [item.shortname, item.service_item_path, item.service_frames[0][u'title']]) + Receiver().send_message(u'%s_start' % item.name.lower(), \ + [item.shortname, item.service_item_path, + item.service_frames[0][u'title']]) else: self.displayServiceManagerItems(item, slideno) @@ -279,9 +285,11 @@ class SlideController(QtGui.QWidget): self.serviceitem = serviceitem self.PreviewListWidget.clear() self.PreviewListWidget.setRowCount(0) - self.PreviewListWidget.setColumnWidth(0, self.settingsmanager.slidecontroller_image) + self.PreviewListWidget.setColumnWidth( + 0, self.settingsmanager.slidecontroller_image) for framenumber, frame in enumerate(self.serviceitem.frames): - self.PreviewListWidget.setRowCount(self.PreviewListWidget.rowCount() + 1) + self.PreviewListWidget.setRowCount( + self.PreviewListWidget.rowCount() + 1) item = QtGui.QTableWidgetItem() label = QtGui.QLabel() label.setMargin(8) @@ -294,9 +302,11 @@ class SlideController(QtGui.QWidget): label.setText(frame[u'text']) self.PreviewListWidget.setCellWidget(framenumber, 0, label) self.PreviewListWidget.setItem(framenumber, 0, item) - slide_height = self.settingsmanager.slidecontroller_image * self.parent.RenderManager.screen_ratio + slide_height = self.settingsmanager.slidecontroller_image * \ + self.parent.RenderManager.screen_ratio self.PreviewListWidget.setRowHeight(framenumber, slide_height) - self.PreviewListWidget.setColumnWidth(0, self.PreviewListWidget.viewport().size().width()) + self.PreviewListWidget.setColumnWidth( + 0, self.PreviewListWidget.viewport().size().width()) if slideno > self.PreviewListWidget.rowCount(): self.PreviewListWidget.selectRow(self.PreviewListWidget.rowCount()) else: @@ -357,7 +367,8 @@ class SlideController(QtGui.QWidget): Go to the previous slide. """ if self.commandItem.service_item_type == ServiceType.Command: - Receiver().send_message(u'%s_previous'% self.commandItem.name.lower()) + Receiver().send_message( + u'%s_previous'% self.commandItem.name.lower()) else: row = self.PreviewListWidget.currentRow() - 1 if row == -1: @@ -377,7 +388,8 @@ class SlideController(QtGui.QWidget): Start the timer loop running and store the timer id """ if self.PreviewListWidget.rowCount() > 1: - self.timer_id = self.startTimer(int(self.DelaySpinBox.value()) * 1000) + self.timer_id = self.startTimer( + int(self.DelaySpinBox.value()) * 1000) def onStopLoop(self): """ @@ -398,4 +410,5 @@ class SlideController(QtGui.QWidget): """ row = self.PreviewListWidget.currentRow() if row > -1 and row < self.PreviewListWidget.rowCount(): - self.parent.LiveController.addServiceManagerItem(self.commandItem, row) + self.parent.LiveController.addServiceManagerItem( + self.commandItem, row) diff --git a/openlp/core/ui/splashscreen.py b/openlp/core/ui/splashscreen.py index fef040591..788aa60c6 100644 --- a/openlp/core/ui/splashscreen.py +++ b/openlp/core/ui/splashscreen.py @@ -29,36 +29,42 @@ class SplashScreen(object): def __init__(self, version): self.splash_screen = QtGui.QSplashScreen() self.setupUi() - starting = translate(u'SplashScreen',u'Starting') - self.message=starting+u'..... '+version + starting = translate(u'SplashScreen', u'Starting') + self.message = starting + u'..... ' + version def setupUi(self): self.splash_screen.setObjectName(u'splash_screen') self.splash_screen.setWindowModality(QtCore.Qt.NonModal) self.splash_screen.setEnabled(True) self.splash_screen.resize(370, 370) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) + sizePolicy = QtGui.QSizePolicy( + QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.splash_screen.sizePolicy().hasHeightForWidth()) + sizePolicy.setHeightForWidth( + self.splash_screen.sizePolicy().hasHeightForWidth()) self.splash_screen.setSizePolicy(sizePolicy) self.splash_screen.setContextMenuPolicy(QtCore.Qt.PreventContextMenu) icon = QtGui.QIcon() - icon.addPixmap(QtGui.QPixmap(u':/icon/openlp-logo-16x16.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off) + icon.addPixmap(QtGui.QPixmap(u':/icon/openlp-logo-16x16.png'), + QtGui.QIcon.Normal, QtGui.QIcon.Off) splash_image = QtGui.QPixmap(u':/graphics/openlp-splash-screen.png') self.splash_screen.setWindowIcon(icon) self.splash_screen.setPixmap(splash_image) self.splash_screen.setMask(splash_image.mask()) - self.splash_screen.setWindowFlags(QtCore.Qt.SplashScreen | QtCore.Qt.WindowStaysOnTopHint) + self.splash_screen.setWindowFlags( + QtCore.Qt.SplashScreen | QtCore.Qt.WindowStaysOnTopHint) self.retranslateUi() QtCore.QMetaObject.connectSlotsByName(self.splash_screen) def retranslateUi(self): - self.splash_screen.setWindowTitle(translate(u'splash_screen', u'Splash Screen')) + self.splash_screen.setWindowTitle( + translate(u'splash_screen', u'Splash Screen')) def show(self): self.splash_screen.show() - self.splash_screen.showMessage(self.message, QtCore.Qt.AlignLeft | QtCore.Qt.AlignBottom, QtCore.Qt.black) + self.splash_screen.showMessage(self.message, + QtCore.Qt.AlignLeft | QtCore.Qt.AlignBottom, QtCore.Qt.black) self.splash_screen.repaint() def finish(self, widget): diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index a156b5358..6772c8655 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -97,10 +97,10 @@ class ThemeManager(QtGui.QWidget): def changeGlobalFromTab(self, themeName): log.debug(u'changeGlobalFromTab %s', themeName) - for count in range (0, self.ThemeListWidget.count()): + for count in range (0, self.ThemeListWidget.count()): #reset the old name item = self.ThemeListWidget.item(count) - oldName = item.text() + oldName = item.text() newName = unicode(item.data(QtCore.Qt.UserRole).toString()) if oldName != newName: self.ThemeListWidget.item(count).setText(newName) @@ -112,9 +112,9 @@ class ThemeManager(QtGui.QWidget): def changeGlobalFromScreen(self, index): log.debug(u'changeGlobalFromScreen %s', index) - for count in range (0, self.ThemeListWidget.count()): + for count in range (0, self.ThemeListWidget.count()): item = self.ThemeListWidget.item(count) - oldName = item.text() + oldName = item.text() #reset the old name if oldName != unicode(item.data(QtCore.Qt.UserRole).toString()): self.ThemeListWidget.item(count).setText( @@ -194,12 +194,13 @@ class ThemeManager(QtGui.QWidget): path = unicode(path) if path != u'': self.config.set_last_dir(path, 1) - themePath = os.path.join(path, theme + u'.theme') + themePath = os.path.join(path, theme + u'.theme') zip = zipfile.ZipFile(themePath, 'w') source = os.path.join(self.path, theme) for root, dirs, files in os.walk(source): for name in files: - zip.write(os.path.join(source, name), os.path.join(theme, name)) + zip.write( + os.path.join(source, name), os.path.join(theme, name)) zip.close() def onImportTheme(self): @@ -226,7 +227,7 @@ class ThemeManager(QtGui.QWidget): for name in files: if name.endswith(u'.png'): #check to see file is in theme root directory - theme = os.path.join(self.path, name) + theme = os.path.join(self.path, name) if os.path.exists(theme): (path, filename) = os.path.split(unicode(file)) textName = os.path.splitext(name)[0] @@ -244,7 +245,7 @@ class ThemeManager(QtGui.QWidget): self.pushThemes() def pushThemes(self): - Receiver().send_message(u'update_themes', self.getThemes() ) + Receiver().send_message(u'update_themes', self.getThemes() ) def getThemes(self): return self.themelist diff --git a/openlp/core/ui/themestab.py b/openlp/core/ui/themestab.py index 69a77a20a..8dee1b90e 100644 --- a/openlp/core/ui/themestab.py +++ b/openlp/core/ui/themestab.py @@ -24,7 +24,7 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import SettingsTab, translate, Receiver +from openlp.core.lib import SettingsTab, translate, Receiver class ThemesTab(SettingsTab): """ @@ -32,7 +32,8 @@ class ThemesTab(SettingsTab): """ def __init__(self, parent): self.parent = parent - SettingsTab.__init__(self, translate(u'ThemesTab', u'Themes'), u'Themes') + SettingsTab.__init__( + self, translate(u'ThemesTab', u'Themes'), u'Themes') def setupUi(self): self.setObjectName(u'ThemesTab') @@ -106,15 +107,19 @@ class ThemesTab(SettingsTab): def retranslateUi(self): self.GlobalGroupBox.setTitle(translate(u'ThemesTab', u'Global theme')) self.LevelGroupBox.setTitle(translate(u'ThemesTab', u'Theme level')) - self.SongLevelRadioButton.setText(translate(u'ThemesTab', u'Song level')) + self.SongLevelRadioButton.setText( + translate(u'ThemesTab', u'Song level')) self.SongLevelLabel.setText(translate(u'ThemesTab', u'Use the theme from each song in the database. If a song doesn\'t have a theme associated with it, then use the service\'s theme. If the service doesn\'t have a theme, then use the global theme.')) - self.ServiceLevelRadioButton.setText(translate(u'ThemesTab', u'Service level')) + self.ServiceLevelRadioButton.setText( + translate(u'ThemesTab', u'Service level')) self.ServiceLevelLabel.setText(translate(u'ThemesTab', u'Use the theme from the service, overriding any of the individual songs\' themes. If the service doesn\'t have a theme, then use the global theme.')) - self.GlobalLevelRadioButton.setText(translate(u'ThemesTab', u'Global level')) + self.GlobalLevelRadioButton.setText( + translate(u'ThemesTab', u'Global level')) self.GlobalLevelLabel.setText(translate(u'ThemesTab', u'Use the global theme, overriding any themes associated with either the service or the songs.')) def load(self): - self.global_style = self.config.get_config(u'theme global style', u'Global') + self.global_style = self.config.get_config( + u'theme global style', u'Global') self.global_theme = self.config.get_config(u'theme global theme', u'') if self.global_style == u'Global': self.GlobalLevelRadioButton.setChecked(True) @@ -126,29 +131,35 @@ class ThemesTab(SettingsTab): def save(self): self.config.set_config(u'theme global style', self.global_style ) self.config.set_config(u'theme global theme',self.global_theme) - Receiver().send_message(u'update_global_theme', self.global_theme ) + Receiver().send_message(u'update_global_theme', self.global_theme ) def postSetUp(self): - Receiver().send_message(u'update_global_theme', self.global_theme ) + Receiver().send_message(u'update_global_theme', self.global_theme ) def onSongLevelButtonPressed(self): self.global_style= u'Song' - self.parent.RenderManager.set_global_theme(self.global_theme, self.global_style) + self.parent.RenderManager.set_global_theme( + self.global_theme, self.global_style) def onServiceLevelButtonPressed(self): self.global_style= u'Service' - self.parent.RenderManager.set_global_theme(self.global_theme, self.global_style) + self.parent.RenderManager.set_global_theme( + self.global_theme, self.global_style) def onGlobalLevelButtonPressed(self): self.global_style= u'Global' - self.parent.RenderManager.set_global_theme(self.global_theme, self.global_style) + self.parent.RenderManager.set_global_theme( + self.global_theme, self.global_style) def onDefaultComboBoxChanged(self, value): self.global_theme = unicode(self.DefaultComboBox.currentText()) - self.parent.RenderManager.set_global_theme(self.global_theme, self.global_style) - image = self.parent.ThemeManagerContents.getPreviewImage(self.global_theme) + self.parent.RenderManager.set_global_theme( + self.global_theme, self.global_style) + image = self.parent.ThemeManagerContents.getPreviewImage( + self.global_theme) preview = QtGui.QPixmap(unicode(image)) - display = preview.scaled(300, 255, QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation) + display = preview.scaled(300, 255, QtCore.Qt.KeepAspectRatio, + QtCore.Qt.SmoothTransformation) self.DefaultListView.setPixmap(display) def updateThemeList(self, theme_list): @@ -160,14 +171,18 @@ class ThemesTab(SettingsTab): self.DefaultComboBox.clear() for theme in theme_list: self.DefaultComboBox.addItem(theme) - id = self.DefaultComboBox.findText(self.global_theme, QtCore.Qt.MatchExactly) + id = self.DefaultComboBox.findText( + self.global_theme, QtCore.Qt.MatchExactly) if id == -1: id = 0 # Not Found self.global_theme = u'' self.DefaultComboBox.setCurrentIndex(id) - self.parent.RenderManager.set_global_theme(self.global_theme, self.global_style) + self.parent.RenderManager.set_global_theme( + self.global_theme, self.global_style) if self.global_theme is not u'': - image = self.parent.ThemeManagerContents.getPreviewImage(self.global_theme) + image = self.parent.ThemeManagerContents.getPreviewImage( + self.global_theme) preview = QtGui.QPixmap(unicode(image)) - display = preview.scaled(300, 255, QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation) + display = preview.scaled(300, 255, QtCore.Qt.KeepAspectRatio, + QtCore.Qt.SmoothTransformation) self.DefaultListView.setPixmap(display) diff --git a/openlp/migration/migratesongs.py b/openlp/migration/migratesongs.py index ad329ccd7..965cf3113 100644 --- a/openlp/migration/migratesongs.py +++ b/openlp/migration/migratesongs.py @@ -31,17 +31,18 @@ from openlp.core.lib import PluginConfig from sqlalchemy import * from sqlalchemy.sql import select from sqlalchemy import create_engine -from sqlalchemy.orm import scoped_session, sessionmaker, mapper, relation, clear_mappers +from sqlalchemy.orm import scoped_session, sessionmaker, mapper, relation, \ + clear_mappers from openlp.plugins.songs.lib.models import metadata, session, \ - engine, songs_table, Song, Author, Topic, Book + engine, songs_table, Song, Author, Topic, Book from openlp.plugins.songs.lib.tables import * from openlp.plugins.songs.lib.classes import * def init_models(url): engine = create_engine(url) metadata.bind = engine - session = scoped_session(sessionmaker(autoflush=True, autocommit=False, - bind=engine)) + session = scoped_session( + sessionmaker(autoflush=True, autocommit=False, bind=engine)) mapper(Author, authors_table) mapper(TAuthor, temp_authors_table) mapper(Book, song_books_table) @@ -57,7 +58,7 @@ def init_models(url): return session temp_authors_table = Table(u'authors_temp', metadata, - Column(u'authorid', types.Integer, primary_key=True), + Column(u'authorid', types.Integer, primary_key=True), Column(u'authorname', String(40)) ) @@ -154,14 +155,18 @@ class MigrateSongs(): song.search_title = u'' song.search_lyrics = u'' print songs_temp.songtitle - aa = self.session.execute(u'select * from songauthors_temp where songid =' + unicode(songs_temp.songid) ) + aa = self.session.execute( + u'select * from songauthors_temp where songid =' + \ + unicode(songs_temp.songid) ) for row in aa: a = row['authorid'] authors_temp = self.session.query(TAuthor).get(a) - bb = self.session.execute(u'select * from authors where display_name = \"%s\"' % unicode(authors_temp.authorname) ).fetchone() + bb = self.session.execute( + u'select * from authors where display_name = \"%s\"' % \ + unicode(authors_temp.authorname) ).fetchone() if bb is None: author = Author() - author.display_name = authors_temp.authorname + author.display_name = authors_temp.authorname author.first_name = u'' author.last_name = u'' else: @@ -180,11 +185,11 @@ class MigrateSongs(): conn = sqlite3.connect(self.data_path + os.sep + database) conn.execute("""update songs set search_title = replace(replace(replace(replace(replace(replace(replace(replace( - replace(title, '&', 'and'), ',', ''), ';', ''), ':', ''), + replace(title, '&', 'and'), ',', ''), ';', ''), ':', ''), '(u', ''), ')', ''), '{', ''), '}',''),'?','');""") conn.execute("""update songs set search_lyrics = replace(replace(replace(replace(replace(replace(replace(replace( - replace(lyrics, '&', 'and'), ',', ''), ';', ''), ':', ''), + replace(lyrics, '&', 'and'), ',', ''), ';', ''), ':', ''), '(u', ''), ')', ''), '{', ''), '}',''),'?','') ;""") conn.commit() diff --git a/openlp/plugins/audit/auditplugin.py b/openlp/plugins/audit/auditplugin.py index e78b2d455..065099442 100644 --- a/openlp/plugins/audit/auditplugin.py +++ b/openlp/plugins/audit/auditplugin.py @@ -27,7 +27,7 @@ import logging from PyQt4 import QtCore, QtGui from datetime import date -from openlp.core.lib import Plugin, Receiver, translate, str_to_bool +from openlp.core.lib import Plugin, Receiver, translate, str_to_bool from openlp.plugins.audit.lib import AuditTab class AuditPlugin(Plugin): @@ -98,7 +98,8 @@ class AuditPlugin(Plugin): QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'audit_changed'), self.onUpdateAudit) self.auditFileName = self.config.get_config(u'audit file', u'') - self.auditActive = str_to_bool(self.config.get_config(u'audit active', False)) + self.auditActive = str_to_bool( + self.config.get_config(u'audit active', False)) if self.auditFileName == u'': self.auditActive = False self.ToolsAuditItem.setEnabled(False) @@ -117,7 +118,8 @@ class AuditPlugin(Plugin): """ if self.auditActive: for author in auditData[1]: - self.auditFile.write(u'\"%s\",\"%s\",\"%s\",\"%s\"\n' % (date.today(), auditData[0], author, auditData[2])) + self.auditFile.write(u'\"%s\",\"%s\",\"%s\",\"%s\"\n' % \ + (date.today(), auditData[0], author, auditData[2])) self.auditFile.flush() def onUpdateAudit(self): @@ -126,7 +128,8 @@ class AuditPlugin(Plugin): Sort out the file and the auditing state """ self.auditFileNameNew = self.config.get_config(u'audit file', u'') - self.auditActive = str_to_bool(self.config.get_config(u'audit active', False)) + self.auditActive = str_to_bool( + self.config.get_config(u'audit active', False)) if self.auditFileNameNew == u'': self.auditActive = False self.ToolsAuditItem.setChecked(self.auditActive) diff --git a/openlp/plugins/audit/lib/audittab.py b/openlp/plugins/audit/lib/audittab.py index 596772856..603e4b076 100644 --- a/openlp/plugins/audit/lib/audittab.py +++ b/openlp/plugins/audit/lib/audittab.py @@ -24,7 +24,7 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import SettingsTab, str_to_bool, translate, Receiver +from openlp.core.lib import SettingsTab, str_to_bool, translate, Receiver class AuditTab(SettingsTab): """ @@ -45,7 +45,8 @@ class AuditTab(SettingsTab): self.AuditFileName.setObjectName("AuditFileName") self.horizontalLayout.addWidget(self.AuditFileName) icon1 = QtGui.QIcon() - icon1.addPixmap(QtGui.QPixmap(u':/imports/import_load.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off) + icon1.addPixmap(QtGui.QPixmap(u':/imports/import_load.png'), + QtGui.QIcon.Normal, QtGui.QIcon.Off) self.AuditFileButton = QtGui.QPushButton(self) self.AuditFileButton.setObjectName("AuditFileButton") self.AuditFileButton.setIcon(icon1) @@ -63,19 +64,23 @@ class AuditTab(SettingsTab): def retranslateUi(self): self.AuditModeGroupBox.setTitle(translate(u'AuditTab', u'Audit File')) self.AuditActive.setText(translate(u'AuditTab', 'Audit available:')) - self.WarningLabel.setText(translate(u'AuditTab', u'A restart is needed for this change to become effective')) + self.WarningLabel.setText(translate(u'AuditTab', + u'A restart is needed for this change to become effective')) def load(self): self.AuditFileName.setText(self.config.get_config(u'Audit file', u'')) self.AuditActive.setChecked(int(self.config.get_config(u'startup', 0))) def onAuditFileButtonClicked(self): - filename = QtGui.QFileDialog.getOpenFileName(self, u'Audit File',self.AuditFileName.text()) + filename = QtGui.QFileDialog.getOpenFileName( + self, u'Audit File',self.AuditFileName.text()) if filename != u'': filename = unicode(filename) self.AuditFileName.setText(filename) def save(self): - self.config.set_config(u'Audit file', unicode(self.AuditFileName.text())) - self.config.set_config(u'startup', unicode(self.AuditActive.checkState())) + self.config.set_config( + u'Audit file', unicode(self.AuditFileName.text())) + self.config.set_config( + u'startup', unicode(self.AuditActive.checkState())) Receiver().send_message(u'audit_changed') diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index 0de2f4ced..724f24429 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -25,7 +25,6 @@ import logging from PyQt4 import QtCore, QtGui -from PyQt4.QtCore import * from openlp.core.lib import Plugin, translate @@ -62,7 +61,8 @@ class BiblePlugin(Plugin): import_menu.addAction(self.ImportBibleItem) self.ImportBibleItem.setText(translate(u'BiblePlugin', u'&Bible')) # Signals and slots - QtCore.QObject.connect(self.ImportBibleItem, QtCore.SIGNAL(u'triggered()'), self.onBibleNewClick) + QtCore.QObject.connect(self.ImportBibleItem, + QtCore.SIGNAL(u'triggered()'), self.onBibleNewClick) def add_export_menu_item(self, export_menu): self.ExportBibleItem = QtGui.QAction(export_menu) diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index 64614b9c6..cddc8abd5 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -31,7 +31,7 @@ import logging from PyQt4 import QtCore, QtGui from bibleimportdialog import Ui_BibleImportDialog -from openlp.core.lib import Receiver, translate +from openlp.core.lib import Receiver, translate class BibleImportForm(QtGui.QDialog, Ui_BibleImportDialog): @@ -41,7 +41,7 @@ class BibleImportForm(QtGui.QDialog, Ui_BibleImportDialog): """ Class documentation goes here. """ - def __init__(self, config, biblemanager , bibleplugin, parent = None): + def __init__(self, config, biblemanager, bibleplugin, parent=None): ''' Constructor ''' @@ -196,23 +196,28 @@ class BibleImportForm(QtGui.QDialog, Ui_BibleImportDialog): log.debug(u'Import Bible') message = None if self.bible_type == u'OSIS': - loaded = self.biblemanager.register_osis_file_bible(unicode(self.BibleNameEdit.displayText()), + loaded = self.biblemanager.register_osis_file_bible( + unicode(self.BibleNameEdit.displayText()), self.OSISLocationEdit.displayText()) elif self.bible_type == u'CSV': - loaded = self.biblemanager.register_csv_file_bible(unicode(self.BibleNameEdit.displayText()), - self.BooksLocationEdit.displayText(), self.VerseLocationEdit.displayText()) + loaded = self.biblemanager.register_csv_file_bible( + unicode(self.BibleNameEdit.displayText()), + self.BooksLocationEdit.displayText(), + self.VerseLocationEdit.displayText()) else: # set a value as it will not be needed self.setMax(1) - bible = self.bible_versions[unicode(self.BibleComboBox.currentText())] - loaded = self.biblemanager.register_http_bible(unicode(self.BibleComboBox.currentText()), \ - unicode(self.LocationComboBox.currentText()), \ - unicode(bible), \ - unicode(self.AddressEdit.displayText()), \ - unicode(self.UsernameEdit .displayText()), \ - unicode(self.PasswordEdit.displayText())) + bible = self.bible_versions[ + unicode(self.BibleComboBox.currentText())] + loaded = self.biblemanager.register_http_bible( + unicode(self.BibleComboBox.currentText()), + unicode(self.LocationComboBox.currentText()), + unicode(bible), unicode(self.AddressEdit.displayText()), + unicode(self.UsernameEdit .displayText()), + unicode(self.PasswordEdit.displayText())) if loaded: - self.biblemanager.save_meta_data(unicode(self.BibleNameEdit.displayText()), + self.biblemanager.save_meta_data( + unicode(self.BibleNameEdit.displayText()), unicode(self.VersionNameEdit.displayText()), unicode(self.CopyrightEdit.displayText()), unicode(self.PermisionEdit.displayText())) @@ -226,7 +231,8 @@ class BibleImportForm(QtGui.QDialog, Ui_BibleImportDialog): return loaded, message def checkOsis(self): - if len(self.BooksLocationEdit.displayText()) > 0 or len(self.VerseLocationEdit.displayText()) > 0: + if len(self.BooksLocationEdit.displayText()) > 0 or \ + len(self.VerseLocationEdit.displayText()) > 0: self.setCsv() else: # Was CSV and is not any more stops lostFocus running mad @@ -235,7 +241,8 @@ class BibleImportForm(QtGui.QDialog, Ui_BibleImportDialog): self.resetScreenFieldStates() def checkHttp(self): - if self.BibleComboBox.currentIndex() != 0 : # First slot is blank so no bible + if self.BibleComboBox.currentIndex() != 0 : + # First slot is blank so no bible self.setHttp() else: # Was HTTP and is not any more stops lostFocus running mad diff --git a/openlp/plugins/bibles/lib/bibleCSVimpl.py b/openlp/plugins/bibles/lib/bibleCSVimpl.py index e65dc675d..1df41a551 100644 --- a/openlp/plugins/bibles/lib/bibleCSVimpl.py +++ b/openlp/plugins/bibles/lib/bibleCSVimpl.py @@ -42,7 +42,8 @@ class BibleCSVImpl(BibleCommon): """ self.bibledb = bibledb self.loadbible = True - QtCore.QObject.connect(Receiver().get_receiver(),QtCore.SIGNAL(u'openlpstopimport'),self.stop_import) + QtCore.QObject.connect(Receiver().get_receiver(), + QtCore.SIGNAL(u'openlpstopimport'), self.stop_import) def stop_import(self): self.loadbible= False @@ -80,7 +81,7 @@ class BibleCSVImpl(BibleCommon): # split into 3 units and leave the rest as a single field p = line.split(u',', 3) p0 = p[0].replace(u'"', u'') - p3 = p[3].replace(u'"',u'') + p3 = p[3].replace(u'"',u'') if book_ptr is not p0: book = self.bibledb.get_bible_book(p0) book_ptr = book.name diff --git a/openlp/plugins/bibles/lib/bibleDBimpl.py b/openlp/plugins/bibles/lib/bibleDBimpl.py index e9d8c047e..322109bd4 100644 --- a/openlp/plugins/bibles/lib/bibleDBimpl.py +++ b/openlp/plugins/bibles/lib/bibleDBimpl.py @@ -59,7 +59,7 @@ class BibleDBImpl(BibleCommon): self._load_testament(u'New Testament') self._load_testament(u'Apocrypha') - def add_verse(self, bookid, chap, vse, text): + def add_verse(self, bookid, chap, vse, text): #log.debug(u'add_verse %s,%s,%s", bookid, chap, vse) verse = Verse() verse.book_id = bookid @@ -113,7 +113,7 @@ class BibleDBImpl(BibleCommon): return False def _load_testament(self, testament): - log.debug(u'load_testaments %s', testament) + log.debug(u'load_testaments %s', testament) test = ONTestament() test.name = testament self.session.add(test) diff --git a/openlp/plugins/bibles/lib/bibleHTTPimpl.py b/openlp/plugins/bibles/lib/bibleHTTPimpl.py index 66dbd4ee9..22e3c0d7c 100644 --- a/openlp/plugins/bibles/lib/bibleHTTPimpl.py +++ b/openlp/plugins/bibles/lib/bibleHTTPimpl.py @@ -39,21 +39,32 @@ class BGExtract(BibleCommon): log.debug(u'init %s', proxyurl) self.proxyurl = proxyurl - def get_bible_chapter(self, version, bookid, bookname, chapter) : + def get_bible_chapter(self, version, bookid, bookname, chapter) : """ Access and decode bibles via the BibleGateway website - Version - the version of the bible like 31 for New International version - bookid - Book id for the book of the bible - eg 1 for Genesis - bookname - not used - chapter - chapter number + + ``Version`` + The version of the bible like 31 for New International version + + ``bookid`` + Book id for the book of the bible - eg 1 for Genesis + + ``bookname`` + Not used + + ``chapter`` + Chapter number """ - log.debug( u'get_bible_chapter %s,%s,%s,%s', version, bookid, bookname, chapter) - urlstring = u'http://www.biblegateway.com/passage/?book_id='+unicode(bookid)+u'&chapter'+unicode(chapter)+u'&version='+unicode(version) + log.debug(u'get_bible_chapter %s,%s,%s,%s', + version, bookid, bookname, chapter) + urlstring = u'http://www.biblegateway.com/passage/?book_id=' + \ + unicode(bookid) + u'&chapter' + unicode(chapter) + u'&version=' + \ + unicode(version) xml_string = self._get_web_text(urlstring, self.proxyurl) #print xml_string - VerseSearch = u'class='+u'"'+u'sup'+u'"'+u'>' + VerseSearch = u'class=' + u'"' + u'sup' + u'"' + u'>' verse = 1 - i= xml_string.find(u'result-text-style-normal') + i = xml_string.find(u'result-text-style-normal') xml_string = xml_string[i:len(xml_string)] versePos = xml_string.find(VerseSearch) #print versePos @@ -62,11 +73,11 @@ class BGExtract(BibleCommon): verseText = '' # clear out string versePos = xml_string.find(u' 0 and j < i: i = j verseText = xml_string[versePos + 7 : i ] @@ -75,9 +86,11 @@ class BGExtract(BibleCommon): bible[verse] = self._clean_text(verseText) # store the verse versePos = -1 else: - i = xml_string[:i].rfind(u' - xml_string = xml_string[i - 1 :len(xml_string)] # chop off verse 1 + i = xml_string[:i].rfind(u' + verseText = xml_string[versePos + 7 : i - 1 ] + # Chop off verse 1 + xml_string = xml_string[i - 1 :len(xml_string)] versePos = xml_string.find(VerseSearch) #look for the next verse bible[verse] = self._clean_text(verseText) # store the verse verse += 1 @@ -92,16 +105,26 @@ class CWExtract(BibleCommon): log.debug(u'init %s', proxyurl) self.proxyurl = proxyurl - def get_bible_chapter(self, version, bookid, bookname, chapter) : - log.debug( u'getBibleChapter %s,%s,%s,%s', version, bookid, bookname, chapter) + def get_bible_chapter(self, version, bookid, bookname, chapter) : + log.debug(u'getBibleChapter %s,%s,%s,%s', + version, bookid, bookname, chapter) """ Access and decode bibles via the Crosswalk website - Version - the version of the bible like niv for New International version - bookid - not used - bookname - text name of in english eg 'gen' for Genesis - chapter - chapter number + + ``version`` + The version of the bible like niv for New International Version + + ``bookid`` + Not used + + ``bookname`` + Text name of in english e.g. 'gen' for Genesis + + ``chapter`` + Chapter number """ - log.debug(u'get_bible_chapter %s,%s,%s,%s', version, bookid, bookname, chapter) + log.debug(u'get_bible_chapter %s,%s,%s,%s', + version, bookid, bookname, chapter) bookname = bookname.replace(u' ', u'') urlstring = u'http://bible.crosswalk.com/OnlineStudyBible/bible.cgi?word=%s+%d&version=%s' % (bookname, chapter, version) xml_string = self._get_web_text(urlstring, self.proxyurl) @@ -135,7 +158,7 @@ class CWExtract(BibleCommon): #remove the at the front xml_string = xml_string[i + 3 :len(xml_string)] versePos = xml_string.find(u'
') - #log.debug(u'verse pos %d', versePos) + #log.debug(u'verse pos %d', versePos) bible = {} while versePos > 0: verseText = u'' @@ -153,7 +176,7 @@ class CWExtract(BibleCommon): verseText = xml_string[versePos: i] versePos = 0 else: - #log.debug( i, versePos) + #log.debug( i, versePos) verseText = xml_string[versePos: i] versePos = i #print verseText @@ -170,7 +193,9 @@ class BibleHTTPImpl(): def __init__(self): """ Finds all the bibles defined for the system - Creates an Interface Object for each bible containing connection information + Creates an Interface Object for each bible containing connection + information + Throws Exception if no Bibles are found. Init confirms the bible exists and stores the database path. @@ -202,18 +227,19 @@ class BibleHTTPImpl(): log.debug(u'set_bible_source %s', biblesource) self.biblesource = biblesource - def get_bible_chapter(self, version, bookid, bookname, chapter): + def get_bible_chapter(self, version, bookid, bookname, chapter): """ Receive the request and call the relevant handler methods """ - log.debug(u'get_bible_chapter %s,%s,%s,%s', version, bookid, bookname, chapter) + log.debug(u'get_bible_chapter %s,%s,%s,%s', + version, bookid, bookname, chapter) log.debug(u'biblesource = %s', self.biblesource) try: if self.biblesource.lower() == u'crosswalk': ev = CWExtract(self.proxyurl) else: ev = BGExtract(self.proxyurl) - return ev.get_bible_chapter(self.bibleid, bookid, bookname, chapter) + return ev.get_bible_chapter(self.bibleid, bookid, bookname, chapter) except Exception, e: log.error(u'Error thrown = %s', e.args[0]) print e diff --git a/openlp/plugins/bibles/lib/bibleOSISimpl.py b/openlp/plugins/bibles/lib/bibleOSISimpl.py index d796ea052..0d795c27d 100644 --- a/openlp/plugins/bibles/lib/bibleOSISimpl.py +++ b/openlp/plugins/bibles/lib/bibleOSISimpl.py @@ -86,7 +86,7 @@ class BibleOSISImpl(): The Import dialog, so that we can increase the counter on the progress bar. """ - detect_file = open(osisfile_record, u'r') + detect_file = open(osisfile_record, u'r') details = chardet.detect(detect_file.read(2048)) detect_file.close() osis = codecs.open(osisfile_record, u'r', details['encoding']) @@ -102,7 +102,7 @@ class BibleOSISImpl(): pos = file_record.find(verseText) if pos > -1: # we have a verse epos= file_record.find(u'>', pos) - ref = file_record[pos+15:epos-1] # Book Reference + ref = file_record[pos+15:epos-1] # Book Reference #lets find the bible text only # find start of text pos = epos + 1 @@ -113,10 +113,10 @@ class BibleOSISImpl(): text = self.remove_block(u'', text) text = self.remove_block(u'', text) text = self.remove_block(u'', text) - text = self.remove_tag(u'') pos = text.find(u'') while pos > -1: epos = text.find(u'', pos) - text = text[:pos] + text[epos + 4: ] + text = text[:pos] + text[epos + 4: ] #print "X", pos, epos, text pos = text.find(u'') # split up the reference @@ -184,7 +184,7 @@ class BibleOSISImpl(): if epos == -1: pos = -1 else: - text = text[:pos] + text[epos + len(end_tag): ] + text = text[:pos] + text[epos + len(end_tag): ] pos = text.find(start_tag) return text @@ -203,6 +203,6 @@ class BibleOSISImpl(): pos = text.find(start_tag) while pos > -1: epos = text.find(u'/>', pos) - text = text[:pos] + text[epos + 2: ] + text = text[:pos] + text[epos + 2: ] pos = text.find(start_tag) return text diff --git a/openlp/plugins/bibles/lib/biblestab.py b/openlp/plugins/bibles/lib/biblestab.py index 39d85ea8b..288048301 100644 --- a/openlp/plugins/bibles/lib/biblestab.py +++ b/openlp/plugins/bibles/lib/biblestab.py @@ -26,7 +26,7 @@ import logging from PyQt4 import Qt, QtCore, QtGui -from openlp.core.lib import translate, str_to_bool, Receiver +from openlp.core.lib import translate, str_to_bool, Receiver from openlp.core.lib import SettingsTab class BiblesTab(SettingsTab): @@ -42,7 +42,8 @@ class BiblesTab(SettingsTab): self.show_new_chapters = False self.display_style = 0 self.bible_search = True - SettingsTab.__init__(self, translate(u'BiblesTab', u'Bibles'), u'Bibles') + SettingsTab.__init__( + self, translate(u'BiblesTab', u'Bibles'), u'Bibles') def setupUi(self): self.setObjectName(u'BiblesTab') @@ -142,34 +143,53 @@ class BiblesTab(SettingsTab): self.BibleLayout.addWidget(self.BibleRightWidget) # Signals and slots QtCore.QObject.connect(self.NewChaptersCheckBox, - QtCore.SIGNAL(u'stateChanged(int)'), self.onNewChaptersCheckBoxChanged) + QtCore.SIGNAL(u'stateChanged(int)'), + self.onNewChaptersCheckBoxChanged) QtCore.QObject.connect(self.BibleSearchCheckBox, - QtCore.SIGNAL(u'stateChanged(int)'), self.onBibleSearchCheckBoxChanged) + QtCore.SIGNAL(u'stateChanged(int)'), + self.onBibleSearchCheckBoxChanged) QtCore.QObject.connect(self.DisplayStyleComboBox, - QtCore.SIGNAL(u'activated(int)'), self.onDisplayStyleComboBoxChanged) + QtCore.SIGNAL(u'activated(int)'), + self.onDisplayStyleComboBoxChanged) QtCore.QObject.connect(self.BibleThemeComboBox, QtCore.SIGNAL(u'activated(int)'), self.onBibleThemeComboBoxChanged) QtCore.QObject.connect(self.LayoutStyleComboBox, - QtCore.SIGNAL(u'activated(int)'), self.onLayoutStyleComboBoxChanged) + QtCore.SIGNAL(u'activated(int)'), + self.onLayoutStyleComboBoxChanged) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'update_themes'), self.updateThemeList) def retranslateUi(self): - self.VerseDisplayGroupBox.setTitle(translate(u'SettingsForm', u'Verse Display')) - self.NewChaptersCheckBox.setText(translate(u'SettingsForm', u'Only show new chapter numbers')) - self.LayoutStyleLabel.setText(translate(u'SettingsForm', u'Layout Style:')) - self.DisplayStyleLabel.setText(translate(u'SettingsForm', u'Display Style:')) - self.BibleThemeLabel.setText(translate(u'SettingsForm', u'Bible Theme:')) - self.LayoutStyleComboBox.setItemText(0, translate(u'SettingsForm', u'verse per slide')) - self.LayoutStyleComboBox.setItemText(1, translate(u'SettingsForm', u'verse per line')) - self.LayoutStyleComboBox.setItemText(2, translate(u'SettingsForm', u'continuous')) - self.DisplayStyleComboBox.setItemText(0, translate(u'SettingsForm', u'No brackets')) - self.DisplayStyleComboBox.setItemText(1, translate(u'SettingsForm', u'( and )')) - self.DisplayStyleComboBox.setItemText(2, translate(u'SettingsForm', u'{ and }')) - self.DisplayStyleComboBox.setItemText(3, translate(u'SettingsForm', u'[ and ]')) - self.ChangeNoteLabel.setText(translate(u'SettingsForm', u'Note:\nChanges don\'t affect verses already in the service')) - self.BibleSearchGroupBox.setTitle(translate(u'SettingsForm', u'Search')) - self.BibleSearchCheckBox.setText(translate(u'SettingsForm', u'Search-as-you-type')) + self.VerseDisplayGroupBox.setTitle( + translate(u'SettingsForm', u'Verse Display')) + self.NewChaptersCheckBox.setText( + translate(u'SettingsForm', u'Only show new chapter numbers')) + self.LayoutStyleLabel.setText( + translate(u'SettingsForm', u'Layout Style:')) + self.DisplayStyleLabel.setText( + translate(u'SettingsForm', u'Display Style:')) + self.BibleThemeLabel.setText( + translate(u'SettingsForm', u'Bible Theme:')) + self.LayoutStyleComboBox.setItemText( + 0, translate(u'SettingsForm', u'verse per slide')) + self.LayoutStyleComboBox.setItemText( + 1, translate(u'SettingsForm', u'verse per line')) + self.LayoutStyleComboBox.setItemText( + 2, translate(u'SettingsForm', u'continuous')) + self.DisplayStyleComboBox.setItemText( + 0, translate(u'SettingsForm', u'No brackets')) + self.DisplayStyleComboBox.setItemText( + 1, translate(u'SettingsForm', u'( and )')) + self.DisplayStyleComboBox.setItemText( + 2, translate(u'SettingsForm', u'{ and }')) + self.DisplayStyleComboBox.setItemText( + 3, translate(u'SettingsForm', u'[ and ]')) + self.ChangeNoteLabel.setText(translate(u'SettingsForm', + u'Note:\nChanges don\'t affect verses already in the service')) + self.BibleSearchGroupBox.setTitle( + translate(u'SettingsForm', u'Search')) + self.BibleSearchCheckBox.setText( + translate(u'SettingsForm', u'Search-as-you-type')) def onBibleThemeComboBoxChanged(self): self.bible_theme = self.BibleThemeComboBox.currentText() @@ -195,20 +215,27 @@ class BiblesTab(SettingsTab): self.bible_search = True def load(self): - self.show_new_chapters = str_to_bool(self.config.get_config(u'display new chapter', u'False')) - self.display_style = int(self.config.get_config(u'display brackets', u'0')) - self.layout_style = int(self.config.get_config(u'verse layout style', u'0')) + self.show_new_chapters = str_to_bool( + self.config.get_config(u'display new chapter', u'False')) + self.display_style = int( + self.config.get_config(u'display brackets', u'0')) + self.layout_style = int( + self.config.get_config(u'verse layout style', u'0')) self.bible_theme = self.config.get_config(u'bible theme', u'0') - self.bible_search = str_to_bool(self.config.get_config(u'search as type', u'True')) + self.bible_search = str_to_bool( + self.config.get_config(u'search as type', u'True')) self.NewChaptersCheckBox.setChecked(self.show_new_chapters) self.DisplayStyleComboBox.setCurrentIndex(self.display_style) self.LayoutStyleComboBox.setCurrentIndex(self.layout_style) self.BibleSearchCheckBox.setChecked(self.bible_search) def save(self): - self.config.set_config(u'display new chapter', unicode(self.show_new_chapters)) - self.config.set_config(u'display brackets', unicode(self.display_style)) - self.config.set_config(u'verse layout style', unicode(self.layout_style)) + self.config.set_config( + u'display new chapter', unicode(self.show_new_chapters)) + self.config.set_config( + u'display brackets', unicode(self.display_style)) + self.config.set_config( + u'verse layout style', unicode(self.layout_style)) self.config.set_config(u'search as type', unicode(self.bible_search)) self.config.set_config(u'bible theme', unicode(self.bible_theme)) @@ -220,7 +247,8 @@ class BiblesTab(SettingsTab): self.BibleThemeComboBox.addItem(u'') for theme in theme_list: self.BibleThemeComboBox.addItem(theme) - id = self.BibleThemeComboBox.findText(unicode(self.bible_theme), QtCore.Qt.MatchExactly) + id = self.BibleThemeComboBox.findText( + unicode(self.bible_theme), QtCore.Qt.MatchExactly) if id == -1: # Not Found id = 0 diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index 684034fba..75fb1d9a3 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -81,7 +81,7 @@ class BibleManager(object): def reload_bibles(self): log.debug(u'Reload bibles') files = self.config.get_files(self.bibleSuffix) - log.debug(u'Bible Files %s', files ) + log.debug(u'Bible Files %s', files ) self.bible_db_cache = {} self.bible_http_cache = {} # books of the bible with testaments @@ -166,7 +166,7 @@ class BibleManager(object): Defaults to *None*. The password to accompany the username. """ log.debug(u'register_HTTP_bible %s, %s, %s, %s, %s, %s', - biblename, biblesource, bibleid, proxyurl, proxyid, proxypass) + biblename, biblesource, bibleid, proxyurl, proxyid, proxypass) if self._is_new_bible(biblename): # Create new Bible nbible = BibleDBImpl(self.biblePath, biblename, self.config) @@ -271,7 +271,7 @@ c log.debug(u'get_bible_books %s', bible) return self.bible_db_cache[bible].get_bible_books() - def get_book_chapter_count(self, bible, book): + def get_book_chapter_count(self, bible, book): """ Returns the number of Chapters for a given book """ @@ -283,7 +283,7 @@ c Returns all the number of verses for a given book and chapterMaxBibleBookVerses """ - log.debug(u'get_book_verse_count %s,%s,%s', bible, book, chapter) + log.debug(u'get_book_verse_count %s,%s,%s', bible, book, chapter) return self.bible_db_cache[bible].get_max_bible_book_verses( book, chapter) @@ -300,7 +300,7 @@ c Saves the bibles meta data """ log.debug(u'save_meta data %s,%s, %s,%s', - bible, version, copyright, permissions) + bible, version, copyright, permissions) self.bible_db_cache[bible].save_meta(u'Version', version) self.bible_db_cache[bible].save_meta(u'Copyright', copyright) self.bible_db_cache[bible].save_meta(u'Permissions', permissions) @@ -309,7 +309,7 @@ c """ Returns the meta data for a given key """ - log.debug(u'get_meta %s,%s', bible, key) + log.debug(u'get_meta %s,%s', bible, key) return self.bible_db_cache[bible].get_meta(key) def get_verse_text(self, bible, bookname, schapter, echapter, sverse, @@ -414,7 +414,7 @@ c """ Check cache to see if new bible """ - for b , o in self.bible_db_cache.iteritems(): + for b , o in self.bible_db_cache.iteritems(): log.debug(u'Bible from cache in is_new_bible %s', b ) if b == name : return False diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index f39f15f64..59b4e2af7 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -28,7 +28,7 @@ import time from PyQt4 import QtCore, QtGui from openlp.core.lib import translate, ServiceItem, MediaManagerItem, \ - Receiver, contextMenuAction, contextMenuSeparator, BaseListWithDnD + Receiver, contextMenuAction, contextMenuSeparator, BaseListWithDnD from openlp.plugins.bibles.forms import BibleImportForm from openlp.plugins.bibles.lib.manager import BibleMode @@ -329,10 +329,10 @@ class BibleMediaItem(MediaManagerItem): log.debug(u'Advanced Search Button pressed') bible = unicode(self.AdvancedVersionComboBox.currentText()) book = unicode(self.AdvancedBookComboBox.currentText()) - chapter_from = int(self.AdvancedFromChapter.currentText()) - chapter_to = int(self.AdvancedToChapter.currentText()) - verse_from = int(self.AdvancedFromVerse.currentText()) - verse_to = int(self.AdvancedToVerse.currentText()) + chapter_from = int(self.AdvancedFromChapter.currentText()) + chapter_to = int(self.AdvancedToChapter.currentText()) + verse_from = int(self.AdvancedFromVerse.currentText()) + verse_to = int(self.AdvancedToVerse.currentText()) self.search_results = self.parent.biblemanager.get_verse_text( bible, book, chapter_from, chapter_to, verse_from, verse_to) if self.ClearAdvancedSearchComboBox.currentIndex() == 0: @@ -374,7 +374,7 @@ class BibleMediaItem(MediaManagerItem): raw_footer = [] bible_text = u'' for item in items: - bitem = self.ListView.item(item.row()) + bitem = self.ListView.item(item.row()) text = unicode((bitem.data(QtCore.Qt.UserRole)).toString()) verse = text[:text.find(u'(')] bible = text[text.find(u'(') + 1:-1] @@ -457,13 +457,13 @@ class BibleMediaItem(MediaManagerItem): self.adjustComboBox(1, self.verses, self.AdvancedToVerse) def adjustComboBox(self, frm, to , combo): - log.debug(u'adjustComboBox %s , %s , %s', combo, frm, to) + log.debug(u'adjustComboBox %s , %s , %s', combo, frm, to) combo.clear() for i in range(int(frm), int(to) + 1): combo.addItem(unicode(i)) def displayResults(self, bible): - for count, verse in enumerate(self.search_results): + for count, verse in enumerate(self.search_results): bible_text = u' %s %d:%d (%s)' % (verse.book.name, verse.chapter, verse.verse, bible) bible_verse = QtGui.QListWidgetItem(bible_text) @@ -474,7 +474,7 @@ class BibleMediaItem(MediaManagerItem): if cr is not None: cr.setSelected(True) - def searchByReference(self, bible, search): + def searchByReference(self, bible, search): log.debug(u'searchByReference %s ,%s', bible, search) book = u'' start_chapter = u'' @@ -529,7 +529,7 @@ class BibleMediaItem(MediaManagerItem): sp1 = sp[1].split(u':') if len(sp1) == 1: end_chapter = start_chapter - end_verse = sp1[0] + end_verse = sp1[0] else: end_chapter = sp1[0] end_verse = sp1[1] diff --git a/openlp/plugins/custom/forms/editcustomform.py b/openlp/plugins/custom/forms/editcustomform.py index d5654db3e..b4c4ffbfe 100644 --- a/openlp/plugins/custom/forms/editcustomform.py +++ b/openlp/plugins/custom/forms/editcustomform.py @@ -115,7 +115,7 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog): self.ThemeComboBox.setCurrentIndex(0) def accept(self): - valid , message = self._validate() + valid , message = self._validate() if not valid: QtGui.QMessageBox.critical(self, translate(u'customEditDialog', u'Error'), message, @@ -126,7 +126,8 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog): sxml.add_lyrics_to_song() count = 1 for i in range (0, self.VerseListView.count()): - sxml.add_verse_to_lyrics(u'custom', unicode(count), unicode(self.VerseListView.item(i).text())) + sxml.add_verse_to_lyrics(u'custom', unicode(count), + unicode(self.VerseListView.item(i).text())) count += 1 self.customSlide.title = unicode(self.TitleEdit.displayText()) self.customSlide.text = unicode(sxml.extract_xml()) @@ -201,9 +202,11 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog): for row in unicode(self.VerseTextEdit.toPlainText()).split(u'---'): self.VerseListView.addItem(row) else: - self.VerseListView.currentItem().setText(self.VerseTextEdit.toPlainText()) + self.VerseListView.currentItem().setText( + self.VerseTextEdit.toPlainText()) #number of lines has change - if len(self.beforeText.split(u'\n')) != len(self.VerseTextEdit.toPlainText().split(u'\n')): + if len(self.beforeText.split(u'\n')) != \ + len(self.VerseTextEdit.toPlainText().split(u'\n')): tempList = {} for row in range(0, self.VerseListView.count()): tempList[row] = self.VerseListView.item(row).text() @@ -227,9 +230,11 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog): message = u'' if len(self.TitleEdit.displayText()) == 0: valid = False - message = translate(u'customEditDialog', u'You need to enter a title \n') + message = translate( + u'customEditDialog', u'You need to enter a title \n') # must have 1 slide if self.VerseListView.count() == 0: valid = False - message += translate(u'customEditDialog', u'You need to enter a slide \n') - return valid, message + message += translate( + u'customEditDialog', u'You need to enter a slide \n') + return valid, message diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index b8429efed..8551c3ae0 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -26,7 +26,7 @@ import logging from PyQt4 import QtCore, QtGui -from openlp.core.lib import MediaManagerItem, SongXMLParser, ServiceItem, \ +from openlp.core.lib import MediaManagerItem, SongXMLParser, ServiceItem, \ translate, contextMenuAction, contextMenuSeparator, BaseListWithDnD class CustomListView(BaseListWithDnD): @@ -65,7 +65,8 @@ class CustomMediaItem(MediaManagerItem): self.ListView.clear() for CustomSlide in list: custom_name = QtGui.QListWidgetItem(CustomSlide.title) - custom_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(CustomSlide.id)) + custom_name.setData( + QtCore.Qt.UserRole, QtCore.QVariant(CustomSlide.id)) self.ListView.addItem(custom_name) def onNewClick(self): diff --git a/openlp/plugins/images/imageplugin.py b/openlp/plugins/images/imageplugin.py index f67efd2c2..707fa8bbb 100644 --- a/openlp/plugins/images/imageplugin.py +++ b/openlp/plugins/images/imageplugin.py @@ -27,7 +27,7 @@ import logging from PyQt4 import QtCore, QtGui from openlp.core.lib import Plugin -from openlp.plugins.images.lib import ImageMediaItem, ImageTab +from openlp.plugins.images.lib import ImageMediaItem, ImageTab class ImagePlugin(Plugin): global log diff --git a/openlp/plugins/images/lib/imagetab.py b/openlp/plugins/images/lib/imagetab.py index c315b219b..807bac4ca 100644 --- a/openlp/plugins/images/lib/imagetab.py +++ b/openlp/plugins/images/lib/imagetab.py @@ -24,7 +24,7 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import SettingsTab, str_to_bool, translate, Receiver +from openlp.core.lib import SettingsTab, str_to_bool, translate, Receiver class ImageTab(SettingsTab): """ @@ -53,7 +53,8 @@ class ImageTab(SettingsTab): self.TimeoutSpacer = QtGui.QSpacerItem(147, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.TimeoutLayout.addItem(self.TimeoutSpacer) - self.ImageLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.ImageModeGroupBox) + self.ImageLayout.setWidget( + 0, QtGui.QFormLayout.LabelRole, self.ImageModeGroupBox) # Signals and slots QtCore.QObject.connect(self.TimeoutSpinBox, QtCore.SIGNAL(u'valueChanged(int)'), self.onTimeoutSpinBoxChanged) @@ -71,7 +72,7 @@ class ImageTab(SettingsTab): def save(self): self.config.set_config(u'loop delay', self.loop_delay) - Receiver().send_message(u'update_spin_delay', self.loop_delay ) + Receiver().send_message(u'update_spin_delay', self.loop_delay ) def postSetUp(self): - Receiver().send_message(u'update_spin_delay', self.loop_delay ) + Receiver().send_message(u'update_spin_delay', self.loop_delay ) diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index ab076b088..79efa7389 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -26,7 +26,8 @@ import logging import os from PyQt4 import QtCore, QtGui -from openlp.core.lib import MediaManagerItem, ServiceItem, translate, BaseListWithDnD, buildIcon +from openlp.core.lib import MediaManagerItem, ServiceItem, translate, \ + BaseListWithDnD, buildIcon # We have to explicitly create separate classes for each plugin # in order for DnD to the Service manager to work correctly. @@ -61,9 +62,11 @@ class ImageMediaItem(MediaManagerItem): MediaManagerItem.__init__(self, parent, icon, title) def initialise(self): - self.ListView.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection) + self.ListView.setSelectionMode( + QtGui.QAbstractItemView.ExtendedSelection) self.ListView.setIconSize(QtCore.QSize(88,50)) - self.servicePath = os.path.join(self.parent.config.get_data_path(), u'.thumbnails') + self.servicePath = os.path.join( + self.parent.config.get_data_path(), u'.thumbnails') if os.path.exists(self.servicePath) == False: os.mkdir(self.servicePath) self.loadList(self.parent.config.load_list(self.ConfigSection)) @@ -103,9 +106,9 @@ class ImageMediaItem(MediaManagerItem): return False service_item.title = u'Image(s)' for item in items: - bitem = self.ListView.item(item.row()) + bitem = self.ListView.item(item.row()) filename = unicode((bitem.data(QtCore.Qt.UserRole)).toString()) frame = QtGui.QImage(unicode(filename)) (path, name) = os.path.split(filename) - service_item.add_from_image(path, name, frame) + service_item.add_from_image(path, name, frame) return True diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index 61a75b26c..05fce76f4 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -81,7 +81,7 @@ class MediaMediaItem(MediaManagerItem): filename = self.ListData.getFilename(index) frame = QtGui.QImage(unicode(filename)) (path, name) = os.path.split(filename) - service_item.add_from_image(path, name, frame) + service_item.add_from_image(path, name, frame) return True def onPreviewClick(self): diff --git a/openlp/plugins/media/lib/mediatab.py b/openlp/plugins/media/lib/mediatab.py index 9c17a38bc..b24bac094 100644 --- a/openlp/plugins/media/lib/mediatab.py +++ b/openlp/plugins/media/lib/mediatab.py @@ -24,7 +24,7 @@ from PyQt4 import QtCore, QtGui -from openlp.core.lib import SettingsTab, str_to_bool, translate +from openlp.core.lib import SettingsTab, str_to_bool, translate class MediaTab(SettingsTab): """ @@ -50,14 +50,16 @@ class MediaTab(SettingsTab): self.UseVMRLabel.setObjectName(u'UseVMRLabel') self.MediaModeLayout.addWidget(self.UseVMRLabel) - self.MediaLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.MediaModeGroupBox) + self.MediaLayout.setWidget( + 0, QtGui.QFormLayout.LabelRole, self.MediaModeGroupBox) # Signals and slots QtCore.QObject.connect(self.UseVMRCheckBox, QtCore.SIGNAL(u'stateChanged(int)'), self.onVMRCheckBoxChanged) def retranslateUi(self): self.MediaModeGroupBox.setTitle(translate(u'MediaTab', u'Media Mode')) - self.UseVMRCheckBox.setText(translate(u'MediaTab', u'Use Video Mode Rendering')) + self.UseVMRCheckBox.setText( + translate(u'MediaTab', u'Use Video Mode Rendering')) self.UseVMRLabel.setText(translate(u'MediaTab', u'\n' u'