gump-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nicola...@apache.org
Subject cvs commit: jakarta-gump/python/gump model.py
Date Sun, 04 May 2003 08:49:07 GMT
nicolaken    2003/05/04 01:49:07

  Modified:    python/gump model.py
  Log:
  Added logging.
  
  Do not fail if it cannot resolve a property, but warn instead.
  This is a hack to be able to load the model even with errors, so
  I can run a "check.py" module on it and output what is missing.
  
  Revision  Changes    Path
  1.7       +56 -28    jakarta-gump/python/gump/model.py
  
  Index: model.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/model.py,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- model.py	2 May 2003 17:15:20 -0000	1.6
  +++ model.py	4 May 2003 08:49:06 -0000	1.7
  @@ -58,6 +58,28 @@
   # information on the Apache Software Foundation, please see
   # <http://www.apache.org/>.
   
  +import os,types,logging
  +
  +from gump import GumpBase, Named, Single, Multiple
  +from gump.conf import dir, default
  +
  +    
  +###############################################################################
  +# Initialize
  +###############################################################################
  +
  +# use own logging
  +
  +# init logging
  +logging.basicConfig()
  +
  +# base gump logger
  +log = logging.getLogger(__name__)
  +
  +#set verbosity to show all messages of severity >= default.logLevel
  +log.setLevel(default.logLevel)
  +
  +
   ###############################################################################
   # Gump Object Model
   #
  @@ -65,9 +87,6 @@
   # above, allowing the actual model to be rather simple and compact.
   ###############################################################################
   
  -import os,types
  -from gump import GumpBase, Named, Single, Multiple
  -
   class Workspace(GumpBase):
     """Represents a <workspace/> element."""
   
  @@ -318,32 +337,41 @@
     # provide default elements when not defined in xml
     def complete(self,project):
       if self.reference=='home':
  -      self.value=Project.list[self.project].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':
  -      module=Project.list[self.project].module
  -      self.value=Module.list[module].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':
  -      target=Project.list[self.project]
  -      if self.id:
  -        for jar in target.jar:
  -          if jar.id==self.id:
  -            self.value=jar.path
  -            break
  +      try:
  +        target=Project.list[self.project]
  +        if self.id:
  +          for jar in target.jar:
  +            if jar.id==self.id:
  +              self.value=jar.path
  +              break
  +          else:
  +            raise str(("jar with id %s was not found in project %s "
  +               "referenced by %s") % (self.id, target.name, project.name))
  +        elif len(target.jar)==1:
  +          self.value=target.jar[0].path
  +        elif len(target.jar)>1:
  +          raise str(("Multiple jars defined by project %s referenced by %s; " +
  +             "an id attribute is required to select the one you want") %
  +             (target.name, project.name))
           else:
  -          raise str(("jar with id %s was not found in project %s "
  -             "referenced by %s") % (self.id, target.name, project.name))
  -      elif len(target.jar)==1:
  -        self.value=target.jar[0].path
  -      elif len(target.jar)>1:
  -        raise str(("Multiple jars defined by project %s referenced by %s; " +
  -           "an id attribute is required to select the one you want") %
  -           (target.name, project.name))
  -      else:
  -        raise str("Project %s referenced by %s defines no jars as output" %
  -          (target.name, project.name))
  -
  +          raise str("Project %s referenced by %s defines no jars as output" %
  +            (target.name, project.name))
  +        
  +      except:
  +        log.warn( "Cannot resolve jarpath of " + self.project + " for " + project.name)
   
   # TODO: set up the below elements with defaults using complete()
   
  
  
  

Mime
View raw message