gump-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aj...@apache.org
Subject cvs commit: jakarta-gump/python/gump/document forrest.py
Date Tue, 16 Dec 2003 17:13:49 GMT
ajack       2003/12/16 09:13:49

  Modified:    python/gump engine.py gumprun.py
               python/gump/model module.py workspace.py profile.py
                        rawmodel.py project.py loader.py
               python/gump/output statsdb.py
               python/gump/utils http.py __init__.py xmlutils.py
               python/gump/document forrest.py
  Log:
  1) Annotate XML objects w/ lower down errors
  2) Added Profile object (to match XMLProfile)
  3) Fixed consistency w/ getFull vs get on Dep/Depees on project
  
  Revision  Changes    Path
  1.43      +1 -10     jakarta-gump/python/gump/engine.py
  
  Index: engine.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/engine.py,v
  retrieving revision 1.42
  retrieving revision 1.43
  diff -u -r1.42 -r1.43
  --- engine.py	15 Dec 2003 19:36:51 -0000	1.42
  +++ engine.py	16 Dec 2003 17:13:47 -0000	1.43
  @@ -18,7 +18,7 @@
   
   from gump.utils.tools import *
   
  -from gump.model.workspace import Workspace
  +from gump.model.workspace import *
   from gump.model.module import Module
   from gump.model.project import Project
   from gump.model.depend import  ProjectDependency
  @@ -33,15 +33,6 @@
   from gump.output.repository import JarRepository
   from gump.output.nag import nag
   from gump.syndication import syndicate
  -
  -###############################################################################
  -# Initialize
  -###############################################################################
  -
  -SUCCESS=0
  -FAILED=1
  -MISSING_UTILITY=2
  -BAD_ENVIRONMENT=3
   
       
   ###############################################################################
  
  
  
  1.7       +0 -8      jakarta-gump/python/gump/gumprun.py
  
  Index: gumprun.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/gumprun.py,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- gumprun.py	6 Dec 2003 18:01:48 -0000	1.6
  +++ gumprun.py	16 Dec 2003 17:13:47 -0000	1.7
  @@ -29,14 +29,6 @@
   from gump.output.statsdb import *
   from gump.output.repository import JarRepository
   
  -###############################################################################
  -# Initialize
  -###############################################################################
  -
  -SUCCESS=0
  -FAILED=1
  -MISSING_UTILITY=2
  -BAD_ENVIRONMENT=3
       
   ###############################################################################
   # Functions
  
  
  
  1.23      +22 -9     jakarta-gump/python/gump/model/module.py
  
  Index: module.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/model/module.py,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- module.py	15 Dec 2003 19:36:51 -0000	1.22
  +++ module.py	16 Dec 2003 17:13:47 -0000	1.23
  @@ -207,6 +207,19 @@
         
           if self.isComplete(): return
              
  +        if self.getName() == 'broken1':
  +            print "------------------------------------------------------------------------"
  +            print "COMPLETE MODULE"
  +            self.xml.dump()
  +            print "------------------------------------------------------------------------"
       
  +            print "COMPLETE MODULE"
  +            dump(self.xml)
  +            print "------------------------------------------------------------------------"
  +            from gump.utils.xmlutils import xmlize
  +            print xmlize('module',self.xml)
  +            print "COMPLETED MODULE"
  +            print "------------------------------------------------------------------------"
  +        
           
           packaged=0
                   
  @@ -367,14 +380,14 @@
       # Get a full list of all the projects that depend
       # upon projects in this module 
       #
  -    def getDependees(self):   
  +    def getFullDependees(self):   
           # Calculated once only...
           if self.totalDependees: return self.totalDependees
                   
           for project in self.getProjects():
               if not project in self.totalDependees:
                   self.totalDependees.append(project)
  -                for dependee in project.getDependees():
  +                for dependee in project.getFullDependees():
                       dependeeProject=dependee.getProject()
                       if not dependeeProject in self.totalDependees:
                           self.totalDependees.append(dependeeProject)   
  @@ -383,24 +396,24 @@
           self.totalDependees.sort()
           return self.totalDependees
               
  -    def getDependeeCount(self):         
  -        return len(self.getDependees())   
  +    def getFullDependeeCount(self):         
  +        return len(self.getFullDependees())   
               
  -    def getDepends(self):   
  +    def getFullDepends(self):   
           if self.totalDepends: return self.totalDepends
                   
           for project in self.getProjects():
               if not project in self.totalDepends:
                   self.totalDepends.append(project)
  -                for depend in project.getDependencies():
  +                for depend in project.getFullDependencies():
                       dependProject=depend.getProject()
                       if not dependProject in self.totalDepends:
                           self.totalDepends.append(dependProject)                       

           self.totalDepends.sort()
           return self.totalDepends
               
  -    def getDependencyCount(self):         
  -        return len(self.getDepends())   
  +    def getFullDependencyCount(self):         
  +        return len(self.getFullDepends())   
           
       def getFOGFactor(self):
           fogFactor=0
  @@ -443,7 +456,7 @@
           affected=0
           
           # Get all dependenees (optional/otherwise)
  -        dependees=self.getDependees()
  +        dependees=self.getFullDependees()
           
           # Look through all dependees
           for project in dependees:
  
  
  
  1.19      +9 -0      jakarta-gump/python/gump/model/workspace.py
  
  Index: workspace.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/model/workspace.py,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- workspace.py	15 Dec 2003 19:59:19 -0000	1.18
  +++ workspace.py	16 Dec 2003 17:13:48 -0000	1.19
  @@ -78,6 +78,15 @@
   from gump.model.property import PropertyContainer
   from gump.utils.note import transferAnnotations, Annotatable
   
  +#
  +# :TODO: Need to createa GumpEnvironment to move these to..
  +#
  +
  +SUCCESS=0
  +FAILED=1
  +MISSING_UTILITY=2
  +BAD_ENVIRONMENT=3
  +
   
   class Workspace(ModelObject,PropertyContainer):
       """Gump Workspace"""
  
  
  
  1.2       +1 -0      jakarta-gump/python/gump/model/profile.py
  
  Index: profile.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/model/profile.py,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- profile.py	15 Dec 2003 19:36:51 -0000	1.1
  +++ profile.py	16 Dec 2003 17:13:48 -0000	1.2
  @@ -84,6 +84,7 @@
           
           # Copy over any XML errors/warnings
           transferAnnotations(self.xml, workspace)  
  +        
           # :TODO: Until we document the profile
           # add these to workspace transferAnnotations(self.xml, self)  
                   
  
  
  
  1.9       +1 -66     jakarta-gump/python/gump/model/rawmodel.py
  
  Index: rawmodel.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/model/rawmodel.py,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- rawmodel.py	15 Dec 2003 19:36:51 -0000	1.8
  +++ rawmodel.py	16 Dec 2003 17:13:48 -0000	1.9
  @@ -100,6 +100,7 @@
     def __init__(self,attrs):
       GumpXMLObject.__init__(self,attrs)
       
  +    
       # :TODO: This is too low level, do later/higher (somehow)
       
       # parse out '@@DATE@@'
  @@ -118,7 +119,6 @@
       self.profile=Multiple(XMLProfile)
       self.version=Single(GumpXMLModelObject)
   
  -
       
   # represents a <profile/> element
   class XMLProfile(Named,GumpXMLModelObject):
  @@ -219,71 +219,6 @@
       
     def getName(self):
       return self.name    
  -        
  -  # provide default elements when not defined in xml
  -  def complete(self,project):
  -    if self.isComplete(): return    
  -        
  -    if self.reference=='home':
  -      try:
  -        self.value=Project.list[self.project].home
  -      except:
  -        log.warn( "Cannot resolve homedir of " + self.project + " for " + project.name)
  -
  -    elif self.reference=='srcdir':
  -      try:
  -        module=Project.list[self.project].module
  -        self.value=Module.list[module].srcdir
  -      except:
  -        log.warn( "Cannot resolve srcdir of " + self.project + " for " + project.name)
  -
  -    elif self.reference=='jarpath' or self.reference=='jar':
  -      try:
  -        target=Project.list[self.project]
  -        if self.id:
  -          for jar in target.jar:
  -            if jar.id==self.id:
  -              if self.reference=='jarpath':
  -                  self.value=jar.path
  -              else:
  -                  self.value=jar.name
  -              break
  -          else:
  -            self.value=("jar with id %s was not found in project %s " +
  -              "referenced by %s") % (self.id, target.name, project.name)
  -            log.error(self.value)
  -        elif len(target.jar)==1:
  -          self.value=target.jar[0].path
  -        elif len(target.jar)>1:
  -          self.value=("Multiple jars defined by project %s referenced by %s; " + \
  -            "an id attribute is required to select the one you want") % \
  -              (target.name, project.name)
  -          log.error(self.value)
  -        else:
  -          self.value=("Project %s referenced by %s defines no jars as output") % \
  -            (target.name, project.name)
  -          log.error(self.value)
  -
  -      except Exception, details:
  -        log.warn( "Cannot resolve jarpath of " + self.project + \
  -          " for " + project.name + ". Details: " + str(details))
  -    elif self.path:
  -        #
  -        # Path relative to module's srcdir (or
  -        #
  -        module=Project.list[project.name].module
  -        srcdir=Module.list[module].srcdir
  -        
  -        # :TODO: ARBJ, this correct? I think it is close, but not...
  -        # Is module's srcdir same as project's ?
  -        self.value=os.path.abspath(os.path.join(srcdir,self.path))
  -    elif not hasattr(self,'value'):
  -        log.error('Unhandled Property: ' + self.name + ' on project: ' + \
  -                    project.name)
  -                      
  -
  -    self.setComplete(1)
  -        
           
   # TODO: set up the below elements with defaults using complete()
   
  
  
  
  1.25      +2 -2      jakarta-gump/python/gump/model/project.py
  
  Index: project.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/model/project.py,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- project.py	15 Dec 2003 19:36:51 -0000	1.24
  +++ project.py	16 Dec 2003 17:13:48 -0000	1.25
  @@ -305,7 +305,7 @@
               return self.totalDepends
           
           for dependency in self.depends:
  -            if not dependeny in self.totalDepends: 
  +            if not dependency in self.totalDepends: 
                   self.totalDepends.append(dependency)
                   for subdepend in dependency.getProject().getFullDependencies():
                       if not subdepend in self.totalDepends:
  @@ -333,7 +333,7 @@
           # Store once
           return self.totalDependees            
                           
  -    def getFullDependeesCount(self):         
  +    def getFullDependeeCount(self):         
           return len(self.getFullDependees())             
           
       def getFOGFactor(self):
  
  
  
  1.3       +4 -4      jakarta-gump/python/gump/model/loader.py
  
  Index: loader.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/model/loader.py,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- loader.py	15 Dec 2003 19:36:51 -0000	1.2
  +++ loader.py	16 Dec 2003 17:13:48 -0000	1.3
  @@ -69,6 +69,7 @@
   from gump.model.module import Module
   from gump.utils.xmlutils import SAXDispatcher
   from gump.utils.note import transferAnnotations, Annotatable
  +from gump.utils import dump
   
   class WorkspaceLoader:
       def __init__(self):
  @@ -113,7 +114,8 @@
         #
         # Cook the raw model...
         #
  -      workspace.complete(XMLProfile.map,XMLRepository.map,XMLModule.map,XMLProject.map)
  +      workspace.complete(XMLProfile.map,XMLRepository.map,	\
  +                          XMLModule.map,XMLProject.map)
   
         #
         # Clear out the maps [so don't continue to use them]
  @@ -123,8 +125,7 @@
         XMLProfile.map={}
         XMLRepository.map={}
     
  -      return workspace
  -      
  +      return workspace      
         
       def loadModule(self,url,workspace):
           
  @@ -137,7 +138,6 @@
       
           if not xmlmodule:
               raise IOError, "Failed to load module: " + url
  -
   
           #
           #for xmlproject in xmlmodule.project:
  
  
  
  1.6       +4 -4      jakarta-gump/python/gump/output/statsdb.py
  
  Index: statsdb.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/output/statsdb.py,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- statsdb.py	15 Dec 2003 19:36:51 -0000	1.5
  +++ statsdb.py	16 Dec 2003 17:13:48 -0000	1.6
  @@ -375,15 +375,15 @@
       return c
   
   def compareModulesByDependencyCount(module1,module2):
  -    count1=module1.getDependencyCount()
  -    count2=module2.getDependencyCount()
  +    count1=module1.getFullDependencyCount()
  +    count2=module2.getFullDependencyCount()
       c= count2 - count1                 
       if not c: c=cmp(module1,module2)
       return c        
           
   def compareModulesByDependeeCount(module1,module2):
  -    count1=module1.getDependeeCount()
  -    count2=module2.getDependeeCount()
  +    count1=module1.getFullDependeeCount()
  +    count2=module2.getFullDependeeCount()
       c= count2 - count1                  
       if not c: c=cmp(module1,module2)
       return c       
  
  
  
  1.2       +1 -1      jakarta-gump/python/gump/utils/http.py
  
  Index: http.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/utils/http.py,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- http.py	17 Nov 2003 22:10:55 -0000	1.1
  +++ http.py	16 Dec 2003 17:13:48 -0000	1.2
  @@ -143,7 +143,7 @@
           #
           urllib.urlretrieve(href, cachedHrefFile)
         except IOError, detail:
  -        log.error('Failed to download ['+href+']. Details: ' + detail)
  +        log.error('Failed to download ['+href+']. Details: ' + str(detail))
           try:
             os.remove(cachedHrefFile)
           except:
  
  
  
  1.14      +1 -1      jakarta-gump/python/gump/utils/__init__.py
  
  Index: __init__.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/utils/__init__.py,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- __init__.py	11 Dec 2003 22:16:05 -0000	1.13
  +++ __init__.py	16 Dec 2003 17:13:48 -0000	1.14
  @@ -96,7 +96,7 @@
           if isinstance(var,types.MethodType): continue
   
           if isinstance(var,list): 
  -          print indent+"  List Name:" + str(name)
  +          print indent+"  List Name:" + str(name) + ' len:' + str(len(var))
             i=0
             for v in var:
                i+=1
  
  
  
  1.6       +42 -30    jakarta-gump/python/gump/utils/xmlutils.py
  
  Index: xmlutils.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/utils/xmlutils.py,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- xmlutils.py	15 Dec 2003 19:36:52 -0000	1.5
  +++ xmlutils.py	16 Dec 2003 17:13:48 -0000	1.6
  @@ -113,15 +113,18 @@
           attributes['@basedir']=self.basedir
           
           # The newly loaded object moves to top of stack
  -        extractedObject=self.topOfStack.startElement(name,attributes)
  -        if not isinstance(extractedObject,Annotation):
  +        try:
  +            extractedObject=self.topOfStack.startElement(name,attributes)
  +        
  +            # Extract object
               self.topOfStack=extractedObject
  -        else:
  -            # Nasty hack to try to return/annotate errors
  +            
  +        except Exception, detail:
  +            message=str(detail)
               if self.topOfStack and isinstance(self.topOfStack,Annotatable):  
  -                self.topOfStack.addAnnotationObject(extractedObject)
  -                self.topOfStack.dump()
  -        
  +                self.topOfStack.addError(message)              
  +            else:
  +                self.addError(message)
       self.elementStack.append(self.topOfStack)
   
     def characters(self, string):
  @@ -136,12 +139,12 @@
     def error(self, exception):
       self.addError('XML error : ' + str(exception))
       log.error("Handle a recoverable error." + str(exception), exc_info=1)
  -    raise exception
  +    # raise exception
       
     def fatalError(self, exception):
       self.addError('XML error : ' + str(exception))
       log.error("Handle a non-recoverable error." + str(exception), exc_info=1)
  -    raise exception
  +    # raise exception
   
     def warning(self, exception):
       self.addWarning('XML warning' + str(exception))
  @@ -163,12 +166,14 @@
       attributes)."""
   
     def __init__(self,attrs):
  -      
  -    Annotatable.__init__(self)    
  +    
  +    # Ensure we have an 'annotations' list
  +    if not hasattr(self,'annotations') or not isinstance(self.annotations,list):
  +        Annotatable.__init__(self)    
       
       # Transfer attributes
       for (name,value) in attrs.items():
  -        if not name == '@basedir' and not name=='annotations':
  +        if not name == '@basedir':
               self.__dict__[name]=value
       # Setup internal character field
       if not '@text' in self.__dict__: self.init()
  @@ -223,7 +228,7 @@
     def __delitem__(self,name):
       del self.__dict__[name]
   
  -  def __getattr__(self,name):
  +  def __getattr__(self,name):  
       pass
   
     def __str__(self):
  @@ -257,12 +262,12 @@
   
     def __new__(cls,attrs):
       """ A Named element """   
  -     
  +    
       #
       # Note: The first time a named is imported it is probably
       # not 'named' but with an 'href' to the 'remote' metadata.
       #
  -    name=attrs.get('name')
  +    name=attrs.get('name')    
       
       #   
       # A 'named' element can also be 'downloaded' via an href
  @@ -291,10 +296,12 @@
               tag =  cls.__name__.lower().replace('xml','')
                           
               try:
  -                parser=SAXDispatcher(newHref, \
  -                                  tag, cls,\
  -                                  basedir)
  -                                  
  +                parser=SAXDispatcher( newHref, \
  +                                      tag, \
  +                                      cls,\
  +                                      basedir)
  +                                
  +                # Get the extracted object
                   element=parser.docElement     
                   
                   # Copy over any XML errors/warnings
  @@ -303,16 +310,17 @@
               except Exception, detail:
                   message='Failed to parse XML @ [' + newHref + ']. Details: ' + str(detail)
                   log.error(message, exc_info=1)   
  -                element=Annotation(LEVEL_ERROR, message)
  +                raise RuntimeError, message
           else:
               # :TODO: Set any object "invalid"?
  -            log.warn("HREF: ["+href+"] not loaded", exc_info=1)
  -            element=Annotation(LEVEL_ERROR, message)
  +            message='HREF ['+href+'] not loaded'
  +            log.error(message, exc_info=1)
  +            raise RuntimeError, message
           
           #
           # Stash for general reference/interest
           #
  -        if element and not isinstance(element,Annotation):
  +        if element:
               element.href=href                    
           
           # Return the downloaded element instead...
  @@ -323,12 +331,13 @@
             # We've this already?
             element=cls.map[name]
           except:
  -          # Create it first time...
  -          element=GumpXMLObject.__new__(cls,attrs)
  +          # Store in class map
  +          if name: 
  +              log.debug(str(cls) + ' : ' + name + ' ... not downloaded from HREF first')
       
  +              # Create it first time...
  +              element=GumpXMLObject.__new__(cls,attrs)
         
  -        # Store in class map
  -        if name: 
  -            cls.map[name]=element
  +              cls.map[name]=element
         
       return element
                   
  @@ -398,8 +407,9 @@
   
     def __init__(self,cls=GumpXMLObject):
       """The cls passed in determines what type the delegate instances will have."""
  -    list.__init__(self)
  -    
  +    list.__init__(self)    
  +    GumpXMLObject.__init__(self,{}) 
  +       
       # Store the type of class we are a multiple of..
       self.cls=cls
   
  @@ -427,6 +437,8 @@
     # iterate over the object properties
     for name in object.__dict__:
       if name.startswith('__') and name.endswith('__'): continue
  +    if name == 'annotations': continue
  +    
       var=getattr(object,name)
   
       # avoid nulls, metadata, and methods
  
  
  
  1.39      +4 -3      jakarta-gump/python/gump/document/forrest.py
  
  Index: forrest.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/document/forrest.py,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- forrest.py	15 Dec 2003 19:36:52 -0000	1.38
  +++ forrest.py	16 Dec 2003 17:13:49 -0000	1.39
  @@ -1465,7 +1465,7 @@
               if not gumpSet.inModules(module): continue   
               dependenciesRow=dependenciesTable.createRow()
               self.insertLink( module, stats, dependenciesRow.createData())
  -            dependenciesRow.createData( module.getDependencyCount())
  +            dependenciesRow.createData( module.getFullDependencyCount())
               
               #projectsString=''
               #for project in module.getDepends():
  @@ -1485,7 +1485,7 @@
               if not gumpSet.inModules(module): continue   
               dependeesRow=dependeesTable.createRow()
               self.insertLink( module, stats, dependeesRow.createData())
  -            dependeesRow.createData(module.getDependeeCount())
  +            dependeesRow.createData(module.getFullDependeeCount())
               
               #projectsString=''
               #for project in module.getDependees():
  @@ -1544,12 +1544,13 @@
           document=XDocDocument('Projects By Dependee Count',
                       self.resolver.getFile(stats,'project_dependees.xml'))
           
  -        dependeesTable=document.createTable(['Projects By Dependee Count'])
  +        dependeesTable=document.createTable(['Project','Direct Dependee Count', 'Full Dependee
Count'])
           for project in stats.projectsByTotalDependees:         
               if not gumpSet.inSequence(project): continue   
               dependeesRow=dependeesTable.createRow()
               self.insertLink( project, stats, dependeesRow.createData())
               dependeesRow.createData(project.getDependeeCount())
  +            dependeesRow.createData(project.getFullDependeeCount())
               
               #projectsString=''
               #for project in module.getDependees():
  
  
  

Mime
View raw message