Sun, 06 Oct 2013 19:45:29 +0200
Continued to shorten the code lines to max. 79 characters.
--- a/E5Graphics/E5ArrowItem.py Sun Oct 06 19:14:26 2013 +0200 +++ b/E5Graphics/E5ArrowItem.py Sun Oct 06 19:45:29 2013 +0200 @@ -10,12 +10,14 @@ import math from PyQt4.QtCore import QPointF, QRectF, QSizeF, QLineF, Qt -from PyQt4.QtGui import QAbstractGraphicsShapeItem, QGraphicsItem, QStyle, QPen, QPolygonF +from PyQt4.QtGui import QAbstractGraphicsShapeItem, QGraphicsItem, QStyle, \ + QPen, QPolygonF NormalArrow = 1 WideArrow = 2 -ArrowheadAngleFactor = 0.26179938779914941 # 0.5 * math.atan(math.sqrt(3.0) / 3.0) +ArrowheadAngleFactor = 0.26179938779914941 +# 0.5 * math.atan(math.sqrt(3.0) / 3.0) class E5ArrowItem(QAbstractGraphicsShapeItem): @@ -101,14 +103,16 @@ @param option style options (QStyleOptionGraphicsItem) @param widget optional reference to the widget painted on (QWidget) """ - if (option.state & QStyle.State_Selected) == QStyle.State(QStyle.State_Selected): + if (option.state & QStyle.State_Selected) == \ + QStyle.State(QStyle.State_Selected): width = 2 else: width = 1 # draw the line first line = QLineF(self._origin, self._end) - painter.setPen(QPen(Qt.black, width, Qt.SolidLine, Qt.FlatCap, Qt.MiterJoin)) + painter.setPen( + QPen(Qt.black, width, Qt.SolidLine, Qt.FlatCap, Qt.MiterJoin)) painter.drawLine(line) # draw the arrow head
--- a/E5Graphics/E5GraphicsView.py Sun Oct 06 19:14:26 2013 +0200 +++ b/E5Graphics/E5GraphicsView.py Sun Oct 06 19:45:29 2013 +0200 @@ -51,7 +51,8 @@ self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) self.setViewportUpdateMode(QGraphicsView.SmartViewportUpdate) - self.setWhatsThis(self.trUtf8("<b>Graphics View</b>\n" + self.setWhatsThis(self.trUtf8( + "<b>Graphics View</b>\n" "<p>This graphics view is used to show a diagram. \n" "There are various actions available to manipulate the \n" "shown items.</p>\n" @@ -59,7 +60,8 @@ "<li>Clicking on an item selects it.</li>\n" "<li>Ctrl-clicking adds an item to the selection.</li>\n" "<li>Ctrl-clicking a selected item deselects it.</li>\n" - "<li>Clicking on an empty spot of the canvas resets the selection.</li>\n" + "<li>Clicking on an empty spot of the canvas resets the selection." + "</li>\n" "<li>Dragging the mouse over the canvas spans a rubberband to \n" "select multiple items.</li>\n" "<li>Dragging the mouse over a selected item moves the \n" @@ -102,7 +104,8 @@ """ Public method to handle the reset the zoom value. """ - self.setZoom(E5GraphicsView.ZoomLevels[E5GraphicsView.ZoomLevelDefault]) + self.setZoom( + E5GraphicsView.ZoomLevels[E5GraphicsView.ZoomLevelDefault]) def setZoom(self, value): """ @@ -176,7 +179,8 @@ def _getDiagramRect(self, border=0): """ - Protected method to calculate the minimum rectangle fitting the diagram. + Protected method to calculate the minimum rectangle fitting the + diagram. @param border border width to include in the calculation (integer) @return the minimum rectangle (QRectF) @@ -291,7 +295,8 @@ """ Public method to print the diagram. - @param printer reference to a ready configured printer object (QPrinter) + @param printer reference to a ready configured printer object + (QPrinter) @param diagramName name of the diagram (string) """ painter = QPainter() @@ -306,17 +311,19 @@ fontHeight = fm.lineSpacing() marginX = printer.pageRect().x() - printer.paperRect().x() marginX = \ - Preferences.getPrinter("LeftMargin") * int(printer.resolution() / 2.54) \ - - marginX + Preferences.getPrinter("LeftMargin") * int( + printer.resolution() / 2.54) - marginX marginY = printer.pageRect().y() - printer.paperRect().y() marginY = \ - Preferences.getPrinter("TopMargin") * int(printer.resolution() / 2.54) \ - - marginY + Preferences.getPrinter("TopMargin") * int( + printer.resolution() / 2.54) - marginY width = printer.width() - marginX \ - - Preferences.getPrinter("RightMargin") * int(printer.resolution() / 2.54) + - Preferences.getPrinter("RightMargin") * int( + printer.resolution() / 2.54) height = printer.height() - fontHeight - 4 - marginY \ - - Preferences.getPrinter("BottomMargin") * int(printer.resolution() / 2.54) + - Preferences.getPrinter("BottomMargin") * int( + printer.resolution() / 2.54) border = self.border == 0 and 5 or self.border rect = self._getDiagramRect(border) @@ -374,10 +381,10 @@ painter.end() - ############################################################################ + ########################################################################### ## The methods below should be overridden by subclasses to get special ## behavior. - ############################################################################ + ########################################################################### def filteredItems(self, items): """
--- a/E5Gui/E5Action.py Sun Oct 06 19:14:26 2013 +0200 +++ b/E5Gui/E5Action.py Sun Oct 06 19:45:29 2013 +0200 @@ -15,8 +15,8 @@ class ArgumentsError(RuntimeError): """ - Class implementing an exception, which is raised, if the wrong number of arguments - are given. + Class implementing an exception, which is raised, if the wrong number of + arguments are given. """ def __init__(self, error): """ @@ -54,17 +54,19 @@ @param args argument list of the constructor. This list is one of <ul> <li>text (string), icon (QIcon), menu text (string), - accelarator (QKeySequence), alternative accelerator (QKeySequence), - parent (QObject), name (string), toggle (boolean)</li> + accelarator (QKeySequence), alternative accelerator + (QKeySequence), parent (QObject), name (string), toggle + (boolean)</li> <li>text (string), icon (QIcon), menu text (string), - accelarator (QKeySequence), alternative accelerator (QKeySequence), - parent (QObject), name (string)</li> + accelarator (QKeySequence), alternative accelerator + (QKeySequence), parent (QObject), name (string)</li> <li>text (string), menu text (string), - accelarator (QKeySequence), alternative accelerator (QKeySequence), - parent (QObject), name (string), toggle (boolean)</li> + accelarator (QKeySequence), alternative accelerator + (QKeySequence), parent (QObject), name (string), toggle + (boolean)</li> <li>text (string), menu text (string), - accelarator (QKeySequence), alternative accelerator (QKeySequence), - parent (QObject), name (string)</li> + accelarator (QKeySequence), alternative accelerator + (QKeySequence), parent (QObject), name (string)</li> </ul> @exception ArgumentsError raised to indicate invalid arguments """
--- a/E5Gui/E5Application.py Sun Oct 06 19:14:26 2013 +0200 +++ b/E5Gui/E5Application.py Sun Oct 06 19:45:29 2013 +0200 @@ -62,7 +62,8 @@ @exception KeyError raised when the given name is already in use """ if name in self.__pluginObjectRegistry: - raise KeyError('Pluginobject "{0}" already registered.'.format(name)) + raise KeyError( + 'Pluginobject "{0}" already registered.'.format(name)) else: self.__pluginObjectRegistry[name] = (object, pluginType) @@ -86,7 +87,8 @@ if name in self.__pluginObjectRegistry: return self.__pluginObjectRegistry[name][0] else: - raise KeyError('Pluginobject "{0}" is not registered.'.format(name)) + raise KeyError( + 'Pluginobject "{0}" is not registered.'.format(name)) def getPluginObjects(self): """ @@ -111,6 +113,7 @@ if name in self.__pluginObjectRegistry: return self.__pluginObjectRegistry[name][1] else: - raise KeyError('Pluginobject "{0}" is not registered.'.format(name)) + raise KeyError( + 'Pluginobject "{0}" is not registered.'.format(name)) e5App = QCoreApplication.instance
--- a/E5Gui/E5ClickableLabel.py Sun Oct 06 19:14:26 2013 +0200 +++ b/E5Gui/E5ClickableLabel.py Sun Oct 06 19:45:29 2013 +0200 @@ -42,7 +42,8 @@ self.middleClicked.emit(evt.globalPos()) else: self.clicked.emit(evt.globalPos()) - elif evt.button() == Qt.MiddleButton and self.rect().contains(evt.pos()): + elif evt.button() == Qt.MiddleButton and \ + self.rect().contains(evt.pos()): self.middleClicked.emit(evt.globalPos()) else: super().mouseReleaseEvent(evt)
--- a/E5Gui/E5Completers.py Sun Oct 06 19:14:26 2013 +0200 +++ b/E5Gui/E5Completers.py Sun Oct 06 19:45:29 2013 +0200 @@ -26,7 +26,8 @@ @param parent parent widget of the completer (QWidget) @keyparam completionMode completion mode of the completer (QCompleter.CompletionMode) - @keyparam showHidden flag indicating to show hidden entries as well (boolean) + @keyparam showHidden flag indicating to show hidden entries as well + (boolean) """ super().__init__(parent) self.__model = QFileSystemModel(self) @@ -35,8 +36,8 @@ QDir.Filters(QDir.Dirs | QDir.Files | QDir.Drives | \ QDir.AllDirs | QDir.Hidden)) else: - self.__model.setFilter( - QDir.Filters(QDir.Dirs | QDir.Files | QDir.Drives | QDir.AllDirs)) + self.__model.setFilter(QDir.Filters( + QDir.Dirs | QDir.Files | QDir.Drives | QDir.AllDirs)) self.setModel(self.__model) self.setCompletionMode(completionMode) if isWindowsPlatform(): @@ -58,7 +59,8 @@ @param parent parent widget of the completer (QWidget) @keyparam completionMode completion mode of the completer (QCompleter.CompletionMode) - @keyparam showHidden flag indicating to show hidden entries as well (boolean) + @keyparam showHidden flag indicating to show hidden entries as well + (boolean) """ super().__init__(parent) self.__model = QFileSystemModel(self) @@ -86,7 +88,8 @@ Constructor @param parent parent widget of the completer (QWidget) - @param strings list of string to load into the completer (list of strings) + @param strings list of string to load into the completer + (list of strings) @keyparam completionMode completion mode of the completer (QCompleter.CompletionMode) """
--- a/E5Gui/E5ErrorMessage.py Sun Oct 06 19:14:26 2013 +0200 +++ b/E5Gui/E5ErrorMessage.py Sun Oct 06 19:45:29 2013 +0200 @@ -49,9 +49,11 @@ Private method to filter messages. @param message message to be checked (string) - @return flag indicating that the message should be filtered out (boolean) + @return flag indicating that the message should be filtered out + (boolean) """ - for filter in self.settings.value("MessageFilters", self.__defaultFilters): + for filter in self.settings.value( + "MessageFilters", self.__defaultFilters): if filter in message: return True @@ -126,13 +128,17 @@ return if msgType == QtDebugMsg: - messageType = QCoreApplication.translate("E5ErrorMessage", "Debug Message") + messageType = QCoreApplication.translate( + "E5ErrorMessage", "Debug Message") elif msgType == QtWarningMsg: - messageType = QCoreApplication.translate("E5ErrorMessage", "Warning") + messageType = QCoreApplication.translate( + "E5ErrorMessage", "Warning") elif msgType == QtCriticalMsg: - messageType = QCoreApplication.translate("E5ErrorMessage", "Critical") + messageType = QCoreApplication.translate( + "E5ErrorMessage", "Critical") elif msgType == QtFatalMsg: - messageType = QCoreApplication.translate("E5ErrorMessage", "Fatal Error") + messageType = QCoreApplication.translate( + "E5ErrorMessage", "Fatal Error") if isinstance(message, bytes): message = message.decode() print("{0}: {1}".format(messageType, message))
--- a/E5Gui/E5ErrorMessageFilterDialog.py Sun Oct 06 19:14:26 2013 +0200 +++ b/E5Gui/E5ErrorMessageFilterDialog.py Sun Oct 06 19:45:29 2013 +0200 @@ -22,7 +22,8 @@ """ Constructor - @param messageFilters list of message filters to be edited (list of strings) + @param messageFilters list of message filters to be edited + (list of strings) @param parent reference to the parent widget (QWidget) """ super().__init__(parent) @@ -35,7 +36,8 @@ self.__proxyModel.setSourceModel(self.__model) self.filterList.setModel(self.__proxyModel) - self.searchEdit.textChanged.connect(self.__proxyModel.setFilterFixedString) + self.searchEdit.textChanged.connect( + self.__proxyModel.setFilterFixedString) self.removeButton.clicked[()].connect(self.filterList.removeSelected) self.removeAllButton.clicked[()].connect(self.filterList.removeAll)
--- a/E5Gui/E5Led.py Sun Oct 06 19:14:26 2013 +0200 +++ b/E5Gui/E5Led.py Sun Oct 06 19:45:29 2013 +0200 @@ -10,7 +10,8 @@ """ from PyQt4.QtCore import Qt, QSize -from PyQt4.QtGui import QWidget, QColor, QRadialGradient, QPalette, QPainter, QBrush +from PyQt4.QtGui import QWidget, QColor, QRadialGradient, QPalette, QPainter, \ + QBrush E5LedRectangular = 0 E5LedCircular = 1 @@ -20,7 +21,8 @@ """ Class implementing a LED widget. """ - def __init__(self, parent=None, color=None, shape=E5LedCircular, rectRatio=1): + def __init__(self, parent=None, color=None, shape=E5LedCircular, + rectRatio=1): """ Constructor
--- a/E5Gui/E5LineEdit.py Sun Oct 06 19:14:26 2013 +0200 +++ b/E5Gui/E5LineEdit.py Sun Oct 06 19:45:29 2013 +0200 @@ -8,8 +8,9 @@ """ from PyQt4.QtCore import pyqtSignal, Qt, QEvent, qVersion -from PyQt4.QtGui import QLineEdit, QStyle, QPainter, QPalette, QStyleOptionFrameV2, \ - QWidget, QHBoxLayout, QBoxLayout, QLayout, QApplication, QSpacerItem, QSizePolicy +from PyQt4.QtGui import QLineEdit, QStyle, QPainter, QPalette, \ + QStyleOptionFrameV2, QWidget, QHBoxLayout, QBoxLayout, QLayout, \ + QApplication, QSpacerItem, QSizePolicy import UI.PixmapCache @@ -87,7 +88,8 @@ else: self.__rightLayout.setDirection(QBoxLayout.LeftToRight) - horizontalSpacer = QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Minimum) + horizontalSpacer = QSpacerItem( + 0, 0, QSizePolicy.Expanding, QSizePolicy.Minimum) self.__mainLayout.addWidget( self.__leftWidget, 0, Qt.AlignVCenter | Qt.AlignLeft) self.__mainLayout.addItem(horizontalSpacer) @@ -150,8 +152,8 @@ not self.hasFocus(): panel = QStyleOptionFrameV2() self.initStyleOption(panel) - textRect = \ - self.style().subElementRect(QStyle.SE_LineEditContents, panel, self) + textRect = self.style().subElementRect( + QStyle.SE_LineEditContents, panel, self) textRect.adjust(2, 0, 0, 0) left = self.textMargin(self.LeftSide) right = self.textMargin(self.RightSide) @@ -160,7 +162,8 @@ painter.setPen(self.palette().brush( QPalette.Disabled, QPalette.Text).color()) painter.drawText( - textRect, Qt.AlignLeft | Qt.AlignVCenter, self.__inactiveText) + textRect, Qt.AlignLeft | Qt.AlignVCenter, + self.__inactiveText) def _updateTextMargins(self): """ @@ -180,7 +183,8 @@ Public method to add a widget to a side. @param widget reference to the widget to add (QWidget) - @param position position to add to (E5LineEdit.LeftSide, E5LineEdit.RightSide) + @param position position to add to (E5LineEdit.LeftSide, + E5LineEdit.RightSide) """ if widget is None: return @@ -230,7 +234,8 @@ """ Public method to get the text margin for a side. - @param position side to get margin for (E5LineEdit.LeftSide, E5LineEdit.RightSide) + @param position side to get margin for (E5LineEdit.LeftSide, + E5LineEdit.RightSide) @return text margin (integer) """ spacing = self.__rightLayout.spacing() @@ -269,17 +274,18 @@ class E5ClearableLineEdit(E5LineEdit): """ - Class implementing a line edit widget showing some inactive text and a clear button, - if it has some contents. + Class implementing a line edit widget showing some inactive text and a + clear button, if it has some contents. """ - def __init__(self, parent=None, inactiveText="", side=E5LineEdit.RightSide): + def __init__(self, parent=None, inactiveText="", + side=E5LineEdit.RightSide): """ Constructor @param parent reference to the parent widget (QWidget) @keyparam inactiveText text to be shown on inactivity (string) - @keyparam side side the clear button should be shown at (E5LineEdit.RightSide, - E5LineEdit.LeftSide) + @keyparam side side the clear button should be shown at + (E5LineEdit.RightSide, E5LineEdit.LeftSide) """ assert side in [E5LineEdit.RightSide, E5LineEdit.LeftSide]
--- a/E5Gui/E5MainWindow.py Sun Oct 06 19:14:26 2013 +0200 +++ b/E5Gui/E5MainWindow.py Sun Oct 06 19:45:29 2013 +0200 @@ -53,8 +53,9 @@ except (IOError, OSError) as msg: E5MessageBox.warning(self, self.trUtf8("Loading Style Sheet"), - self.trUtf8("""<p>The Qt Style Sheet file <b>{0}</b> could""" - """ not be read.<br>Reason: {1}</p>""") + self.trUtf8( + """<p>The Qt Style Sheet file <b>{0}</b> could""" + """ not be read.<br>Reason: {1}</p>""") .format(styleSheetFile, str(msg))) return else:
--- a/E5Gui/E5MessageBox.py Sun Oct 06 19:14:26 2013 +0200 +++ b/E5Gui/E5MessageBox.py Sun Oct 06 19:45:29 2013 +0200 @@ -10,9 +10,9 @@ from PyQt4.QtCore import Qt from PyQt4.QtGui import QMessageBox, QApplication -################################################################################ -## Mappings to standard QMessageBox ## -################################################################################ +############################################################################### +## Mappings to standard QMessageBox ## +############################################################################### # QMessageBox.Icon NoIcon = QMessageBox.NoIcon @@ -56,9 +56,9 @@ ResetRole = QMessageBox.ResetRole YesRole = QMessageBox.YesRole -################################################################################ -## Replacement for the QMessageBox class ## -################################################################################ +############################################################################### +## Replacement for the QMessageBox class ## +############################################################################### class E5MessageBox(QMessageBox): @@ -96,9 +96,9 @@ self.setText(text) self.setStandardButtons(buttons) -################################################################################ -## Replacements for QMessageBox static methods ## -################################################################################ +############################################################################### +## Replacements for QMessageBox static methods ## +############################################################################### def __messageBox(parent, title, text, icon, @@ -215,21 +215,23 @@ return __messageBox(parent, title, text, QMessageBox.Warning, buttons, defaultButton) -################################################################################ -## Additional convenience functions ## -################################################################################ +############################################################################### +## Additional convenience functions ## +############################################################################### -def yesNo(parent, title, text, icon=Question, yesDefault=False, textFormat=Qt.AutoText): +def yesNo(parent, title, text, icon=Question, yesDefault=False, + textFormat=Qt.AutoText): """ Function to show a model yes/no message box. @param parent parent widget of the message box (QWidget) @param title caption of the message box (string) @param text text to be shown by the message box (string) - @keyparam icon icon for the dialog (Critical, Information, Question or Warning) - @keyparam yesDefault flag indicating that the Yes button should be the default - button (boolean) + @keyparam icon icon for the dialog (Critical, Information, Question or + Warning) + @keyparam yesDefault flag indicating that the Yes button should be the + default button (boolean) @param textFormat format of the text (Qt.TextFormat) @return flag indicating the selection of the Yes button (boolean) """ @@ -249,7 +251,8 @@ @param parent parent widget of the message box (QWidget) @param title caption of the message box (string) @param text text to be shown by the message box (string) - @keyparam icon icon for the dialog (Critical, Information, Question or Warning) + @keyparam icon icon for the dialog (Critical, Information, Question or + Warning) @param textFormat format of the text (Qt.TextFormat) @return flag indicating the selection of the Retry button (boolean) """
--- a/E5Gui/E5ModelMenu.py Sun Oct 06 19:14:26 2013 +0200 +++ b/E5Gui/E5ModelMenu.py Sun Oct 06 19:45:29 2013 +0200 @@ -8,7 +8,8 @@ """ from PyQt4.QtCore import pyqtSignal, qVersion, Qt, QModelIndex, QPoint -from PyQt4.QtGui import QMenu, QFontMetrics, QAction, QApplication, QDrag, QPixmap +from PyQt4.QtGui import QMenu, QFontMetrics, QAction, QApplication, QDrag, \ + QPixmap import UI.PixmapCache @@ -182,7 +183,8 @@ def createMenu(self, parent, max_, parentMenu=None, menu=None): """ - Public method to put all the children of a parent into a menu of a given length. + Public method to put all the children of a parent into a menu of a + given length. @param parent index of the parent item (QModelIndex) @param max_ maximum number of entries (integer) @@ -220,7 +222,8 @@ if self.__model.hasChildren(idx): self.createMenu(idx, -1, menu) else: - if self.__separatorRole != 0 and idx.data(self.__separatorRole): + if self.__separatorRole != 0 and \ + idx.data(self.__separatorRole): self.addSeparator() else: menu.addAction(self.__makeAction(idx)) @@ -360,7 +363,8 @@ super().mouseMoveEvent(evt) return - manhattanLength = (evt.pos() - self.__dragStartPosition).manhattanLength() + manhattanLength = (evt.pos() - + self.__dragStartPosition).manhattanLength() if manhattanLength <= QApplication.startDragDistance(): super().mouseMoveEvent(evt) return
--- a/E5Gui/E5ModelToolBar.py Sun Oct 06 19:14:26 2013 +0200 +++ b/E5Gui/E5ModelToolBar.py Sun Oct 06 19:45:29 2013 +0200 @@ -8,7 +8,8 @@ """ from PyQt4.QtCore import pyqtSignal, qVersion, Qt, QModelIndex, QPoint, QEvent -from PyQt4.QtGui import QApplication, QDrag, QPixmap, QToolBar, QIcon, QToolButton +from PyQt4.QtGui import QApplication, QDrag, QPixmap, QToolBar, QIcon, \ + QToolButton class E5ModelToolBar(QToolBar): @@ -54,17 +55,23 @@ """ if self.__model is not None: self.__model.modelReset[()].disconnect(self._build) - self.__model.rowsInserted[QModelIndex, int, int].disconnect(self._build) - self.__model.rowsRemoved[QModelIndex, int, int].disconnect(self._build) - self.__model.dataChanged[QModelIndex, QModelIndex].disconnect(self._build) + self.__model.rowsInserted[QModelIndex, int, int].disconnect( + self._build) + self.__model.rowsRemoved[QModelIndex, int, int].disconnect( + self._build) + self.__model.dataChanged[QModelIndex, QModelIndex].disconnect( + self._build) self.__model = model if self.__model is not None: self.__model.modelReset[()].connect(self._build) - self.__model.rowsInserted[QModelIndex, int, int].connect(self._build) - self.__model.rowsRemoved[QModelIndex, int, int].connect(self._build) - self.__model.dataChanged[QModelIndex, QModelIndex].connect(self._build) + self.__model.rowsInserted[QModelIndex, int, int].connect( + self._build) + self.__model.rowsRemoved[QModelIndex, int, int].connect( + self._build) + self.__model.dataChanged[QModelIndex, QModelIndex].connect( + self._build) def model(self): """ @@ -225,7 +232,8 @@ super().mouseMoveEvent(evt) return - manhattanLength = (evt.pos() - self.__dragStartPosition).manhattanLength() + manhattanLength = (evt.pos() - + self.__dragStartPosition).manhattanLength() if manhattanLength <= QApplication.startDragDistance(): super().mouseMoveEvent(evt) return
--- a/E5Gui/E5PassivePopup.py Sun Oct 06 19:14:26 2013 +0200 +++ b/E5Gui/E5PassivePopup.py Sun Oct 06 19:45:29 2013 +0200 @@ -48,7 +48,8 @@ """ Public method to set the message view. - @param child reference to the widget to set as the message view (QWidget) + @param child reference to the widget to set as the message view + (QWidget) """ self.__msgView = child self.__topLayout = QVBoxLayout(self) @@ -103,8 +104,8 @@ Public method to set the delay for the popup is removed automatically. Setting the delay to 0 disables the timeout. If you're doing this, you - may want to connect the clicked() signal to the hide() slot. Setting the - delay to -1 makes it use the default value. + may want to connect the clicked() signal to the hide() slot. Setting + the delay to -1 makes it use the default value. @param delay value for the delay in milliseconds (integer) """ @@ -119,7 +120,8 @@ def timeout(self): """ - Public method to get the delay before the popup is removed automatically. + Public method to get the delay before the popup is removed + automatically. @return the delay before the popup is removed automatically (integer) """ @@ -159,7 +161,8 @@ def __moveNear(self, target): """ - Private method to move the popup to be adjacent to the specified rectangle. + Private method to move the popup to be adjacent to the specified + rectangle. @param target rectangle to be placed at (QRect) """ @@ -180,14 +183,16 @@ w = self.minimumSizeHint().width() h = self.minimumSizeHint().height() - r = QApplication.desktop().screenGeometry(QPoint(x + w // 2, y + h // 2)) + r = QApplication.desktop().screenGeometry( + QPoint(x + w // 2, y + h // 2)) if x < r.center().x(): x += target.width() else: x -= w - # It's apparently trying to go off screen, so display it ALL at the bottom. + # It's apparently trying to go off screen, so display it ALL at the + # bottom. if (y + h) > r.bottom(): y = r.bottom() - h
--- a/E5Gui/E5PasswordMeter.py Sun Oct 06 19:14:26 2013 +0200 +++ b/E5Gui/E5PasswordMeter.py Sun Oct 06 19:45:29 2013 +0200 @@ -44,7 +44,8 @@ " text-align: center; }}" \ "QProgressBar::chunk:horizontal {{" \ " background-color: {0}; }}" - self.setStyleSheet(self.__styleSheetTemplate.format(self.__noIndicator)) + self.setStyleSheet( + self.__styleSheetTemplate.format(self.__noIndicator)) def checkPasswordStrength(self, password): """
--- a/E5Gui/E5SideBar.py Sun Oct 06 19:14:26 2013 +0200 +++ b/E5Gui/E5SideBar.py Sun Oct 06 19:45:29 2013 +0200 @@ -7,9 +7,10 @@ Module implementing a sidebar class. """ -from PyQt4.QtCore import QEvent, QSize, Qt, QByteArray, QDataStream, QIODevice, QTimer -from PyQt4.QtGui import QTabBar, QWidget, QStackedWidget, QBoxLayout, QToolButton, \ - QSizePolicy +from PyQt4.QtCore import QEvent, QSize, Qt, QByteArray, QDataStream, \ + QIODevice, QTimer +from PyQt4.QtGui import QTabBar, QWidget, QStackedWidget, QBoxLayout, \ + QToolButton, QSizePolicy from E5Gui.E5Application import e5App @@ -18,8 +19,8 @@ class E5SideBar(QWidget): """ - Class implementing a sidebar with a widget area, that is hidden or shown, if the - current tab is clicked again. + Class implementing a sidebar with a widget area, that is hidden or shown, + if the current tab is clicked again. """ Version = 1 @@ -32,8 +33,10 @@ """ Constructor - @param orientation orientation of the sidebar widget (North, East, South, West) - @param delay value for the expand/shrink delay in milliseconds (integer) + @param orientation orientation of the sidebar widget (North, East, + South, West) + @param delay value for the expand/shrink delay in milliseconds + (integer) @param parent parent widget (QWidget) """ super().__init__(parent) @@ -47,7 +50,8 @@ self.__stackedWidget.setContentsMargins(0, 0, 0, 0) self.__autoHideButton = QToolButton() self.__autoHideButton.setCheckable(True) - self.__autoHideButton.setIcon(UI.PixmapCache.getIcon("autoHideOff.png")) + self.__autoHideButton.setIcon( + UI.PixmapCache.getIcon("autoHideOff.png")) self.__autoHideButton.setChecked(True) self.__autoHideButton.setToolTip( self.trUtf8("Deselect to activate automatic collapsing")) @@ -77,7 +81,8 @@ self.splitter = None self.splitterSizes = [] - self.__hasFocus = False # flag storing if this widget or any child has the focus + self.__hasFocus = False + # flag storing if this widget or any child has the focus self.__autoHide = False self.__tabBar.installEventFilter(self) @@ -87,7 +92,8 @@ orientation = E5SideBar.North self.setOrientation(orientation) - self.__tabBar.currentChanged[int].connect(self.__stackedWidget.setCurrentIndex) + self.__tabBar.currentChanged[int].connect( + self.__stackedWidget.setCurrentIndex) e5App().focusChanged[QWidget, QWidget].connect(self.__appFocusChanged) self.__autoHideButton.toggled[bool].connect(self.__autoHideToggled) @@ -122,15 +128,18 @@ def setDelay(self, delay): """ - Public method to set the delay value for the expand/shrink delay in milliseconds. + Public method to set the delay value for the expand/shrink delay in + milliseconds. - @param delay value for the expand/shrink delay in milliseconds (integer) + @param delay value for the expand/shrink delay in milliseconds + (integer) """ self.__delayTimer.setInterval(delay) def delay(self): """ - Public method to get the delay value for the expand/shrink delay in milliseconds. + Public method to get the delay value for the expand/shrink delay in + milliseconds. @return value for the expand/shrink delay in milliseconds (integer) """ @@ -242,7 +251,8 @@ return True elif self.isMinimized(): self.expand() - elif evt.type() == QEvent.Wheel and not self.__stackedWidget.isHidden(): + elif evt.type() == QEvent.Wheel and \ + not self.__stackedWidget.isHidden(): if evt.delta() > 0: self.prevTab() else: @@ -377,7 +387,8 @@ """ Public slot to set the current widget. - @param widget reference to the widget to become the current widget (QWidget) + @param widget reference to the widget to become the current widget + (QWidget) """ self.__stackedWidget.setCurrentWidget(widget) self.__tabBar.setCurrentIndex(self.__stackedWidget.currentIndex()) @@ -427,25 +438,29 @@ """ if orient == E5SideBar.North: self.__tabBar.setShape(QTabBar.RoundedNorth) - self.__tabBar.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred) + self.__tabBar.setSizePolicy( + QSizePolicy.Expanding, QSizePolicy.Preferred) self.barLayout.setDirection(QBoxLayout.LeftToRight) self.layout.setDirection(QBoxLayout.TopToBottom) self.layout.setAlignment(self.barLayout, Qt.AlignLeft) elif orient == E5SideBar.East: self.__tabBar.setShape(QTabBar.RoundedEast) - self.__tabBar.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Expanding) + self.__tabBar.setSizePolicy( + QSizePolicy.Preferred, QSizePolicy.Expanding) self.barLayout.setDirection(QBoxLayout.TopToBottom) self.layout.setDirection(QBoxLayout.RightToLeft) self.layout.setAlignment(self.barLayout, Qt.AlignTop) elif orient == E5SideBar.South: self.__tabBar.setShape(QTabBar.RoundedSouth) - self.__tabBar.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred) + self.__tabBar.setSizePolicy( + QSizePolicy.Expanding, QSizePolicy.Preferred) self.barLayout.setDirection(QBoxLayout.LeftToRight) self.layout.setDirection(QBoxLayout.BottomToTop) self.layout.setAlignment(self.barLayout, Qt.AlignLeft) elif orient == E5SideBar.West: self.__tabBar.setShape(QTabBar.RoundedWest) - self.__tabBar.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Expanding) + self.__tabBar.setSizePolicy( + QSizePolicy.Preferred, QSizePolicy.Expanding) self.barLayout.setDirection(QBoxLayout.TopToBottom) self.layout.setDirection(QBoxLayout.LeftToRight) self.layout.setAlignment(self.barLayout, Qt.AlignTop) @@ -615,13 +630,16 @@ """ Private slot to handle the toggling of the autohide button. - @param checked flag indicating the checked state of the button (boolean) + @param checked flag indicating the checked state of the button + (boolean) """ self.__autoHide = not checked if self.__autoHide: - self.__autoHideButton.setIcon(UI.PixmapCache.getIcon("autoHideOn.png")) + self.__autoHideButton.setIcon( + UI.PixmapCache.getIcon("autoHideOn.png")) else: - self.__autoHideButton.setIcon(UI.PixmapCache.getIcon("autoHideOff.png")) + self.__autoHideButton.setIcon( + UI.PixmapCache.getIcon("autoHideOff.png")) def __appFocusChanged(self, old, now): """ @@ -662,8 +680,9 @@ """ Public method to shut down the object. - This method does some preparations so the object can be deleted properly. - It disconnects from the focusChanged signal in order to avoid trouble later - on. + This method does some preparations so the object can be deleted + properly. It disconnects from the focusChanged signal in order to + avoid trouble later on. """ - e5App().focusChanged[QWidget, QWidget].disconnect(self.__appFocusChanged) + e5App().focusChanged[QWidget, QWidget].disconnect( + self.__appFocusChanged)
--- a/E5Gui/E5SingleApplication.py Sun Oct 06 19:14:26 2013 +0200 +++ b/E5Gui/E5SingleApplication.py Sun Oct 06 19:45:29 2013 +0200 @@ -11,7 +11,8 @@ from E5Gui.E5Application import e5App -from Toolbox.SingleApplication import SingleApplicationClient, SingleApplicationServer +from Toolbox.SingleApplication import SingleApplicationClient, \ + SingleApplicationServer import Utilities
--- a/E5Gui/E5SqueezeLabels.py Sun Oct 06 19:14:26 2013 +0200 +++ b/E5Gui/E5SqueezeLabels.py Sun Oct 06 19:45:29 2013 +0200 @@ -4,7 +4,8 @@ # """ -Module implementing labels that squeeze their contents to fit the size of the label. +Module implementing labels that squeeze their contents to fit the size of the +label. """ from PyQt4.QtCore import Qt @@ -36,7 +37,8 @@ """ fm = self.fontMetrics() if fm.width(self.__text) > self.contentsRect().width(): - self.__elided = fm.elidedText(self.text(), Qt.ElideMiddle, self.width()) + self.__elided = fm.elidedText( + self.text(), Qt.ElideMiddle, self.width()) super().setText(self.__elided) else: super().setText(self.__text) @@ -71,7 +73,8 @@ """ Public method to set the surrounding of the path string. - @param surrounding the a string containg placeholders for the path (string) + @param surrounding the a string containg placeholders for the path + (string) """ self.__surrounding = surrounding super().setText(self.__surrounding.format(self.__path)) @@ -89,7 +92,8 @@ """ Public method to set the surrounding and the path of the label. - @param surrounding the a string containg placeholders for the path (string) + @param surrounding the a string containg placeholders for the path + (string) @param path path to be shown (string) """ self.__surrounding = surrounding @@ -103,7 +107,8 @@ @param event reference to the paint event (QPaintEvent) """ fm = self.fontMetrics() - if fm.width(self.__surrounding.format(self.__path)) > self.contentsRect().width(): + if (fm.width(self.__surrounding.format(self.__path)) > + self.contentsRect().width()): super().setText( self.__surrounding.format(compactPath(self.__path, self.contentsRect().width(),
--- a/E5Gui/E5TabWidget.py Sun Oct 06 19:14:26 2013 +0200 +++ b/E5Gui/E5TabWidget.py Sun Oct 06 19:45:29 2013 +0200 @@ -8,12 +8,14 @@ """ from PyQt4.QtCore import Qt, QPoint, QMimeData, QByteArray, pyqtSignal -from PyQt4.QtGui import QTabWidget, QTabBar, QApplication, QDrag, QStyle, QLabel, QMovie +from PyQt4.QtGui import QTabWidget, QTabBar, QApplication, QDrag, QStyle, \ + QLabel, QMovie class E5WheelTabBar(QTabBar): """ - Class implementing a tab bar class substituting QTabBar to support wheel events. + Class implementing a tab bar class substituting QTabBar to support wheel + events. """ def __init__(self, parent=None): """ @@ -45,8 +47,8 @@ """ Class implementing a tab bar class substituting QTabBar. - @signal tabMoveRequested(int, int) emitted to signal a tab move request giving - the old and new index position + @signal tabMoveRequested(int, int) emitted to signal a tab move request + giving the old and new index position """ tabMoveRequested = pyqtSignal(int, int) @@ -126,8 +128,8 @@ It provides slots to show the previous and next tab and give them the input focus and it allows to have a context menu for the tabs. - @signal customTabContextMenuRequested(const QPoint & point, int index) emitted when - a context menu for a tab is requested + @signal customTabContextMenuRequested(const QPoint & point, int index) + emitted when a context menu for a tab is requested """ customTabContextMenuRequested = pyqtSignal(QPoint, int) @@ -186,7 +188,8 @@ def switchTab(self): """ - Public slot used to switch between the current and the previous current tab. + Public slot used to switch between the current and the previous + current tab. """ if self.__lastCurrentIndex == -1 or self.__currentIndex == -1: return @@ -240,7 +243,8 @@ for index in range(_tabbar.count()): rect = _tabbar.tabRect(index) if rect.contains(point): - self.customTabContextMenuRequested.emit(_tabbar.mapToParent(point), index) + self.customTabContextMenuRequested.emit( + _tabbar.mapToParent(point), index) return self.customTabContextMenuRequested.emit(_tabbar.mapToParent(point), -1) @@ -292,7 +296,8 @@ @return free side (QTabBar.ButtonPosition) """ - side = self.__tabBar.style().styleHint(QStyle.SH_TabBar_CloseButtonPosition, + side = self.__tabBar.style().styleHint( + QStyle.SH_TabBar_CloseButtonPosition, None, None, None) if side == QTabBar.LeftSide: side = QTabBar.RightSide
--- a/E5Gui/E5ToolBarDialog.py Sun Oct 06 19:14:26 2013 +0200 +++ b/E5Gui/E5ToolBarDialog.py Sun Oct 06 19:45:29 2013 +0200 @@ -27,7 +27,8 @@ Constructor @param toolBarId id of the toolbar object (integer) - @param actionIDs list of action IDs belonging to the toolbar (list of integer) + @param actionIDs list of action IDs belonging to the toolbar + (list of integer) @param default flag indicating a default toolbar (boolean) """ self.toolBarId = toolBarId @@ -48,16 +49,19 @@ """ Constructor - @param toolBarManager reference to a toolbar manager object (E5ToolBarManager) + @param toolBarManager reference to a toolbar manager object + (E5ToolBarManager) @param parent reference to the parent widget (QWidget) """ super().__init__(parent) self.setupUi(self) self.__manager = toolBarManager - self.__toolbarItems = {} # maps toolbar item IDs to toolbar items + self.__toolbarItems = {} + # maps toolbar item IDs to toolbar items self.__currentToolBarItem = None - self.__removedToolBarIDs = [] # remember custom toolbars to be deleted + self.__removedToolBarIDs = [] + # remember custom toolbars to be deleted self.__widgetActionToToolBarItemID = {} # maps widget action IDs to toolbar item IDs @@ -108,11 +112,13 @@ actionIDs.append(aID) if aID in self.__widgetActionToToolBarItemID: self.__widgetActionToToolBarItemID[aID] = id(tbItem) - self.__toolBarItemToWidgetActionID[id(tbItem)].append(aID) + self.__toolBarItemToWidgetActionID[id(tbItem)]\ + .append(aID) tbItem.actionIDs = actionIDs self.toolbarComboBox.addItem(tb.windowTitle(), int(id(tbItem))) if default: - self.toolbarComboBox.setItemData(self.toolbarComboBox.count() - 1, + self.toolbarComboBox.setItemData( + self.toolbarComboBox.count() - 1, QColor(Qt.darkGreen), Qt.ForegroundRole) self.toolbarComboBox.model().sort(0) @@ -135,7 +141,8 @@ # toolbar with this name already exists E5MessageBox.critical(self, self.trUtf8("New Toolbar"), - self.trUtf8("""A toolbar with the name <b>{0}</b> already exists.""")\ + self.trUtf8( + """A toolbar with the name <b>{0}</b> already exists.""") .format(name)) return @@ -146,7 +153,8 @@ self.__toolBarItemToWidgetActionID[id(tbItem)] = [] self.toolbarComboBox.addItem(name, int(id(tbItem))) self.toolbarComboBox.model().sort(0) - self.toolbarComboBox.setCurrentIndex(self.toolbarComboBox.findText(name)) + self.toolbarComboBox.setCurrentIndex( + self.toolbarComboBox.findText(name)) @pyqtSlot() def on_removeButton_clicked(self): @@ -156,7 +164,8 @@ name = self.toolbarComboBox.currentText() res = E5MessageBox.yesNo(self, self.trUtf8("Remove Toolbar"), - self.trUtf8("""Should the toolbar <b>{0}</b> really be removed?""")\ + self.trUtf8( + """Should the toolbar <b>{0}</b> really be removed?""") .format(name)) if res: index = self.toolbarComboBox.currentIndex() @@ -190,7 +199,8 @@ # toolbar with this name already exists E5MessageBox.critical(self, self.trUtf8("Rename Toolbar"), - self.trUtf8("""A toolbar with the name <b>{0}</b> already exists.""")\ + self.trUtf8( + """A toolbar with the name <b>{0}</b> already exists.""") .format(newName)) return index = self.toolbarComboBox.currentIndex() @@ -208,10 +218,14 @@ if index > -1: itemID = self.toolbarComboBox.itemData(index) self.__currentToolBarItem = self.__toolbarItems[itemID] - self.renameButton.setEnabled(not self.__currentToolBarItem.isDefault) - self.removeButton.setEnabled(not self.__currentToolBarItem.isDefault) - self.__restoreDefaultsButton.setEnabled(self.__currentToolBarItem.isDefault) - self.__resetButton.setEnabled(self.__currentToolBarItem.toolBarId is not None) + self.renameButton.setEnabled( + not self.__currentToolBarItem.isDefault) + self.removeButton.setEnabled( + not self.__currentToolBarItem.isDefault) + self.__restoreDefaultsButton.setEnabled( + self.__currentToolBarItem.isDefault) + self.__resetButton.setEnabled( + self.__currentToolBarItem.toolBarId is not None) row = self.toolbarActionsList.currentRow() self.upButton.setEnabled(row > 0) @@ -351,11 +365,12 @@ if oldTbItemID is not None: self.__toolbarItems[oldTbItemID].actionIDs.remove(actionID) self.__toolbarItems[oldTbItemID].isChanged = True - self.__toolBarItemToWidgetActionID[oldTbItemID].remove(actionID) + self.__toolBarItemToWidgetActionID[oldTbItemID]\ + .remove(actionID) self.__widgetActionToToolBarItemID[actionID] = \ id(self.__currentToolBarItem) - self.__toolBarItemToWidgetActionID[id(self.__currentToolBarItem)]\ - .append(actionID) + self.__toolBarItemToWidgetActionID[ + id(self.__currentToolBarItem)].append(actionID) self.toolbarActionsList.insertItem(row, item) self.__currentToolBarItem.actionIDs.insert(row, actionID) self.__currentToolBarItem.isChanged = True @@ -417,16 +432,19 @@ else: action = self.__manager.actionById(actionID) if action is None: - raise RuntimeError("No such action, id: 0x{0:x}".format(actionID)) + raise RuntimeError( + "No such action, id: 0x{0:x}".format(actionID)) actions.append(action) self.__manager.setToolBar(tb, actions) tbItem.isChanged = False def __restoreCurrentToolbar(self, actions): """ - Private methdo to restore the current toolbar to the given list of actions. + Private methdo to restore the current toolbar to the given list of + actions. - @param actions list of actions to set for the current toolbar (list of QAction) + @param actions list of actions to set for the current toolbar + (list of QAction) """ tbItemID = id(self.__currentToolBarItem) for widgetActionID in self.__toolBarItemToWidgetActionID[tbItemID]: @@ -443,12 +461,16 @@ if actionID in self.__widgetActionToToolBarItemID: oldTbItemID = self.__widgetActionToToolBarItemID[actionID] if oldTbItemID is not None: - self.__toolbarItems[oldTbItemID].actionIDs.remove(actionID) + self.__toolbarItems[oldTbItemID].actionIDs.remove( + actionID) self.__toolbarItems[oldTbItemID].isChanged = True - self.__toolBarItemToWidgetActionID[oldTbItemID].remove(actionID) + self.__toolBarItemToWidgetActionID[oldTbItemID].remove( + actionID) self.__widgetActionToToolBarItemID[actionID] = tbItemID - self.__toolBarItemToWidgetActionID[tbItemID].append(actionID) - self.__toolbarComboBox_currentIndexChanged(self.toolbarComboBox.currentIndex()) + self.__toolBarItemToWidgetActionID[tbItemID].append( + actionID) + self.__toolbarComboBox_currentIndexChanged( + self.toolbarComboBox.currentIndex()) def __resetCurrentToolbar(self): """
--- a/E5Gui/E5ToolBarManager.py Sun Oct 06 19:14:26 2013 +0200 +++ b/E5Gui/E5ToolBarManager.py Sun Oct 06 19:45:29 2013 +0200 @@ -33,19 +33,30 @@ self.__mainWindow = None self.__ui = ui - self.__toolBars = {} # maps toolbar IDs to actions - self.__toolBarsWithSeparators = {} # maps toolbar IDs to actions incl. separators - self.__defaultToolBars = {} # maps default toolbar IDs to actions - self.__customToolBars = [] # list of custom toolbars - self.__allToolBars = {} # maps toolbar IDs to toolbars + self.__toolBars = {} + # maps toolbar IDs to actions + self.__toolBarsWithSeparators = {} + # maps toolbar IDs to actions incl. separators + self.__defaultToolBars = {} + # maps default toolbar IDs to actions + self.__customToolBars = [] + # list of custom toolbars + self.__allToolBars = {} + # maps toolbar IDs to toolbars - self.__categoryToActions = {} # maps categories to actions - self.__actionToCategory = {} # maps action IDs to categories - self.__allActions = {} # maps action IDs to actions - self.__actionToToolBars = {} # maps action IDs to toolbars + self.__categoryToActions = {} + # maps categories to actions + self.__actionToCategory = {} + # maps action IDs to categories + self.__allActions = {} + # maps action IDs to actions + self.__actionToToolBars = {} + # maps action IDs to toolbars - self.__widgetActions = {} # maps widget action IDs to toolbars - self.__allWidgetActions = {} # maps widget action IDs to widget actions + self.__widgetActions = {} + # maps widget action IDs to toolbars + self.__allWidgetActions = {} + # maps widget action IDs to widget actions ###################################################### ## Private methods @@ -591,7 +602,8 @@ removedActions = [] for action in actions[tbID]: - if action in newActions and self.toolBarWidgetAction(action) == toolBar: + if action in newActions and \ + self.toolBarWidgetAction(action) == toolBar: newActions.remove(action) newActionsWithSeparators.remove(action) removedActions.append(action)
--- a/E5Gui/E5ToolBox.py Sun Oct 06 19:14:26 2013 +0200 +++ b/E5Gui/E5ToolBox.py Sun Oct 06 19:45:29 2013 +0200 @@ -14,7 +14,8 @@ class E5VerticalToolBox(QToolBox): """ - Class implementing a ToolBox class substituting QToolBox to support wheel events. + Class implementing a ToolBox class substituting QToolBox to support wheel + events. """ def __init__(self, parent=None): """
--- a/E5Gui/E5TreeSortFilterProxyModel.py Sun Oct 06 19:14:26 2013 +0200 +++ b/E5Gui/E5TreeSortFilterProxyModel.py Sun Oct 06 19:45:29 2013 +0200 @@ -40,7 +40,8 @@ if self.sourceModel().hasChildren(idx): return True - return QSortFilterProxyModel.filterAcceptsRow(self, sourceRow, sourceParent) + return QSortFilterProxyModel.filterAcceptsRow( + self, sourceRow, sourceParent) def hasChildren(self, parent=QModelIndex()): """
--- a/E5Gui/E5TreeWidget.py Sun Oct 06 19:14:26 2013 +0200 +++ b/E5Gui/E5TreeWidget.py Sun Oct 06 19:45:29 2013 +0200 @@ -48,7 +48,8 @@ @param mode default mode (ItemsCollapsed, ItemsExpanded) """ - assert mode in [E5TreeWidget.ItemsCollapsed, E5TreeWidget.ItemsExpanded] + assert mode in [E5TreeWidget.ItemsCollapsed, + E5TreeWidget.ItemsExpanded] self.__showMode = mode @@ -136,7 +137,8 @@ """ Public method to add a list of top level items. - @param items items to be added as top level items (list of QTreeWidgetItem) + @param items items to be added as top level items + (list of QTreeWidgetItem) """ self.__allTreeItems.extend(items) super().addTopLevelItems(items) @@ -156,7 +158,8 @@ Public method to insert a list of top level items. @param index index for the insertion (integer) - @param items items to be inserted as top level items (list of QTreeWidgetItem) + @param items items to be inserted as top level items + (list of QTreeWidgetItem) """ self.__allTreeItems.extend(items) super().insertTopLevelItems(index, items)
--- a/E5Gui/E5ZoomWidget.py Sun Oct 06 19:14:26 2013 +0200 +++ b/E5Gui/E5ZoomWidget.py Sun Oct 06 19:45:29 2013 +0200 @@ -202,7 +202,8 @@ @param mapping list of mapping values (list of integer) @param default index of the default value (integer) - @keyparam percent flag indicating to show zoom value in percent (boolean) + @keyparam percent flag indicating to show zoom value in percent + (boolean) """ if mapping: self.__mapping = mapping[:] @@ -227,7 +228,8 @@ """ Public method to get the current mapping. - @return tuple of the mapping and the default index (list of integer, integer) + @return tuple of the mapping and the default index + (list of integer, integer) """ return self.__mapping[:], self.__default
--- a/E5Network/E5Ftp.py Sun Oct 06 19:14:26 2013 +0200 +++ b/E5Network/E5Ftp.py Sun Oct 06 19:45:29 2013 +0200 @@ -4,7 +4,8 @@ # """ -Module implementing an extension to the Python FTP class to support FTP proxies. +Module implementing an extension to the Python FTP class to support FTP +proxies. """ import ftplib @@ -18,14 +19,18 @@ The error message starts with a three digit error code followed by a space and the error string. Supported error codes are: <ul> - <li>910: proxy error; the second number gives the category of the proxy error. - The original response from the proxy is appended in the next line.</li> - <li>930: proxy error; the second number gives the category of the proxy error. - The original response from the proxy is appended in the next line.</li> - <li>940: proxy error; the second number gives the category of the proxy error. - The original response from the proxy is appended in the next line.</li> - <li>950: proxy error; the second number gives the category of the proxy error. - The original response from the proxy is appended in the next line.</li> + <li>910: proxy error; the second number gives the category of the proxy + error. The original response from the proxy is appended in the next + line.</li> + <li>930: proxy error; the second number gives the category of the proxy + error. The original response from the proxy is appended in the next + line.</li> + <li>940: proxy error; the second number gives the category of the proxy + error. The original response from the proxy is appended in the next + line.</li> + <li>950: proxy error; the second number gives the category of the proxy + error. The original response from the proxy is appended in the next + line.</li> <li>990: proxy usage is enabled but no proxy host given</li> <li>991: proxy usage is enabled but no proxy user given</li> <li>992: proxy usage is enabled but no proxy password given</li> @@ -46,18 +51,20 @@ UserAtProxyuserAtServer = 5 # one login for both ProxyuserAtServer = 6 # proxy login with remote host given, than # normal remote login - AuthResp = 7 # authenticate to proxy with AUTH and RESP commands + AuthResp = 7 # authenticate to proxy with AUTH and + # RESP commands Bluecoat = 8 # bluecoat proxy class E5Ftp(ftplib.FTP): """ - Class implementing an extension to the Python FTP class to support FTP proxies. + Class implementing an extension to the Python FTP class to support FTP + proxies. """ def __init__(self, host="", user="", password="", acct="", - proxyType=E5FtpProxyType.NoProxy, proxyHost="", proxyPort=ftplib.FTP_PORT, - proxyUser="", proxyPassword="", proxyAccount="", - timeout=_GLOBAL_DEFAULT_TIMEOUT): + proxyType=E5FtpProxyType.NoProxy, proxyHost="", + proxyPort=ftplib.FTP_PORT, proxyUser="", proxyPassword="", + proxyAccount="", timeout=_GLOBAL_DEFAULT_TIMEOUT): """ Constructor @@ -96,7 +103,8 @@ self.login(user, password, acct) def setProxy(self, proxyType=E5FtpProxyType.NoProxy, proxyHost="", - proxyPort=ftplib.FTP_PORT, proxyUser="", proxyPassword="", proxyAccount=""): + proxyPort=ftplib.FTP_PORT, proxyUser="", proxyPassword="", + proxyAccount=""): """ Public method to set the proxy configuration. @@ -114,7 +122,8 @@ self.__proxyPassword = proxyPassword self.__proxyAccount = proxyAccount - def setProxyAuthentication(self, proxyUser="", proxyPassword="", proxyAccount=""): + def setProxyAuthentication(self, proxyUser="", proxyPassword="", + proxyAccount=""): """ Public method to set the proxy authentication info. @@ -152,7 +161,8 @@ raise E5FtpProxyError( "990 Proxy usage requested, but no proxy host given.") - return super().connect(self.__proxyHost, self.__proxyPort, self.__timeout) + return super().connect( + self.__proxyHost, self.__proxyPort, self.__timeout) else: return super().connect(self.__host, self.__port, self.__timeout) @@ -160,17 +170,18 @@ """ Public method to login to the FTP server. - This extended method respects the FTP proxy configuration. There are many - different FTP proxy products available. But unfortunately there is no - standard for how o traverse a FTP proxy. The lis below shows the sequence - of commands used. + This extended method respects the FTP proxy configuration. There are + many different FTP proxy products available. But unfortunately there + is no standard for how o traverse a FTP proxy. The lis below shows + the sequence of commands used. <table> <tr><td>user</td><td>Username for remote host</td></tr> <tr><td>pass</td><td>Password for remote host</td></tr> <tr><td>pruser</td><td>Username for FTP proxy</td></tr> <tr><td>prpass</td><td>Password for FTP proxy</td></tr> - <tr><td>remote.host</td><td>Hostname of the remote FTP server</td></tr> + <tr><td>remote.host</td><td>Hostname of the remote FTP server</td> + </tr> </table> <dl> @@ -259,7 +270,8 @@ "991 Proxy usage requested, but no proxy user given") if not self.__proxyPassword: raise E5FtpProxyError( - "992 Proxy usage requested, but no proxy password given") + "992 Proxy usage requested, but no proxy password" + " given") if self.__proxyType in [E5FtpProxyType.NonAuthorizing, E5FtpProxyType.AuthResp, E5FtpProxyType.Bluecoat]: @@ -268,7 +280,8 @@ user += " " + self.__proxyUser acct = self.__proxyPassword elif self.__proxyType == E5FtpProxyType.UserAtProxyuserAtServer: - user = "{0}@{1}@{2}".format(user, self.__proxyUser, self.__host) + user = "{0}@{1}@{2}".format( + user, self.__proxyUser, self.__host) password = "{0}@{1}".format(password, self.__proxyPassword) else: pruser = self.__proxyUser @@ -284,7 +297,8 @@ if presp[0] == "3" and self.__proxyAccount: presp = self.sendcmd("ACCT " + self.__proxyAccount) if presp[0] != "2": - raise E5FtpProxyError("9{0}0 Error authorizing at proxy\n{1}".format( + raise E5FtpProxyError( + "9{0}0 Error authorizing at proxy\n{1}".format( presp[0], presp)) if self.__proxyType == E5FtpProxyType.Site: @@ -317,7 +331,8 @@ if presp[0] == "3": presp = self.sendcmd("RESP " + self.__proxyPassword) if presp[0] != "2": - raise E5FtpProxyError("9{0}0 Error authorizing at proxy\n{1}".format( + raise E5FtpProxyError( + "9{0}0 Error authorizing at proxy\n{1}".format( presp[0], presp)) return resp
--- a/E5Network/E5NetworkMonitor.py Sun Oct 06 19:14:26 2013 +0200 +++ b/E5Network/E5NetworkMonitor.py Sun Oct 06 19:45:29 2013 +0200 @@ -85,14 +85,16 @@ [self.trUtf8("Name"), self.trUtf8("Value")]) self.responseHeadersList.setModel(self.__replyHeaders) self.responseHeadersList.horizontalHeader().setStretchLastSection(True) - self.responseHeadersList.doubleClicked.connect(self.__showHeaderDetails) + self.responseHeadersList.doubleClicked.connect( + self.__showHeaderDetails) self.requestsList.horizontalHeader().setStretchLastSection(True) self.requestsList.verticalHeader().setMinimumSectionSize(-1) self.__proxyModel = QSortFilterProxyModel(self) self.__proxyModel.setFilterKeyColumn(-1) - self.searchEdit.textChanged.connect(self.__proxyModel.setFilterFixedString) + self.searchEdit.textChanged.connect( + self.__proxyModel.setFilterFixedString) self.removeButton.clicked[()].connect(self.requestsList.removeSelected) self.removeAllButton.clicked[()].connect(self.requestsList.removeAll) @@ -100,8 +102,10 @@ self.__model = E5RequestModel(networkAccessManager, self) self.__proxyModel.setSourceModel(self.__model) self.requestsList.setModel(self.__proxyModel) - self.__proxyModel.rowsInserted.connect(self.requestsList.scrollToBottom) - self.requestsList.selectionModel().currentChanged[QModelIndex, QModelIndex]\ + self.__proxyModel.rowsInserted.connect( + self.requestsList.scrollToBottom) + self.requestsList.selectionModel()\ + .currentChanged[QModelIndex, QModelIndex]\ .connect(self.__currentChanged) fm = self.fontMetrics() @@ -189,7 +193,8 @@ name = headerList.model().data(headerList.model().index(row, 0)) value = headerList.model().data(headerList.model().index(row, 1)) if self.__headersDlg is None: - from .E5NetworkHeaderDetailsDialog import E5NetworkHeaderDetailsDialog + from .E5NetworkHeaderDetailsDialog import \ + E5NetworkHeaderDetailsDialog self.__headersDlg = E5NetworkHeaderDetailsDialog(self) self.__headersDlg.setData(name, value) self.__headersDlg.show() @@ -248,7 +253,8 @@ @param req reference to the request object (E5NetworkRequest) """ - self.beginInsertRows(QModelIndex(), len(self.requests), len(self.requests)) + self.beginInsertRows( + QModelIndex(), len(self.requests), len(self.requests)) self.requests.append(req) req.reply.finished[()].connect(self.__addReply) self.endInsertRows() @@ -276,13 +282,17 @@ # save reply info to be displayed status = reply.attribute(QNetworkRequest.HttpStatusCodeAttribute) or 0 - reason = reply.attribute(QNetworkRequest.HttpReasonPhraseAttribute) or "" + reason = \ + reply.attribute(QNetworkRequest.HttpReasonPhraseAttribute) or "" self.requests[offset].response = "{0:d} {1}".format(status, reason) - self.requests[offset].length = reply.header(QNetworkRequest.ContentLengthHeader) - self.requests[offset].contentType = reply.header(QNetworkRequest.ContentTypeHeader) + self.requests[offset].length = \ + reply.header(QNetworkRequest.ContentLengthHeader) + self.requests[offset].contentType = \ + reply.header(QNetworkRequest.ContentTypeHeader) if status == 302: - target = reply.attribute(QNetworkRequest.RedirectionTargetAttribute) or QUrl() + target = reply.attribute( + QNetworkRequest.RedirectionTargetAttribute) or QUrl() self.requests[offset].info = \ self.trUtf8("Redirect: {0}").format(target.toString())
--- a/E5Network/E5NetworkProxyFactory.py Sun Oct 06 19:14:26 2013 +0200 +++ b/E5Network/E5NetworkProxyFactory.py Sun Oct 06 19:45:29 2013 +0200 @@ -11,7 +11,8 @@ from PyQt4.QtCore import QUrl, QCoreApplication from PyQt4.QtGui import QDialog -from PyQt4.QtNetwork import QNetworkProxyFactory, QNetworkProxy, QNetworkProxyQuery +from PyQt4.QtNetwork import QNetworkProxyFactory, QNetworkProxy, \ + QNetworkProxyQuery from E5Gui import E5MessageBox @@ -107,8 +108,9 @@ proxyType = QNetworkProxy.FtpCachingProxy else: proxyType = QNetworkProxy.HttpProxy - proxy = QNetworkProxy(proxyType, url.host(), url.port(), - url.userName(), url.password()) + proxy = QNetworkProxy( + proxyType, url.host(), url.port(), + url.userName(), url.password()) proxyList = [proxy] break if proxyList: @@ -119,7 +121,8 @@ proxyList[0].setUser( Preferences.getUI("ProxyUser/{0}".format(scheme))) proxyList[0].setPassword( - Preferences.getUI("ProxyPassword/{0}".format(scheme))) + Preferences.getUI( + "ProxyPassword/{0}".format(scheme))) return proxyList else: return [QNetworkProxy(QNetworkProxy.NoProxy)]
--- a/E5Network/E5SslCertificatesDialog.py Sun Oct 06 19:14:26 2013 +0200 +++ b/E5Network/E5SslCertificatesDialog.py Sun Oct 06 19:45:29 2013 +0200 @@ -7,11 +7,12 @@ Module implementing a dialog to show and edit all certificates. """ -from PyQt4.QtCore import pyqtSlot, Qt, QByteArray, QFile, QFileInfo, QIODevice, \ - qVersion +from PyQt4.QtCore import pyqtSlot, Qt, QByteArray, QFile, QFileInfo, \ + QIODevice, qVersion from PyQt4.QtGui import QDialog, QTreeWidgetItem try: - from PyQt4.QtNetwork import QSslCertificate, QSslSocket, QSslConfiguration, QSsl + from PyQt4.QtNetwork import QSslCertificate, QSslSocket, \ + QSslConfiguration, QSsl except ImportError: pass @@ -39,15 +40,23 @@ super().__init__(parent) self.setupUi(self) - self.serversViewButton.setIcon(UI.PixmapCache.getIcon("certificates.png")) - self.serversDeleteButton.setIcon(UI.PixmapCache.getIcon("certificateDelete.png")) - self.serversExportButton.setIcon(UI.PixmapCache.getIcon("certificateExport.png")) - self.serversImportButton.setIcon(UI.PixmapCache.getIcon("certificateImport.png")) + self.serversViewButton.setIcon( + UI.PixmapCache.getIcon("certificates.png")) + self.serversDeleteButton.setIcon( + UI.PixmapCache.getIcon("certificateDelete.png")) + self.serversExportButton.setIcon( + UI.PixmapCache.getIcon("certificateExport.png")) + self.serversImportButton.setIcon( + UI.PixmapCache.getIcon("certificateImport.png")) - self.caViewButton.setIcon(UI.PixmapCache.getIcon("certificates.png")) - self.caDeleteButton.setIcon(UI.PixmapCache.getIcon("certificateDelete.png")) - self.caExportButton.setIcon(UI.PixmapCache.getIcon("certificateExport.png")) - self.caImportButton.setIcon(UI.PixmapCache.getIcon("certificateImport.png")) + self.caViewButton.setIcon( + UI.PixmapCache.getIcon("certificates.png")) + self.caDeleteButton.setIcon( + UI.PixmapCache.getIcon("certificateDelete.png")) + self.caExportButton.setIcon( + UI.PixmapCache.getIcon("certificateExport.png")) + self.caImportButton.setIcon( + UI.PixmapCache.getIcon("certificateImport.png")) self.__populateServerCertificatesTree() self.__populateCaCertificatesTree() @@ -94,7 +103,8 @@ items = self.serversCertificatesTree.findItems(organisation, Qt.MatchFixedString | Qt.MatchCaseSensitive) if len(items) == 0: - parent = QTreeWidgetItem(self.serversCertificatesTree, [organisation]) + parent = QTreeWidgetItem( + self.serversCertificatesTree, [organisation]) else: parent = items[0] @@ -121,9 +131,11 @@ Private slot to show data of the selected server certificate. """ try: - from E5Network.E5SslCertificatesInfoDialog import E5SslCertificatesInfoDialog + from E5Network.E5SslCertificatesInfoDialog import \ + E5SslCertificatesInfoDialog cert = QSslCertificate.fromData( - self.serversCertificatesTree.currentItem().data(0, self.CertRole)) + self.serversCertificatesTree.currentItem().data( + 0, self.CertRole)) dlg = E5SslCertificatesInfoDialog(cert, self) dlg.exec_() except ImportError: @@ -137,17 +149,20 @@ itm = self.serversCertificatesTree.currentItem() res = E5MessageBox.yesNo(self, self.trUtf8("Delete Server Certificate"), - self.trUtf8("""<p>Shall the server certificate really be deleted?</p>""" - """<p>{0}</p>""" - """<p>If the server certificate is deleted, the normal security""" - """ checks will be reinstantiated and the server has to""" - """ present a valid certificate.</p>""")\ + self.trUtf8("""<p>Shall the server certificate really be""" + """ deleted?</p><p>{0}</p>""" + """<p>If the server certificate is deleted, the""" + """ normal security checks will be reinstantiated""" + """ and the server has to present a valid""" + """ certificate.</p>""")\ .format(itm.text(0))) if res: server = itm.text(1) - cert = self.serversCertificatesTree.currentItem().data(0, self.CertRole) + cert = self.serversCertificatesTree.currentItem().data( + 0, self.CertRole) - # delete the selected entry and its parent entry, if it was the only one + # delete the selected entry and its parent entry, + # if it was the only one parent = itm.parent() parent.takeChild(parent.indexOfChild(itm)) if parent.childCount() == 0: @@ -196,11 +211,13 @@ commonStr = ", ".join( cert.subjectInfo(QSslCertificate.CommonName)) else: - commonStr = cert.subjectInfo(QSslCertificate.CommonName) + commonStr = cert.subjectInfo( + QSslCertificate.CommonName) E5MessageBox.warning(self, self.trUtf8("Import Certificate"), - self.trUtf8("""<p>The certificate <b>{0}</b> already exists.""" - """ Skipping.</p>""") + self.trUtf8( + """<p>The certificate <b>{0}</b> already exists.""" + """ Skipping.</p>""") .format(Utilities.decodeString(commonStr))) else: pems.append(cert.toPem() + '\n') @@ -220,7 +237,8 @@ """ Private slot to export the selected server certificate. """ - cert = self.serversCertificatesTree.currentItem().data(0, self.CertRole) + cert = self.serversCertificatesTree.currentItem().data( + 0, self.CertRole) fname = self.serversCertificatesTree.currentItem().text(0)\ .replace(" ", "").replace("\t", "") self.__exportCertificate(fname, cert) @@ -318,7 +336,8 @@ Private slot to show data of the selected CA certificate. """ try: - from E5Network.E5SslCertificatesInfoDialog import E5SslCertificatesInfoDialog + from E5Network.E5SslCertificatesInfoDialog import \ + E5SslCertificatesInfoDialog cert = QSslCertificate.fromData( self.caCertificatesTree.currentItem().data(0, self.CertRole)) dlg = E5SslCertificatesInfoDialog(cert, self) @@ -334,15 +353,17 @@ itm = self.caCertificatesTree.currentItem() res = E5MessageBox.yesNo(self, self.trUtf8("Delete CA Certificate"), - self.trUtf8("""<p>Shall the CA certificate really be deleted?</p>""" - """<p>{0}</p>""" - """<p>If the CA certificate is deleted, the browser""" - """ will not trust any certificate issued by this CA.</p>""")\ + self.trUtf8( + """<p>Shall the CA certificate really be deleted?</p>""" + """<p>{0}</p>""" + """<p>If the CA certificate is deleted, the browser""" + """ will not trust any certificate issued by this CA.</p>""")\ .format(itm.text(0))) if res: cert = self.caCertificatesTree.currentItem().data(0, self.CertRole) - # delete the selected entry and its parent entry, if it was the only one + # delete the selected entry and its parent entry, + # if it was the only one parent = itm.parent() parent.takeChild(parent.indexOfChild(itm)) if parent.childCount() == 0: @@ -356,7 +377,8 @@ pems = QByteArray() for cert in caCerts: pems.append(cert.toPem() + '\n') - Preferences.Prefs.settings.setValue("Help/SystemCertificates", pems) + Preferences.Prefs.settings.setValue( + "Help/SystemCertificates", pems) # delete the certificate from the default certificates self.__updateDefaultConfiguration() @@ -375,11 +397,13 @@ commonStr = ", ".join( cert.subjectInfo(QSslCertificate.CommonName)) else: - commonStr = cert.subjectInfo(QSslCertificate.CommonName) + commonStr = cert.subjectInfo( + QSslCertificate.CommonName) E5MessageBox.warning(self, self.trUtf8("Import Certificate"), - self.trUtf8("""<p>The certificate <b>{0}</b> already exists.""" - """ Skipping.</p>""") + self.trUtf8( + """<p>The certificate <b>{0}</b> already exists.""" + """ Skipping.</p>""") .format(Utilities.decodeString(commonStr))) else: caCerts.append(cert) @@ -387,7 +411,8 @@ pems = QByteArray() for cert in caCerts: pems.append(cert.toPem() + '\n') - Preferences.Prefs.settings.setValue("Help/SystemCertificates", pems) + Preferences.Prefs.settings.setValue( + "Help/SystemCertificates", pems) self.caCertificatesTree.clear() self.__populateCaCertificatesTree() @@ -440,8 +465,9 @@ if not f.open(QIODevice.WriteOnly): E5MessageBox.critical(self, self.trUtf8("Export Certificate"), - self.trUtf8("""<p>The certificate could not be written to file""" - """ <b>{0}</b></p><p>Error: {1}</p>""") + self.trUtf8( + """<p>The certificate could not be written""" + """ to file <b>{0}</b></p><p>Error: {1}</p>""") .format(fname, f.errorString())) return @@ -470,8 +496,9 @@ if not f.open(QIODevice.ReadOnly): E5MessageBox.critical(self, self.trUtf8("Export Certificate"), - self.trUtf8("""<p>The certificate could not be read from file""" - """ <b>{0}</b></p><p>Error: {1}</p>""") + self.trUtf8( + """<p>The certificate could not be read from file""" + """ <b>{0}</b></p><p>Error: {1}</p>""") .format(fname, f.errorString())) return []
--- a/E5Network/E5SslCertificatesInfoWidget.py Sun Oct 06 19:14:26 2013 +0200 +++ b/E5Network/E5SslCertificatesInfoWidget.py Sun Oct 06 19:45:29 2013 +0200 @@ -35,7 +35,8 @@ """ Public method to show the SSL certificates of a certificate chain. - @param certificateChain list od SSL certificates (list of QSslCertificate) + @param certificateChain list od SSL certificates + (list of QSslCertificate) """ self.chainLabel.show() self.chainComboBox.show() @@ -50,7 +51,8 @@ name = cert.subjectInfo(QSslCertificate.CommonName) if not name: if qVersion() >= "5.0.0": - name = ", ".join(cert.subjectInfo(QSslCertificate.Organization)) + name = ", ".join( + cert.subjectInfo(QSslCertificate.Organization)) else: name = cert.subjectInfo(QSslCertificate.Organization) if not name: @@ -88,45 +90,56 @@ if qVersion() >= "5.0.0": self.subjectCommonNameLabel.setText(self.__certificateString( - ", ".join(certificate.subjectInfo(QSslCertificate.CommonName)))) + ", ".join(certificate.subjectInfo( + QSslCertificate.CommonName)))) self.subjectOrganizationLabel.setText(self.__certificateString( - ", ".join(certificate.subjectInfo(QSslCertificate.Organization)))) - self.subjectOrganizationalUnitLabel.setText(self.__certificateString( - ", ".join( - certificate.subjectInfo(QSslCertificate.OrganizationalUnitName)))) + ", ".join(certificate.subjectInfo( + QSslCertificate.Organization)))) + self.subjectOrganizationalUnitLabel.setText( + self.__certificateString(", ".join( + certificate.subjectInfo( + QSslCertificate.OrganizationalUnitName)))) self.issuerCommonNameLabel.setText(self.__certificateString( ", ".join(certificate.issuerInfo(QSslCertificate.CommonName)))) self.issuerOrganizationLabel.setText(self.__certificateString( - ", ".join(certificate.issuerInfo(QSslCertificate.Organization)))) - self.issuerOrganizationalUnitLabel.setText(self.__certificateString( - ", ".join(certificate.issuerInfo(QSslCertificate.OrganizationalUnitName)))) + ", ".join(certificate.issuerInfo( + QSslCertificate.Organization)))) + self.issuerOrganizationalUnitLabel.setText( + self.__certificateString(", ".join( + certificate.issuerInfo( + QSslCertificate.OrganizationalUnitName)))) else: self.subjectCommonNameLabel.setText(self.__certificateString( certificate.subjectInfo(QSslCertificate.CommonName))) self.subjectOrganizationLabel.setText(self.__certificateString( certificate.subjectInfo(QSslCertificate.Organization))) - self.subjectOrganizationalUnitLabel.setText(self.__certificateString( - certificate.subjectInfo(QSslCertificate.OrganizationalUnitName))) + self.subjectOrganizationalUnitLabel.setText( + self.__certificateString(certificate.subjectInfo( + QSslCertificate.OrganizationalUnitName))) self.issuerCommonNameLabel.setText(self.__certificateString( certificate.issuerInfo(QSslCertificate.CommonName))) self.issuerOrganizationLabel.setText(self.__certificateString( certificate.issuerInfo(QSslCertificate.Organization))) - self.issuerOrganizationalUnitLabel.setText(self.__certificateString( - certificate.issuerInfo(QSslCertificate.OrganizationalUnitName))) + self.issuerOrganizationalUnitLabel.setText( + self.__certificateString(certificate.issuerInfo( + QSslCertificate.OrganizationalUnitName))) self.serialNumberLabel.setText(self.__serialNumber(certificate)) self.effectiveLabel.setText( certificate.effectiveDate().toString("yyyy-MM-dd")) self.expiresLabel.setText( certificate.expiryDate().toString("yyyy-MM-dd")) self.sha1Label.setText(self.__formatHexString( - str(certificate.digest(QCryptographicHash.Sha1).toHex(), encoding="ascii"))) + str(certificate.digest(QCryptographicHash.Sha1).toHex(), + encoding="ascii"))) self.md5Label.setText(self.__formatHexString( - str(certificate.digest(QCryptographicHash.Md5).toHex(), encoding="ascii"))) + str(certificate.digest(QCryptographicHash.Md5).toHex(), + encoding="ascii"))) if (qVersion() >= "5.0.0" and certificate.isBlacklisted()) or \ (qVersion() < "5.0.0" and not certificate.isValid()): # something is wrong; indicate it to the user - if self.__hasExpired(certificate.effectiveDate(), certificate.expiryDate()): + if self.__hasExpired(certificate.effectiveDate(), + certificate.expiryDate()): self.expiredLabel.setVisible(True) else: self.blacklistedLabel.setVisible(True) @@ -196,6 +209,7 @@ """ Private slot to show the certificate info for the selected entry. - @param index number of the certificate in the certificate chain (integer) + @param index number of the certificate in the certificate chain + (integer) """ self.__showCertificate(self.__chain[index])
--- a/E5Network/E5SslErrorHandler.py Sun Oct 06 19:14:26 2013 +0200 +++ b/E5Network/E5SslErrorHandler.py Sun Oct 06 19:45:29 2013 +0200 @@ -40,7 +40,7 @@ if Preferences.Prefs.settings.contains("Help/CaCertificatesDict"): # port old entries stored under 'Help' certificateDict = Preferences.toDict( - Preferences.Prefs.settings.value("Help/CaCertificatesDict")) + Preferences.Prefs.settings.value("Help/CaCertificatesDict")) Preferences.Prefs.settings.setValue("Ssl/CaCertificatesDict", certificateDict) Preferences.Prefs.settings.remove("Help/CaCertificatesDict") @@ -76,14 +76,15 @@ @param reply reference to the reply object (QNetworkReply) @param errors list of SSL errors (list of QSslError) @return tuple indicating to ignore the SSL errors (one of NotIgnored, - SystemIgnored or UserIgnored) and indicating a change of the default - SSL configuration (boolean) + SystemIgnored or UserIgnored) and indicating a change of the + default SSL configuration (boolean) """ url = reply.url() ignore, defaultChanged = self.sslErrors(errors, url.host(), url.port()) if ignore: if defaultChanged: - reply.setSslConfiguration(QSslConfiguration.defaultConfiguration()) + reply.setSslConfiguration( + QSslConfiguration.defaultConfiguration()) reply.ignoreSslErrors() else: reply.abort() @@ -98,14 +99,15 @@ @param server name of the server (string) @keyparam port value of the port (integer) @return tuple indicating to ignore the SSL errors (one of NotIgnored, - SystemIgnored or UserIgnored) and indicating a change of the default - SSL configuration (boolean) + SystemIgnored or UserIgnored) and indicating a change of the + default SSL configuration (boolean) """ caMerge = {} certificateDict = Preferences.toDict( Preferences.Prefs.settings.value("Ssl/CaCertificatesDict")) for caServer in certificateDict: - caMerge[caServer] = QSslCertificate.fromData(certificateDict[caServer]) + caMerge[caServer] = QSslCertificate.fromData( + certificateDict[caServer]) caNew = [] errorStrings = [] @@ -142,8 +144,10 @@ certinfos.append(self.__certToString(cert)) caRet = E5MessageBox.yesNo(None, self.trUtf8("Certificates"), - self.trUtf8("""<p>Certificates:<br/>{0}<br/>""" - """Do you want to accept all these certificates?</p>""")\ + self.trUtf8( + """<p>Certificates:<br/>{0}<br/>""" + """Do you want to accept all these certificates?""" + """</p>""")\ .format("".join(certinfos))) if caRet: if server not in caMerge: @@ -165,7 +169,8 @@ for cert in caMerge[server]: pems.append(cert.toPem() + '\n') certificateDict[server] = pems - Preferences.Prefs.settings.setValue("Ssl/CaCertificatesDict", + Preferences.Prefs.settings.setValue( + "Ssl/CaCertificatesDict", certificateDict) return E5SslErrorHandler.UserIgnored, caRet @@ -189,7 +194,8 @@ result += self.trUtf8("<br/>Organization: {0}")\ .format(Utilities.html_encode(Utilities.decodeString( - ", ".join(cert.subjectInfo(QSslCertificate.Organization))))) + ", ".join(cert.subjectInfo( + QSslCertificate.Organization))))) result += self.trUtf8("<br/>Issuer: {0}")\ .format(Utilities.html_encode(Utilities.decodeString( @@ -207,9 +213,12 @@ .format(Utilities.html_encode(Utilities.decodeString( cert.issuerInfo(QSslCertificate.CommonName)))) - result += self.trUtf8("<br/>Not valid before: {0}<br/>Valid Until: {1}")\ - .format(Utilities.html_encode(cert.effectiveDate().toString("yyyy-MM-dd")), - Utilities.html_encode(cert.expiryDate().toString("yyyy-MM-dd"))) + result += self.trUtf8( + "<br/>Not valid before: {0}<br/>Valid Until: {1}")\ + .format(Utilities.html_encode( + cert.effectiveDate().toString("yyyy-MM-dd")), + Utilities.html_encode( + cert.expiryDate().toString("yyyy-MM-dd"))) result += "</p>"
--- a/E5Network/E5SslInfoWidget.py Sun Oct 06 19:14:26 2013 +0200 +++ b/E5Network/E5SslInfoWidget.py Sun Oct 06 19:45:29 2013 +0200 @@ -63,8 +63,8 @@ label = QLabel(self) label.setWordWrap(True) if cert.isNull(): - label.setText( - self.trUtf8("Warning: this site is NOT carrying a certificate.")) + label.setText(self.trUtf8( + "Warning: this site is NOT carrying a certificate.")) imageLabel.setPixmap(UI.PixmapCache.getPixmap("securityLow32.png")) else: if qVersion() >= "5.0.0": @@ -73,16 +73,21 @@ valid = cert.isValid() if valid: if qVersion() >= "5.0.0": - txt = ", ".join(cert.issuerInfo(QSslCertificate.CommonName)) + txt = ", ".join( + cert.issuerInfo(QSslCertificate.CommonName)) else: txt = cert.issuerInfo(QSslCertificate.CommonName) - label.setText(self.trUtf8("The certificate for this site is valid" + label.setText(self.trUtf8( + "The certificate for this site is valid" " and has been verified by:\n{0}").format( Utilities.decodeString(txt))) - imageLabel.setPixmap(UI.PixmapCache.getPixmap("securityHigh32.png")) + imageLabel.setPixmap( + UI.PixmapCache.getPixmap("securityHigh32.png")) else: - label.setText(self.trUtf8("The certificate for this site is NOT valid.")) - imageLabel.setPixmap(UI.PixmapCache.getPixmap("securityLow32.png")) + label.setText(self.trUtf8( + "The certificate for this site is NOT valid.")) + imageLabel.setPixmap( + UI.PixmapCache.getPixmap("securityLow32.png")) layout.addWidget(label, rows, 1) rows += 1 @@ -130,21 +135,26 @@ proto = cipher.protocol() if proto == QSsl.SslV3: sslVersion = "SSL 3.0" - imageLabel.setPixmap(UI.PixmapCache.getPixmap("securityHigh32.png")) + imageLabel.setPixmap( + UI.PixmapCache.getPixmap("securityHigh32.png")) elif proto == QSsl.TlsV1: sslVersion = "TLS 1.0" - imageLabel.setPixmap(UI.PixmapCache.getPixmap("securityHigh32.png")) + imageLabel.setPixmap( + UI.PixmapCache.getPixmap("securityHigh32.png")) elif proto == QSsl.SslV2: sslVersion = "SSL 2.0" - imageLabel.setPixmap(UI.PixmapCache.getPixmap("securityLow32.png")) + imageLabel.setPixmap( + UI.PixmapCache.getPixmap("securityLow32.png")) else: sslVersion = self.trUtf8("unknown") - imageLabel.setPixmap(UI.PixmapCache.getPixmap("securityLow32.png")) + imageLabel.setPixmap( + UI.PixmapCache.getPixmap("securityLow32.png")) rows += 1 label = QLabel(self) label.setWordWrap(True) - label.setText(self.trUtf8("It uses protocol: {0}").format(sslVersion)) + label.setText(self.trUtf8( + "It uses protocol: {0}").format(sslVersion)) layout.addWidget(label, rows, 1) rows += 1 @@ -180,7 +190,8 @@ Private slot to show certificate information. """ from .E5SslCertificatesInfoDialog import E5SslCertificatesInfoDialog - dlg = E5SslCertificatesInfoDialog(self.__configuration.peerCertificateChain()) + dlg = E5SslCertificatesInfoDialog( + self.__configuration.peerCertificateChain()) dlg.exec_() def accept(self):