You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gump.apache.org by bo...@apache.org on 2010/08/11 06:46:15 UTC

svn commit: r984302 - in /gump/trunk/python/gump: core/model/project.py tool/dot/ tool/dot/__init__.py tool/dot/dot.py

Author: bodewig
Date: Wed Aug 11 04:46:15 2010
New Revision: 984302

URL: http://svn.apache.org/viewvc?rev=984302&view=rev
Log:
a tool to create a DOT  dependency graph of a workspace

Added:
    gump/trunk/python/gump/tool/dot/
    gump/trunk/python/gump/tool/dot/__init__.py   (with props)
    gump/trunk/python/gump/tool/dot/dot.py   (with props)
Modified:
    gump/trunk/python/gump/core/model/project.py

Modified: gump/trunk/python/gump/core/model/project.py
URL: http://svn.apache.org/viewvc/gump/trunk/python/gump/core/model/project.py?rev=984302&r1=984301&r2=984302&view=diff
==============================================================================
--- gump/trunk/python/gump/core/model/project.py (original)
+++ gump/trunk/python/gump/core/model/project.py Wed Aug 11 04:46:15 2010
@@ -117,6 +117,9 @@ class Project(NamedModelObject, Statable
         self.honoraryPackage = False
         self.built = False
 
+        # removed dependencies
+        self.removes = []
+
     def __del__(self):
         NamedModelObject.__del__(self)
         Statable.__del__(self)
@@ -610,7 +613,7 @@ class Project(NamedModelObject, Statable
         [b.expand(self, workspace) for b in self.builder]
 
         if not packaged:
-            removes = []
+            self.removes = []
 
             # Complete dependencies so properties can reference the, 
             # completed metadata within a dependent project
@@ -629,7 +632,7 @@ class Project(NamedModelObject, Statable
                                       "on %s from %s." % \
                                       (depProject.getName(), self.getName()))
 
-                    removes.append(dependency)
+                    self.removes.append(dependency)
                 else:
                     # Don't redo what is done.
                     if not depProject.isComplete():
@@ -638,7 +641,7 @@ class Project(NamedModelObject, Statable
                         depProject.complete(workspace, new_visited)
 
             # Remove circulars...
-            for dependency in removes:
+            for dependency in self.removes:
                 self.removeDependency(dependency)
 
             self.buildDependenciesMap(workspace)
@@ -746,6 +749,13 @@ class Project(NamedModelObject, Statable
 
         return (badDepends, badOptions)
 
+    def get_removed_dependencies(self):
+        """
+        ProjectDependencies that have been removed in order to break
+        circular dependencies.
+        """
+        return self.removes
+
     def hasBaseDirectory(self):
         if self.basedir:
             return True

Added: gump/trunk/python/gump/tool/dot/__init__.py
URL: http://svn.apache.org/viewvc/gump/trunk/python/gump/tool/dot/__init__.py?rev=984302&view=auto
==============================================================================
--- gump/trunk/python/gump/tool/dot/__init__.py (added)
+++ gump/trunk/python/gump/tool/dot/__init__.py Wed Aug 11 04:46:15 2010
@@ -0,0 +1,18 @@
+#!/usr/bin/env python
+
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+# 
+#     http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+__all__ = ["dot"]

Propchange: gump/trunk/python/gump/tool/dot/__init__.py
------------------------------------------------------------------------------
    svn:eol-style = native

Added: gump/trunk/python/gump/tool/dot/dot.py
URL: http://svn.apache.org/viewvc/gump/trunk/python/gump/tool/dot/dot.py?rev=984302&view=auto
==============================================================================
--- gump/trunk/python/gump/tool/dot/dot.py (added)
+++ gump/trunk/python/gump/tool/dot/dot.py Wed Aug 11 04:46:15 2010
@@ -0,0 +1,45 @@
+#!/usr/bin/env python
+
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+# 
+#     http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import sys
+from gump.core.config import default
+from gump.core.loader.loader import WorkspaceLoader
+from gump.core.run.gumpset import GumpSet
+
+def write_to_dot_file(gump_set, dot_file_name):
+    """
+    Writes a dependency graph for the given GumpSet to the named file
+    using the DOT language.
+    """
+    dot = open(dot_file_name, "w")
+    dot.write("digraph {\n")
+    for project in gump_set.getProjects():
+        for dep in project.getDirectDependencies():
+            dot.write('\t"%s" -> "%s"\n' % (project.getName(),
+                                            dep.getProject().getName()))
+        for dep in project.get_removed_dependencies():
+            dot.write('\t"%s" -> "%s" [color = red]\n' %
+                      (project.getName(), dep.getProject().getName()))
+    dot.write("}\n")
+
+if __name__ == '__main__':
+    if len(sys.argv) != 3:
+        print "requires exactly two args: worksapce and outputfile"
+        exit(1)
+    default.date_s = default.datetime.strftime('YYYYMMDD')
+    WORKSPACE = WorkspaceLoader().load(sys.argv[1])
+    write_to_dot_file(GumpSet(WORKSPACE), sys.argv[2])

Propchange: gump/trunk/python/gump/tool/dot/dot.py
------------------------------------------------------------------------------
    svn:eol-style = native