Graphics/ImportsDiagramBuilder.py

branch
Py2 comp.
changeset 3057
10516539f238
parent 2525
8b507a9a2d40
parent 2992
dbdf27746da5
child 3058
0a02c433f52d
--- a/Graphics/ImportsDiagramBuilder.py	Tue Oct 15 22:03:54 2013 +0200
+++ b/Graphics/ImportsDiagramBuilder.py	Fri Oct 18 23:00:41 2013 +0200
@@ -27,7 +27,8 @@
     Note: Only package internal imports are shown in order to maintain
     some readability.
     """
-    def __init__(self, dialog, view, project, package, showExternalImports=False):
+    def __init__(self, dialog, view, project, package,
+                 showExternalImports=False):
         """
         Constructor
         
@@ -36,8 +37,8 @@
         @param project reference to the project object (Project)
         @param package name of a python package to show the import
             relationships (string)
-        @keyparam showExternalImports flag indicating to show exports from outside
-            the package (boolean)
+        @keyparam showExternalImports flag indicating to show exports from
+            outside the package (boolean)
         """
         super(ImportsDiagramBuilder, self).__init__(dialog, view, project)
         self.setObjectName("ImportsDiagram")
@@ -49,25 +50,29 @@
         """
         Public method to initialize the object.
         """
-        self.package = os.path.splitdrive(self.packagePath)[1].replace(os.sep, '.')[1:]
+        self.package = os.path.splitdrive(self.packagePath)[1].replace(
+            os.sep, '.')[1:]
         hasInit = True
         ppath = self.packagePath
         while hasInit:
             ppath = os.path.dirname(ppath)
             hasInit = len(glob.glob(os.path.join(ppath, '__init__.*'))) > 0
-        self.shortPackage = self.packagePath.replace(ppath, '').replace(os.sep, '.')[1:]
+        self.shortPackage = self.packagePath.replace(ppath, '').replace(
+            os.sep, '.')[1:]
         
         pname = self.project.getProjectName()
         if pname:
             name = self.trUtf8("Imports Diagramm {0}: {1}").format(
                 pname, self.project.getRelativePath(self.packagePath))
         else:
-            name = self.trUtf8("Imports Diagramm: {0}").format(self.packagePath)
+            name = self.trUtf8("Imports Diagramm: {0}").format(
+                self.packagePath)
         self.umlView.setDiagramName(name)
     
     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.
         """
@@ -78,8 +83,8 @@
         modules = []
         for ext in Preferences.getPython("PythonExtensions") + \
                     Preferences.getPython("Python3Extensions"):
-            modules.extend(
-                glob.glob(Utilities.normjoinpath(self.packagePath, '*{0}'.format(ext))))
+            modules.extend(glob.glob(Utilities.normjoinpath(
+                self.packagePath, '*{0}'.format(ext))))
         
         tot = len(modules)
         try:
@@ -93,8 +98,8 @@
                 QApplication.processEvents()
                 prog = 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:
@@ -115,7 +120,8 @@
         if len(initlist) == 0:
             ct = QGraphicsTextItem(None)
             ct.setHtml(
-                self.trUtf8("The directory <b>'{0}'</b> is not a Python package.")\
+                self.trUtf8(
+                    "The directory <b>'{0}'</b> is not a Python package.")
                     .format(self.package))
             self.scene.addItem(ct)
             return
@@ -153,7 +159,8 @@
                     else:
                         if self.showExternalImports:
                             n = '.'.join(
-                                packageList[:packageListLen - dots + 1] + [i[dots:]])
+                                packageList[:packageListLen - dots + 1] +
+                                [i[dots:]])
                         else:
                             n = i
                 elif i.startswith(self.package):
@@ -222,6 +229,7 @@
             (list of strings)
         @param x x-coordinate (float)
         @param y y-coordinate (float)
+        @return reference to the imports item (ModuleItem)
         """
         from .ModuleItem import ModuleItem, ModuleModel
         classes.sort()
@@ -268,7 +276,8 @@
             return False
         
         self.packagePath = parts[0].split("=", 1)[1].strip()
-        self.showExternalImports = Utilities.toBool(parts[1].split("=", 1)[1].strip())
+        self.showExternalImports = Utilities.toBool(
+            parts[1].split("=", 1)[1].strip())
         
         self.initialize()
         

eric ide

mercurial