From d33a7191724aefda87ea526f0c0a0338e9c84f16 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Thu, 27 May 2010 21:56:34 +0100 Subject: [PATCH] Imports for declared exceptions --- openlp/core/lib/mediamanageritem.py | 3 ++- openlp/core/lib/songxmlhandler.py | 2 ++ openlp/core/lib/xmlrootclass.py | 10 ++++--- openlp/migration/migratebibles.py | 1 + openlp/migration/migratesongs.py | 2 +- openlp/plugins/alerts/lib/manager.py | 1 + openlp/plugins/songs/forms/authorsdialog.py | 4 ++- openlp/plugins/songs/forms/authorsform.py | 29 ++++++++++----------- 8 files changed, 30 insertions(+), 22 deletions(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 95e67bee1..12f4136f6 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -23,13 +23,14 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### +import logging import types import os from PyQt4 import QtCore, QtGui from openlp.core.lib import contextMenuAction, contextMenuSeparator, \ - SettingsManager, OpenLPToolbar, ServiceItem + SettingsManager, OpenLPToolbar, ServiceItem, build_icon log = logging.getLogger(__name__) diff --git a/openlp/core/lib/songxmlhandler.py b/openlp/core/lib/songxmlhandler.py index 547e83bdb..acb75609b 100644 --- a/openlp/core/lib/songxmlhandler.py +++ b/openlp/core/lib/songxmlhandler.py @@ -24,8 +24,10 @@ ############################################################################### import logging + from xml.dom.minidom import Document from xml.etree.ElementTree import ElementTree, XML, dump +from xml.parsers.expat import ExpatError log = logging.getLogger(__name__) diff --git a/openlp/core/lib/xmlrootclass.py b/openlp/core/lib/xmlrootclass.py index 017d365c2..9b58a6f03 100644 --- a/openlp/core/lib/xmlrootclass.py +++ b/openlp/core/lib/xmlrootclass.py @@ -52,8 +52,8 @@ class XmlRootClass(object): The root tag of the xml. """ root = ElementTree(element=XML(xml)) - iter = root.getiterator() - for element in iter: + xml_iter = root.getiterator() + for element in xml_iter: if element.tag != root_tag: text = element.text if type(text) is NoneType: @@ -76,7 +76,8 @@ class XmlRootClass(object): # Ok, it seems to be a string. val = text if hasattr(self, u'post_tag_hook'): - (element.tag, val) = self.post_tag_hook(element.tag, val) + (element.tag, val) = \ + self.post_tag_hook(element.tag, val) setattr(self, element.tag, val) def __str__(self): @@ -90,7 +91,8 @@ class XmlRootClass(object): attributes = [] for attrib in dir(self): if not attrib.startswith(u'_'): - attributes.append(u'%30s : %s' % (attrib, getattr(self, attrib))) + attributes.append( + u'%30s : %s' % (attrib, getattr(self, attrib))) return u'\n'.join(attributes) def _get_as_string(self): diff --git a/openlp/migration/migratebibles.py b/openlp/migration/migratebibles.py index 2c0ebb73a..0bdb44f47 100644 --- a/openlp/migration/migratebibles.py +++ b/openlp/migration/migratebibles.py @@ -28,6 +28,7 @@ import sys import sqlite3 from sqlalchemy import create_engine +from sqlalchemy.exceptions import InvalidRequestError from sqlalchemy.orm import scoped_session, sessionmaker, mapper from openlp.core.lib import SettingsManager diff --git a/openlp/migration/migratesongs.py b/openlp/migration/migratesongs.py index dfe507eff..8e0a1ae2e 100644 --- a/openlp/migration/migratesongs.py +++ b/openlp/migration/migratesongs.py @@ -27,8 +27,8 @@ import os import sys import sqlite3 -from sqlalchemy import * from sqlalchemy import create_engine +from sqlalchemy.exceptions import InvalidRequestError from sqlalchemy.orm import scoped_session, sessionmaker, mapper, relation from openlp.core.lib import SettingsManager diff --git a/openlp/plugins/alerts/lib/manager.py b/openlp/plugins/alerts/lib/manager.py index dded8c8ef..088f0cbae 100644 --- a/openlp/plugins/alerts/lib/manager.py +++ b/openlp/plugins/alerts/lib/manager.py @@ -26,6 +26,7 @@ import logging from PyQt4 import QtCore +from sqlalchemy.exceptions import InvalidRequestError from openlp.core.utils import AppLocation from openlp.plugins.alerts.lib.models import init_models, metadata, AlertItem diff --git a/openlp/plugins/songs/forms/authorsdialog.py b/openlp/plugins/songs/forms/authorsdialog.py index dbd7af077..9834e3606 100644 --- a/openlp/plugins/songs/forms/authorsdialog.py +++ b/openlp/plugins/songs/forms/authorsdialog.py @@ -74,7 +74,9 @@ class Ui_AuthorsDialog(object): QtCore.QMetaObject.connectSlotsByName(AuthorsDialog) def retranslateUi(self, AuthorsDialog): - AuthorsDialog.setWindowTitle(translate('AuthorsForm', 'Author Maintenance')) + AuthorsDialog.setWindowTitle( + translate('AuthorsForm', 'Author Maintenance')) self.DisplayLabel.setText(translate('AuthorsForm', 'Display name:')) self.FirstNameLabel.setText(translate('AuthorsForm', 'First name:')) self.LastNameLabel.setText(translate('AuthorsForm', 'Last name:')) + diff --git a/openlp/plugins/songs/forms/authorsform.py b/openlp/plugins/songs/forms/authorsform.py index d1cb24761..873d6ba28 100644 --- a/openlp/plugins/songs/forms/authorsform.py +++ b/openlp/plugins/songs/forms/authorsform.py @@ -37,11 +37,13 @@ class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog): """ QtGui.QDialog.__init__(self, parent) self.setupUi(self) - self.autoDisplayName = False + self._autoDisplayName = False QtCore.QObject.connect(self.FirstNameEdit, - QtCore.SIGNAL(u'textEdited(QString)'), self.onFirstNameEditTextEdited) + QtCore.SIGNAL(u'textEdited(QString)'), + self.onFirstNameEditTextEdited) QtCore.QObject.connect(self.LastNameEdit, - QtCore.SIGNAL(u'textEdited(QString)'), self.onLastNameEditTextEdited) + QtCore.SIGNAL(u'textEdited(QString)'), + self.onLastNameEditTextEdited) def exec_(self, clear=True): if clear: @@ -52,7 +54,7 @@ class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog): return QtGui.QDialog.exec_(self) def onFirstNameEditTextEdited(self, text): - if not self.autoDisplayName: + if not self._autoDisplayName: return display_name = text if self.LastNameEdit.text() != u'': @@ -60,7 +62,7 @@ class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog): self.DisplayEdit.setText(display_name) def onLastNameEditTextEdited(self, text): - if not self.autoDisplayName: + if not self._autoDisplayName: return display_name = text if self.FirstNameEdit.text() != u'': @@ -68,24 +70,20 @@ class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog): self.DisplayEdit.setText(display_name) def autoDisplayName(self): - return self.autoDisplayName + return self._autoDisplayName def setAutoDisplayName(self, on): - self.autoDisplayName = on + self._autoDisplayName = on def accept(self): if not self.FirstNameEdit.text(): - QtGui.QMessageBox.critical( - self, self.trUtf8('Error'), - self.trUtf8('You need to type in the first name of the author.'), - QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok)) + QtGui.QMessageBox.critical(self, self.trUtf8('Error'), self.trUtf8( + 'You need to type in the first name of the author.')) self.FirstNameEdit.setFocus() return False elif not self.LastNameEdit.text(): - QtGui.QMessageBox.critical( - self, self.trUtf8('Error'), - self.trUtf8('You need to type in the last name of the author.'), - QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok)) + QtGui.QMessageBox.critical(self, self.trUtf8('Error'), + self.trUtf8('You need to type in the last name of the author.')) self.LastNameEdit.setFocus() return False elif not self.DisplayEdit.text(): @@ -105,3 +103,4 @@ class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog): return False else: return QtGui.QDialog.accept(self) +