Imports for declared exceptions

This commit is contained in:
Jon Tibble 2010-05-27 21:56:34 +01:00
parent 4616bbcb36
commit d33a719172
8 changed files with 30 additions and 22 deletions

View File

@ -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__)

View File

@ -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__)

View File

@ -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):

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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:'))

View File

@ -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)