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 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA #
############################################################################### ###############################################################################
import logging
import types import types
import os import os
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.lib import contextMenuAction, contextMenuSeparator, \ from openlp.core.lib import contextMenuAction, contextMenuSeparator, \
SettingsManager, OpenLPToolbar, ServiceItem SettingsManager, OpenLPToolbar, ServiceItem, build_icon
log = logging.getLogger(__name__) log = logging.getLogger(__name__)

View File

@ -24,8 +24,10 @@
############################################################################### ###############################################################################
import logging import logging
from xml.dom.minidom import Document from xml.dom.minidom import Document
from xml.etree.ElementTree import ElementTree, XML, dump from xml.etree.ElementTree import ElementTree, XML, dump
from xml.parsers.expat import ExpatError
log = logging.getLogger(__name__) log = logging.getLogger(__name__)

View File

@ -52,8 +52,8 @@ class XmlRootClass(object):
The root tag of the xml. The root tag of the xml.
""" """
root = ElementTree(element=XML(xml)) root = ElementTree(element=XML(xml))
iter = root.getiterator() xml_iter = root.getiterator()
for element in iter: for element in xml_iter:
if element.tag != root_tag: if element.tag != root_tag:
text = element.text text = element.text
if type(text) is NoneType: if type(text) is NoneType:
@ -76,7 +76,8 @@ class XmlRootClass(object):
# Ok, it seems to be a string. # Ok, it seems to be a string.
val = text val = text
if hasattr(self, u'post_tag_hook'): 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) setattr(self, element.tag, val)
def __str__(self): def __str__(self):
@ -90,7 +91,8 @@ class XmlRootClass(object):
attributes = [] attributes = []
for attrib in dir(self): for attrib in dir(self):
if not attrib.startswith(u'_'): 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) return u'\n'.join(attributes)
def _get_as_string(self): def _get_as_string(self):

View File

@ -28,6 +28,7 @@ import sys
import sqlite3 import sqlite3
from sqlalchemy import create_engine from sqlalchemy import create_engine
from sqlalchemy.exceptions import InvalidRequestError
from sqlalchemy.orm import scoped_session, sessionmaker, mapper from sqlalchemy.orm import scoped_session, sessionmaker, mapper
from openlp.core.lib import SettingsManager from openlp.core.lib import SettingsManager

View File

@ -27,8 +27,8 @@ import os
import sys import sys
import sqlite3 import sqlite3
from sqlalchemy import *
from sqlalchemy import create_engine from sqlalchemy import create_engine
from sqlalchemy.exceptions import InvalidRequestError
from sqlalchemy.orm import scoped_session, sessionmaker, mapper, relation from sqlalchemy.orm import scoped_session, sessionmaker, mapper, relation
from openlp.core.lib import SettingsManager from openlp.core.lib import SettingsManager

View File

@ -26,6 +26,7 @@
import logging import logging
from PyQt4 import QtCore from PyQt4 import QtCore
from sqlalchemy.exceptions import InvalidRequestError
from openlp.core.utils import AppLocation from openlp.core.utils import AppLocation
from openlp.plugins.alerts.lib.models import init_models, metadata, AlertItem 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) QtCore.QMetaObject.connectSlotsByName(AuthorsDialog)
def retranslateUi(self, 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.DisplayLabel.setText(translate('AuthorsForm', 'Display name:'))
self.FirstNameLabel.setText(translate('AuthorsForm', 'First name:')) self.FirstNameLabel.setText(translate('AuthorsForm', 'First name:'))
self.LastNameLabel.setText(translate('AuthorsForm', 'Last 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) QtGui.QDialog.__init__(self, parent)
self.setupUi(self) self.setupUi(self)
self.autoDisplayName = False self._autoDisplayName = False
QtCore.QObject.connect(self.FirstNameEdit, 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.QObject.connect(self.LastNameEdit,
QtCore.SIGNAL(u'textEdited(QString)'), self.onLastNameEditTextEdited) QtCore.SIGNAL(u'textEdited(QString)'),
self.onLastNameEditTextEdited)
def exec_(self, clear=True): def exec_(self, clear=True):
if clear: if clear:
@ -52,7 +54,7 @@ class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog):
return QtGui.QDialog.exec_(self) return QtGui.QDialog.exec_(self)
def onFirstNameEditTextEdited(self, text): def onFirstNameEditTextEdited(self, text):
if not self.autoDisplayName: if not self._autoDisplayName:
return return
display_name = text display_name = text
if self.LastNameEdit.text() != u'': if self.LastNameEdit.text() != u'':
@ -60,7 +62,7 @@ class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog):
self.DisplayEdit.setText(display_name) self.DisplayEdit.setText(display_name)
def onLastNameEditTextEdited(self, text): def onLastNameEditTextEdited(self, text):
if not self.autoDisplayName: if not self._autoDisplayName:
return return
display_name = text display_name = text
if self.FirstNameEdit.text() != u'': if self.FirstNameEdit.text() != u'':
@ -68,24 +70,20 @@ class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog):
self.DisplayEdit.setText(display_name) self.DisplayEdit.setText(display_name)
def autoDisplayName(self): def autoDisplayName(self):
return self.autoDisplayName return self._autoDisplayName
def setAutoDisplayName(self, on): def setAutoDisplayName(self, on):
self.autoDisplayName = on self._autoDisplayName = on
def accept(self): def accept(self):
if not self.FirstNameEdit.text(): if not self.FirstNameEdit.text():
QtGui.QMessageBox.critical( QtGui.QMessageBox.critical(self, self.trUtf8('Error'), self.trUtf8(
self, self.trUtf8('Error'), 'You need to type in the first name of the author.'))
self.trUtf8('You need to type in the first name of the author.'),
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok))
self.FirstNameEdit.setFocus() self.FirstNameEdit.setFocus()
return False return False
elif not self.LastNameEdit.text(): elif not self.LastNameEdit.text():
QtGui.QMessageBox.critical( QtGui.QMessageBox.critical(self, self.trUtf8('Error'),
self, self.trUtf8('Error'), self.trUtf8('You need to type in the last name of the author.'))
self.trUtf8('You need to type in the last name of the author.'),
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok))
self.LastNameEdit.setFocus() self.LastNameEdit.setFocus()
return False return False
elif not self.DisplayEdit.text(): elif not self.DisplayEdit.text():
@ -105,3 +103,4 @@ class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog):
return False return False
else: else:
return QtGui.QDialog.accept(self) return QtGui.QDialog.accept(self)