eric6/Graphics/PackageDiagramBuilder.py

branch
maintenance
changeset 8273
698ae46f40a4
parent 8043
0acf98cd089a
parent 8270
6ba3564b7161
child 8400
b3eefd7e58d1
--- a/eric6/Graphics/PackageDiagramBuilder.py	Fri Apr 02 11:59:41 2021 +0200
+++ b/eric6/Graphics/PackageDiagramBuilder.py	Sat May 01 14:27:20 2021 +0200
@@ -36,7 +36,7 @@
         @param noAttrs flag indicating, that no attributes should be shown
             (boolean)
         """
-        super(PackageDiagramBuilder, self).__init__(dialog, view, project)
+        super().__init__(dialog, view, project)
         self.setObjectName("PackageDiagram")
         
         self.package = os.path.abspath(package)
@@ -47,11 +47,12 @@
         Public method to initialize the object.
         """
         pname = self.project.getProjectName()
-        if pname:
-            name = self.tr("Package Diagram {0}: {1}").format(
+        name = (
+            self.tr("Package Diagram {0}: {1}").format(
                 pname, self.project.getRelativePath(self.package))
-        else:
-            name = self.tr("Package Diagram: {0}").format(self.package)
+            if pname else
+            self.tr("Package Diagram: {0}").format(self.package)
+        )
         self.umlView.setDiagramName(name)
     
     def __getCurrentShape(self, name):
@@ -93,14 +94,12 @@
             None, 0, tot, self.tr("%v/%m Modules"), self.parent())
         progress.setWindowTitle(self.tr("Package Diagram"))
         try:
-            prog = 0
             progress.show()
             QApplication.processEvents()
             
-            for module in modules:
+            for prog, module in enumerate(modules):
                 progress.setValue(prog)
                 QApplication.processEvents()
-                prog += 1
                 try:
                     mod = Utilities.ModuleParser.readModule(
                         module, extensions=extensions, caching=False)
@@ -158,7 +157,6 @@
             None, 0, tot, self.tr("%v/%m Modules"), self.parent())
         progress.setWindowTitle(self.tr("Package Diagram"))
         try:
-            prog = 0
             progress.show()
             QApplication.processEvents()
             
@@ -169,10 +167,9 @@
                 for ext in supportedExt:
                     modules.extend(glob.glob(
                         Utilities.normjoinpath(subpackage, ext)))
-                for module in modules:
+                for prog, module in enumerate(modules):
                     progress.setValue(prog)
                     QApplication.processEvents()
-                    prog += 1
                     try:
                         mod = Utilities.ModuleParser.readModule(
                             module, extensions=extensions, caching=False)
@@ -328,19 +325,19 @@
             for rect in generation:
                 if rect.bottom() > currentHeight:
                     currentHeight = rect.bottom()
-                currentWidth = currentWidth + rect.right()
+                currentWidth += rect.right()
                 
             # update totals
             if currentWidth > width:
                 width = currentWidth
-            height = height + currentHeight
+            height += currentHeight
             
             # store generation info
             widths.append(currentWidth)
             heights.append(currentHeight)
             
         # add in some whitespace
-        width = width * whiteSpaceFactor
+        width *= whiteSpaceFactor
         height = height * whiteSpaceFactor - 20
         verticalWhiteSpace = 40.0
         
@@ -433,13 +430,13 @@
         
         @param routes list of relationsships
         """
-        from .AssociationItem import AssociationItem, Generalisation
+        from .AssociationItem import AssociationItem, AssociationType
         for route in routes:
             if len(route) > 1:
                 assoc = AssociationItem(
                     self.__getCurrentShape(route[1]),
                     self.__getCurrentShape(route[0]),
-                    Generalisation,
+                    AssociationType.GENERALISATION,
                     topToBottom=True,
                     colors=self.umlView.getDrawingColors())
                 self.scene.addItem(assoc)

eric ide

mercurial