Graphics/PackageDiagramBuilder.py

branch
Py2 comp.
changeset 3057
10516539f238
parent 2602
affc66a603c7
parent 2997
7f0ef975da9e
child 3058
0a02c433f52d
--- a/Graphics/PackageDiagramBuilder.py	Tue Oct 15 22:03:54 2013 +0200
+++ b/Graphics/PackageDiagramBuilder.py	Fri Oct 18 23:00:41 2013 +0200
@@ -36,7 +36,8 @@
         @param view reference to the view object (UMLGraphicsView)
         @param project reference to the project object (Project)
         @param package name of a python package to be shown (string)
-        @keyparam noAttrs flag indicating, that no attributes should be shown (boolean)
+        @keyparam noAttrs flag indicating, that no attributes should be shown
+            (boolean)
         """
         super(PackageDiagramBuilder, self).__init__(dialog, view, project)
         self.setObjectName("PackageDiagram")
@@ -67,15 +68,18 @@
     
     def __buildModulesDict(self):
         """
-        Private method to build a dictionary of modules contained in the package.
+        Private method to build a dictionary of modules contained in the
+        package.
         
         @return dictionary of modules contained in the package.
         """
         import Utilities.ModuleParser
         
         supportedExt = \
-            ['*{0}'.format(ext) for ext in Preferences.getPython("PythonExtensions")] + \
-            ['*{0}'.format(ext) for ext in Preferences.getPython("Python3Extensions")] + \
+            ['*{0}'.format(ext) for ext in 
+             Preferences.getPython("PythonExtensions")] + \
+            ['*{0}'.format(ext) for ext in 
+             Preferences.getPython("Python3Extensions")] + \
             ['*.rb']
         extensions = Preferences.getPython("PythonExtensions") + \
             Preferences.getPython("Python3Extensions") + ['.rb']
@@ -83,7 +87,8 @@
         moduleDict = {}
         modules = []
         for ext in supportedExt:
-            modules.extend(glob.glob(Utilities.normjoinpath(self.package, ext)))
+            modules.extend(glob.glob(
+                Utilities.normjoinpath(self.package, ext)))
         tot = len(modules)
         try:
             prog = 0
@@ -97,8 +102,8 @@
                 QApplication.processEvents()
                 prog += 1
                 try:
-                    mod = Utilities.ModuleParser.readModule(module, extensions=extensions,
-                                                            caching=False)
+                    mod = Utilities.ModuleParser.readModule(
+                        module, extensions=extensions, caching=False)
                 except ImportError:
                     continue
                 else:
@@ -113,15 +118,18 @@
     
     def __buildSubpackagesDict(self):
         """
-        Private method to build a dictionary of sub-packages contained in this package.
+        Private method to build a dictionary of sub-packages contained in this
+        package.
         
         @return dictionary of sub-packages contained in this package
         """
         import Utilities.ModuleParser
         
         supportedExt = \
-            ['*{0}'.format(ext) for ext in Preferences.getPython("PythonExtensions")] + \
-            ['*{0}'.format(ext) for ext in Preferences.getPython("Python3Extensions")] + \
+            ['*{0}'.format(ext) for ext in 
+             Preferences.getPython("PythonExtensions")] + \
+            ['*{0}'.format(ext) for ext in 
+             Preferences.getPython("Python3Extensions")] + \
             ['*.rb']
         extensions = Preferences.getPython("PythonExtensions") + \
             Preferences.getPython("Python3Extensions") + ['.rb']
@@ -152,7 +160,8 @@
                 subpackagesDict[packageName] = []
                 modules = []
                 for ext in supportedExt:
-                    modules.extend(glob.glob(Utilities.normjoinpath(subpackage, ext)))
+                    modules.extend(glob.glob(
+                        Utilities.normjoinpath(subpackage, ext)))
                 for module in modules:
                     progress.setValue(prog)
                     QApplication.processEvents()
@@ -197,7 +206,8 @@
         if not modules:
             ct = QGraphicsTextItem(None, self.scene)
             ct.setHtml(
-                self.trUtf8("The package <b>'{0}'</b> does not contain any modules.")
+                self.trUtf8(
+                    "The package <b>'{0}'</b> does not contain any modules.")
                     .format(self.package))
             return
             
@@ -212,7 +222,8 @@
         if not classesFound:
             ct = QGraphicsTextItem(None, self.scene)
             ct.setHtml(
-                self.trUtf8("The package <b>'{0}'</b> does not contain any classes.")
+                self.trUtf8(
+                    "The package <b>'{0}'</b> does not contain any classes.")
                     .format(self.package))
             return
         
@@ -242,12 +253,14 @@
                     else:
                         if className in module.classes:
                             # this is a local class (defined in this module)
-                            self.__addLocalClass(className, module.classes[className],
-                                                 0, 0)
+                            self.__addLocalClass(
+                                className, module.classes[className],
+                                0, 0)
                         elif className in module.modules:
                             # this is a local module (defined in this module)
-                            self.__addLocalClass(className, module.modules[className],
-                                                 0, 0, True)
+                            self.__addLocalClass(
+                                className, module.modules[className],
+                                0, 0, True)
                         else:
                             self.__addExternalClass(className, 0, 0)
                         nodes.append(className)
@@ -276,6 +289,11 @@
         Private method to arrange the shapes on the canvas.
         
         The algorithm is borrowed from Boa Constructor.
+        
+        @param nodes list of nodes to arrange
+        @param routes list of routes
+        @param whiteSpaceFactor factor to increase whitespace between
+            items (float)
         """
         from . import GraphicsUtilities
         generations = GraphicsUtilities.sort(nodes, routes)
@@ -285,7 +303,8 @@
         for generation in generations:
             sizes.append([])
             for child in generation:
-                sizes[-1].append(self.__getCurrentShape(child).sceneBoundingRect())
+                sizes[-1].append(
+                    self.__getCurrentShape(child).sceneBoundingRect())
                 
         # calculate total width and total height
         width = 0
@@ -334,7 +353,8 @@
                 zip_longest(widths, heights, generations):
             x = 10.0
             # whiteSpace is the space between any two elements
-            whiteSpace = (width - currentWidth - 20) / (len(generation) - 1.0 or 2.0)
+            whiteSpace = (width - currentWidth - 20) / \
+                (len(generation) - 1.0 or 2.0)
             for className in generation:
                 cw = self.__getCurrentShape(className)
                 cw.setPos(x, y)
@@ -418,7 +438,8 @@
         
         @return persisted data string (string)
         """
-        return "package={0}, no_attributes={1}".format(self.package, self.noAttrs)
+        return "package={0}, no_attributes={1}".format(
+            self.package, self.noAttrs)
     
     def parsePersistenceData(self, version, data):
         """

eric ide

mercurial