diff -r 9986ec0e559a -r 10516539f238 Graphics/UMLDialog.py --- a/Graphics/UMLDialog.py Tue Oct 15 22:03:54 2013 +0200 +++ b/Graphics/UMLDialog.py Fri Oct 18 23:00:41 2013 +0200 @@ -31,18 +31,19 @@ FileVersions = ["1.0"] - def __init__(self, diagramType, project, path="", parent=None, initBuilder=True, - **kwargs): + def __init__(self, diagramType, project, path="", parent=None, + initBuilder=True, **kwargs): """ Constructor - @param diagramType type of the diagram (one of ApplicationDiagram, ClassDiagram, - ImportsDiagram, NoDiagram, PackageDiagram) + @param diagramType type of the diagram (one of ApplicationDiagram, + ClassDiagram, ImportsDiagram, NoDiagram, PackageDiagram) @param project reference to the project object (Project) @param path file or directory path to build the diagram from (string) @param parent parent widget of the dialog (QWidget) - @keyparam initBuilder flag indicating to initialize the diagram builder (boolean) - @param kwargs diagram specific data + @keyparam initBuilder flag indicating to initialize the diagram + builder (boolean) + @keyparam kwargs diagram specific data """ super(UMLDialog, self).__init__(parent) self.setObjectName("UMLDialog") @@ -53,7 +54,8 @@ from .UMLGraphicsView import UMLGraphicsView self.scene = QGraphicsScene(0.0, 0.0, 800.0, 600.0) self.umlView = UMLGraphicsView(self.scene, parent=self) - self.builder = self.__diagramBuilder(self.__diagramType, path, **kwargs) + self.builder = self.__diagramBuilder( + self.__diagramType, path, **kwargs) if self.builder and initBuilder: self.builder.initialize() @@ -105,7 +107,8 @@ self.printPreviewAct = \ QAction(UI.PixmapCache.getIcon("printPreview.png"), self.trUtf8("Print Preview"), self) - self.printPreviewAct.triggered[()].connect(self.umlView.printPreviewDiagram) + self.printPreviewAct.triggered[()].connect( + self.umlView.printPreviewDiagram) def __initToolBars(self): """ @@ -155,31 +158,34 @@ Private method to instantiate a diagram builder object. @param diagramType type of the diagram - (one of ApplicationDiagram, ClassDiagram, ImportsDiagram, PackageDiagram) + (one of ApplicationDiagram, ClassDiagram, ImportsDiagram, + PackageDiagram) @param path file or directory path to build the diagram from (string) - @param kwargs diagram specific data + @keyparam kwargs diagram specific data + @return reference to the instantiated diagram builder + @exception ValueError raised to indicate an illegal diagram type """ if diagramType == UMLDialog.ClassDiagram: from .UMLClassDiagramBuilder import UMLClassDiagramBuilder - return UMLClassDiagramBuilder(self, self.umlView, self.__project, path, - **kwargs) + return UMLClassDiagramBuilder( + self, self.umlView, self.__project, path, **kwargs) elif diagramType == UMLDialog.PackageDiagram: from .PackageDiagramBuilder import PackageDiagramBuilder - return PackageDiagramBuilder(self, self.umlView, self.__project, path, - **kwargs) + return PackageDiagramBuilder( + self, self.umlView, self.__project, path, **kwargs) elif diagramType == UMLDialog.ImportsDiagram: from .ImportsDiagramBuilder import ImportsDiagramBuilder - return ImportsDiagramBuilder(self, self.umlView, self.__project, path, - **kwargs) + return ImportsDiagramBuilder( + self, self.umlView, self.__project, path, **kwargs) elif diagramType == UMLDialog.ApplicationDiagram: from .ApplicationDiagramBuilder import ApplicationDiagramBuilder - return ApplicationDiagramBuilder(self, self.umlView, self.__project, - **kwargs) + return ApplicationDiagramBuilder( + self, self.umlView, self.__project, **kwargs) elif diagramType == UMLDialog.NoDiagram: return None else: - raise ValueError( - self.trUtf8("Illegal diagram type '{0}' given.").format(diagramType)) + raise ValueError(self.trUtf8( + "Illegal diagram type '{0}' given.").format(diagramType)) def __diagramTypeString(self): """ @@ -239,7 +245,8 @@ "version: 1.0", "diagram_type: {0} ({1})".format(self.__diagramType, self.__diagramTypeString()), - "scene_size: {0};{1}".format(self.scene.width(), self.scene.height()), + "scene_size: {0};{1}".format(self.scene.width(), + self.scene.height()), ] persistenceData = self.builder.getPersistenceData() if persistenceData: @@ -253,8 +260,9 @@ except (IOError, OSError) as err: E5MessageBox.critical(self, self.trUtf8("Save Diagram"), - self.trUtf8("""<p>The file <b>{0}</b> could not be saved.</p>""" - """<p>Reason: {1}</p>""").format(filename, str(err))) + self.trUtf8( + """<p>The file <b>{0}</b> could not be saved.</p>""" + """<p>Reason: {1}</p>""").format(filename, str(err))) return self.__fileName = filename @@ -281,8 +289,9 @@ except (IOError, OSError) as err: E5MessageBox.critical(self, self.trUtf8("Load Diagram"), - self.trUtf8("""<p>The file <b>{0}</b> could not be read.</p>""" - """<p>Reason: {1}</p>""").format(filename, str(err))) + self.trUtf8( + """<p>The file <b>{0}</b> could not be read.</p>""" + """<p>Reason: {1}</p>""").format(filename, str(err))) return False lines = data.splitlines() @@ -294,7 +303,8 @@ # step 1: check version linenum = 0 key, value = lines[linenum].split(": ", 1) - if key.strip() != "version" or value.strip() not in UMLDialog.FileVersions: + if key.strip() != "version" or \ + value.strip() not in UMLDialog.FileVersions: self.__showInvalidDataMessage(filename, linenum) return False else: @@ -338,7 +348,8 @@ linenum += 1 # step 5: extract the graphics items - ok, vlinenum = self.umlView.parsePersistenceData(version, lines[linenum:]) + ok, vlinenum = self.umlView.parsePersistenceData( + version, lines[linenum:]) if not ok: self.__showInvalidDataMessage(filename, linenum + vlinenum) return False