Jon Olav Vik avatar Jon Olav Vik committed fc1db93

Avoid re-importing modules.

Comments (0)

Files changed (1)


         for cls in classes:
-        return all_classes.values()
+        return all_classes
     def class_name(self, cls, parts=0):
         """Given a class object, return a fully-qualified name.
     def get_all_class_names(self):
         """Get all of the class names involved in the graph."""
-        return [fullname for (_, fullname, _) in self.class_info]
+        return [fullname for (_, fullname, _) in self.class_info.values()]
     # These are the default attrs for graphviz
     default_graph_attrs = {
         'shape': 'box',
         'fontsize': 10,
         'height': 0.25,
-        'fontname': 'Vera Sans, DejaVu Sans, Liberation Sans, '
-                    'Arial, Helvetica, sans',
+        'fontname': '"Vera Sans, DejaVu Sans, Liberation Sans, '
+                    'Arial, Helvetica, sans"',
         'style': '"setlinewidth(0.5)"',
     default_edge_attrs = {
         res.append('digraph %s {\n' % name)
-        for name, fullname, bases in self.class_info:
+        for cls, (name, fullname, bases) in self.class_info.items():
             # Write the node
             this_node_attrs = n_attrs.copy()
-            url = urls.get(fullname)
-            if url is not None:
-                this_node_attrs['URL'] = '"%s"' % url
-            # Use first line of docstring as tooltip
-            modulename, classname = fullname.rsplit(".", 1)
-            module = __import__(modulename, fromlist=[classname])
-            cls = module.__dict__[classname]
-            doc = inspect.getdoc(cls)
-            if doc:
-                this_node_attrs['tooltip'] = '"%s"' % doc.split("\n")[0]
+            if fullname in urls:
+                this_node_attrs['URL'] = '"%s"' % urls[fullname]
+            # Use first line of docstring as tooltip, if available
+            if cls.__doc__:
+                doc = cls.__doc__.strip().split("\n")[0]
+                if doc:
+                    this_node_attrs['tooltip'] = '"%s"' % doc
             res.append('  "%s" [%s];\n' %
                        (name, self._format_node_attrs(this_node_attrs)))
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.