gump-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From leosim...@apache.org
Subject svn commit: r161609 - in gump/branches/Gump3/pygump/python/gump: engine/modeller.py model/__init__.py test/testModel.py
Date Sat, 16 Apr 2005 21:35:35 GMT
Author: leosimons
Date: Sat Apr 16 14:35:34 2005
New Revision: 161609

URL: http://svn.apache.org/viewcvs?view=rev&rev=161609
Log:
Use one Dependency object as the only vertex between two projects.

* pygump/python/gump/model/__init__.py,
  pygump/python/gump/engine/modeller.py,
  pygump/python/gump/test/testModel.py:
    The previous arrangement where multiple dependencies from one project to the same other
project resulted in multiple Dependency objects was bad bad bad. Change things so that only
one Dependency object is created in that case, and introduce a new DependencyInfo object to
hold the additional information regarding that relationship that we previously stored inside
Dependency directly.

Modified:
    gump/branches/Gump3/pygump/python/gump/engine/modeller.py
    gump/branches/Gump3/pygump/python/gump/model/__init__.py
    gump/branches/Gump3/pygump/python/gump/test/testModel.py

Modified: gump/branches/Gump3/pygump/python/gump/engine/modeller.py
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/python/gump/engine/modeller.py?view=diff&r1=161608&r2=161609
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/engine/modeller.py (original)
+++ gump/branches/Gump3/pygump/python/gump/engine/modeller.py Sat Apr 16 14:35:34 2005
@@ -984,8 +984,9 @@
             dependency_project = dependency_name
         
         id = dependency.getAttribute("id")
-        new_dependency = Dependency(dependency_project,project,optional,runtime,inherit,id)
-        project.add_dependency(Dependency(dependency_project,project,optional,runtime,inherit,id))
+        
+        relationship = project.get_dependency_on_project(dependency_project)
+        relationship.add_dependency_info(DependencyInfo(relationship,optional,runtime,inherit,id))
 
 
 class VerificationError(ModellerError):

Modified: gump/branches/Gump3/pygump/python/gump/model/__init__.py
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/python/gump/model/__init__.py?view=diff&r1=161608&r2=161609
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/model/__init__.py (original)
+++ gump/branches/Gump3/pygump/python/gump/model/__init__.py Sat Apr 16 14:35:34 2005
@@ -298,6 +298,22 @@
                                                             # dependency
             relationship.dependency.add_dependee(relationship)
     
+    def get_dependency_on_project(self, dependency):
+        """Retrieve the relationship object for this dependency.
+        
+        If this project already has a declared relationship with the project
+        specified as the dependency argument, return that relationship. If not,
+        create a new relationship object, add it to "self", then return it."""
+        assert isinstance(dependency, Project)
+        
+        for relationship in self.dependencies:
+            if relationship.dependency == dependency:
+                return relationship
+        
+        new_relationship = Dependency(dependency,self)
+        self.add_dependency(new_relationship)
+        return new_relationship
+    
     def add_dependee(self, relationship):
         #print "%s is told that %s is a dependee of %s" % (self.name, relationship.dependee.name,
self.name)
         self.dependees.append(relationship)
@@ -321,16 +337,6 @@
 DEPENDENCY_INHERIT_COPY_OUTPUTS  = "copy-outputs"
 DEPENDENCY_INHERIT_JARS          = DEPENDENCY_INHERIT_COPY_OUTPUTS
 
-# TODO currently the model is one project has many dependencies which may be
-# further specified by output id, meaning a project can have multiple
-# dependencies with a different id but on the same project. This potentially
-# leads to a big performance hit on the graphing code and the like. Maybe it
-# is a better idea to have multiple (optional,runtime,inherit,id) pairs
-# associated with a (dependency,dependee) pair. Might rename "dependency" to
-# "relationship" and call "(optional,runtime,inherit,id)" the "dependency".
-#
-# That would mean a mismatch between object model and xml model that's a little
-# bigger than what we have now. Hmm.
 class Dependency(ModelObject):
     """Model a dependency.
     
@@ -344,6 +350,35 @@
                         it doesn't actually exist (ie that's an error
                         condition).
         - dependee -- the project that is depending on the other project
+        - dependencyInfo -- an array of DependencyInfo objects further
+                            qualifying this dependency
+    """
+    def __init__(self,
+                 dependency,
+                 dependee,
+                 dependencyInfo = []):
+        assert isinstance(dependency, Project)
+        assert isinstance(dependee, Project)
+        for info in dependencyInfo:
+            assert isinstance(info, DependencyInfo)
+        self.dependency         = dependency
+        self.dependee           = dependee
+        self.dependencyInfo     = dependencyInfo
+    
+    def add_dependency_info(self, info):
+        assert isinstance(info, DependencyInfo)
+        self.dependencyInfo.append(info)
+
+class DependencyInfo(ModelObject):
+    """Model information about a particular dependency.
+    
+    DependencyInfo objects are used to describe additional information about
+    a dependency besides just what projects relate to each other. Each
+    Dependency can have multiple DependencyInfo objects associated with it
+    detailing exactly what is depended on in the dependency.
+    
+    Has the following properties:
+        - dependency -- the Dependency instance this info is associated with
         - optional   -- flag indicating whether the dependee can be built and
                         used if this dependency cannot be satisfied
         - runtime    -- flag indicating whether the dependee needs this
@@ -355,15 +390,12 @@
     """
     def __init__(self,
                  dependency,
-                 dependee,
                  optional = False,
                  runtime  = False,
                  inherit  = DEPENDENCY_INHERIT_NONE,
                  specific_output_id = None):
-        assert isinstance(dependency, Project)
-        assert isinstance(dependee, Project)
+        assert isinstance(dependency, Dependency)
         self.dependency         = dependency
-        self.dependee           = dependee
         self.optional           = optional
         self.runtime            = runtime
         self.inherit            = inherit

Modified: gump/branches/Gump3/pygump/python/gump/test/testModel.py
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/python/gump/test/testModel.py?view=diff&r1=161608&r2=161609
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/test/testModel.py (original)
+++ gump/branches/Gump3/pygump/python/gump/test/testModel.py Sat Apr 16 14:35:34 2005
@@ -423,31 +423,32 @@
         self.assertEqual(2,len(c.dependencies))
         self.assertEqual(0,len(c.dependees))
         
-        optional = True
-        runtime = True
-        inherit = DEPENDENCY_INHERIT_ALL
-        specific_output_id = "some-sub-project-jar"
-        d = Dependency(c,b,optional,runtime,inherit,specific_output_id)
-        self.assertEqual(c,d.dependency)
-        self.assertEqual(b,d.dependee)
-        self.assertEqual(optional,d.optional)
-        self.assertEqual(inherit,d.inherit)
-        self.assertEqual(specific_output_id,d.specific_output_id)
+        # TODO: test DependencyInfo
+        #optional = True
+        #runtime = True
+        #inherit = DEPENDENCY_INHERIT_ALL
+        #specific_output_id = "some-sub-project-jar"
+        #d = Dependency(c,b,optional,runtime,inherit,specific_output_id)
+        #self.assertEqual(c,d.dependency)
+        #self.assertEqual(b,d.dependee)
+        #self.assertEqual(optional,d.optional)
+        #self.assertEqual(inherit,d.inherit)
+        #self.assertEqual(specific_output_id,d.specific_output_id)
         
-        d = Dependency(dependency=c,dependee=b,optional=False)
-        self.assertEqual(c,d.dependency)
-        self.assertEqual(b,d.dependee)
-        self.assertEqual(False,d.optional)
+        #d = Dependency(dependency=c,dependee=b,optional=False)
+        #self.assertEqual(c,d.dependency)
+        #self.assertEqual(b,d.dependee)
+        #self.assertEqual(False,d.optional)
         
-        d = Dependency(dependency=c,dependee=b,inherit=False)
-        self.assertEqual(c,d.dependency)
-        self.assertEqual(b,d.dependee)
-        self.assertEqual(False,d.inherit)
+        #d = Dependency(dependency=c,dependee=b,inherit=False)
+        #self.assertEqual(c,d.dependency)
+        #self.assertEqual(b,d.dependee)
+        #self.assertEqual(False,d.inherit)
         
-        d = Dependency(dependency=c,dependee=b,specific_output_id="blah")
-        self.assertEqual(c,d.dependency)
-        self.assertEqual(b,d.dependee)
-        self.assertEqual("blah",d.specific_output_id)
+        #d = Dependency(dependency=c,dependee=b,specific_output_id="blah")
+        #self.assertEqual(c,d.dependency)
+        #self.assertEqual(b,d.dependee)
+        #self.assertEqual("blah",d.specific_output_id)
         
         self.assertRaises(AssertionError,Dependency,None,c)
         self.assertRaises(AssertionError,Dependency,c,None)



Mime
View raw message