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 build.py gen.py gumpconf.py gumpcore.py gumputil.py gumpview.py orphans.py ruper.py
Date Sat, 26 Apr 2003 08:46:20 GMT
nicolaken    2003/04/26 01:46:20

  Modified:    python   build.py gen.py gumpconf.py gumpcore.py gumputil.py
                        gumpview.py orphans.py ruper.py
  Log:
  Fix line endings.
  
  Revision  Changes    Path
  1.7       +174 -170  jakarta-gump/python/build.py
  
  Index: build.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/build.py,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- build.py	25 Apr 2003 17:17:49 -0000	1.6
  +++ build.py	26 Apr 2003 08:46:19 -0000	1.7
  @@ -1,170 +1,174 @@
  -#!/usr/bin/python
  -"""
  -        This is the entrypoint into gump. It at the moment basically
  -        calls gumpcore.load() to get the workspace, then dumps
  -        information about what it should be doing to stdout.
  -
  -        The main thing to do here is to clone dumpDeps to create a
  -        build() method which executes the appropriate script
  -        (probably only ant at the moment; would be nice to have)
  -        support for maven) for each of the dependencies.        
  -"""
  -
  -import os.path,os,sys
  -from gumpcore import *
  -from gumpconf import *
  -
  -# dump all dependencies to build a project to the output
  -def dumpDeps(workspace, projectname):
  -
  -  # get the project object given the project name
  -  project=Project.list[projectname]
  -  
  -  print 'PROJECTS TO BUILD:'
  -
  -  # resolve the build sequence of the specified project
  -  build_sequence = dependencies(projectname, project.depend)
  -
  -  # synchronize
  -  syncWorkDir( workspace, build_sequence )
  -
  -  # build
  -  buildProjects( workspace, projectname, project, build_sequence )  
  -    
  -def syncWorkDir( workspace, build_sequence ):
  -  print
  -  print ' ----- Synchronizing work directories with sources-----'
  -  print
  -
  -  # copy the raw project materials from source to work dir (hopefully using rsync, cp is
fallback)
  -  for project in build_sequence:
  -    module=Module.list[project.module];
  -    sourcedir = os.path.normpath(os.path.join(workspace.cvsdir,module.name)) # todo allow
override
  -    destdir = os.path.normpath(os.path.join(workspace.basedir,module.name))
  -    if not workspace.sync:
  -      workspace.sync = default.syncCommand
  -    execString = workspace.sync + ' ' + sourcedir + ' ' + destdir
  -    #if default.debug:
  -    print 'Synchronizing:', execString
  -    # TODO: don't just brag about it!
  -    #exec( execString )
  -
  -def buildProjects( workspace, projectname, project, build_sequence ):
  -  print
  -  print ' ----- Build sequence for ' + projectname + ' -----'
  -  print
  -
  -  # restore classpath when done
  -  try:
  -    oldPath = os.environ['CLASSPATH']
  -  except:
  -    oldPath = ''
  -
  -  # for all the projects that this project depends upon, show relevant infos
  -  for project in build_sequence:
  -    
  -    # get the module object given the module name,
  -    # which is gotten from the project
  -    module=Module.list[project.module]
  -
  -    print ' ----------- '+ module.name + ':' + project.name + ' ----------- '
  -
  -    # get the ant element
  -    ant=project.ant
  -
  -    if ant:
  -      target=''
  -
  -      # debug info      
  -      if ant.target:
  -        print ' ANT TARGET '
  -        print '   ',ant.target
  -        target = ant.target
  -      else:
  -        print ' ANT TARGET '
  -        print '   [default]'
  -
  -    # get the script element
  -    script=project.script
  -
  -    if script:
  -      print ' BUILD WITH SCRIPT '
  -      print '   ', script.name
  -
  -    if not (script or ant):
  -      print ' THIS PROJECT IS NOT TO BE BUILT '
  -      
  -    print ' SRCDIR'
  -    buildbasedir = os.path.normpath(os.path.join(module.srcdir,ant.basedir or ''))
  -    print '   ',buildbasedir
  -
  -    print ' CLASSPATH'          #FIXME (nicolaken) has to use this too
  -    classpath=''
  -    for depend in project.depend:#+project.option:
  -      p=Project.list[depend.project]
  -      srcdir=Module.list[p.module].srcdir
  -
  -      for jar in p.jar:
  -        classpath = classpath + os.path.normpath(os.path.join(srcdir,jar.name)) + ';'
  -        print '  ',os.path.normpath(os.path.join(srcdir,jar.name))
  -
  -    print
  -    print ' PROPERTIES'                #FIXME (nicolaken) it's not necessarily there
  -    for property in workspace.property:#+ant.property:
  -      print '  ',property.name,'=',property.value
  -
  -    print ' ------------------------------------------------------- '
  -    print
  -
  -    if ant:
  -      execString=default.antCommand + ' ' + target
  -      print 'Building using ant!'
  -      print '    cd', buildbasedir
  -      print '    export CLASSPATH=' + classpath
  -      print '   ', execString
  -
  -      # TODO: don't just brag about it!
  -      #os.environ['CLASSPATH']=classpath
  -      #os.chdir( buildbasedir )
  -      #exec( execString )
  -
  -    if script:
  -      scriptfile = os.path.normpath(os.path.join(module.srcdir, script.name))
  -      print 'Building using ant!'
  -      print '    cd', buildbasedir
  -      print '    export CLASSPATH=' + classpath
  -      print '   ', scriptfile
  -
  -      # TODO: don't just brag about it!
  -      #os.environ['CLASSPATH']=classpath
  -      #os.chdir( buildbasedir )
  -      #exec( scriptfile )
  -      
  -    print
  -    print ' ------------------------------------------------------- '
  -    print
  -
  -  os.environ['CLASSPATH'] = oldPath
  -
  -
  -# static void main()
  -if __name__=='__main__':
  -  # cd into the base Gump dir; all dirs are relative to it
  -  os.chdir(dir.base)
  -    
  -  # load commandline args or use default values
  -  if len(sys.argv)>1 :
  -    ws=sys.argv[1]
  -  else:
  -    ws=default.workspace
  -    
  -  if len(sys.argv)>2 :
  -    ps=sys.argv[2]
  -  else:
  -    ps=default.project    
  -
  -  # get parsed workspace definition
  -  workspace=load(ws)
  -  # print info on the definition
  -  dumpDeps(workspace, ps);          
  -  sys.exit(0)
  +#!/usr/bin/python
  +"""
  +        This is the entrypoint into gump. It at the moment basically
  +        calls gumpcore.load() to get the workspace, then dumps
  +        information about what it should be doing to stdout.
  +
  +        The main thing to do here is to clone dumpDeps to create a
  +        build() method which executes the appropriate script
  +        (probably only ant at the moment; would be nice to have
  +        support for maven) for each of the dependencies.        
  +"""
  +
  +
  +import os.path,os,sys
  +from gumpcore import *
  +from gumpconf import *
  +
  +# dump all dependencies to build a project to the output
  +def dumpDeps(workspace, projectname):
  +
  +  # get the project object given the project name
  +  project=Project.list[projectname]
  +
  +  print 'PROJECTS TO BUILD:'
  +
  +  # resolve the build sequence of the specified project
  +  build_sequence = dependencies(projectname, project.depend)
  +
  +  # synchronize
  +  syncWorkDir( workspace, build_sequence )
  +
  +  # build
  +  buildProjects( workspace, projectname, project, build_sequence )  
  +   
  +
  +def syncWorkDir( workspace, build_sequence ):
  +  print
  +  print ' ----- Synchronizing work directories with sources-----'
  +  print
  +
  +  # copy the raw project materials from source to work dir (hopefully using rsync, cp is
fallback)
  +  for project in build_sequence:
  +    module=Module.list[project.module];
  +    sourcedir = os.path.normpath(os.path.join(workspace.cvsdir,module.name)) # todo allow
override
  +    destdir = os.path.normpath(os.path.join(workspace.basedir,module.name))
  +
  +    if not workspace.sync:
  +      workspace.sync = default.syncCommand
  +    execString = workspace.sync + ' ' + sourcedir + ' ' + destdir
  +
  +    #if default.debug:
  +    print 'Synchronizing:', execString
  +    # TODO: don't just brag about it!
  +    #exec( execString )
  +
  +def buildProjects( workspace, projectname, project, build_sequence ):
  +  print
  +  print ' ----- Build sequence for ' + projectname + ' -----'
  +  print
  +
  +  # restore classpath when done
  +  try:
  +    oldPath = os.environ['CLASSPATH']
  +  except:
  +    oldPath = ''
  +
  +  # for all the projects that this project depends upon, show relevant infos
  +  for project in build_sequence:
  +
  +    # get the module object given the module name,
  +    # which is gotten from the project
  +    module=Module.list[project.module]
  +
  +    print ' ----------- '+ module.name + ':' + project.name + ' ----------- '
  +
  +    # get the ant element
  +    ant=project.ant
  +
  +    if ant:
  +      target=''
  +
  +      # debug info      
  +      if ant.target:
  +        print ' ANT TARGET '
  +        print '   ',ant.target
  +        target = ant.target
  +      else:
  +        print ' ANT TARGET '
  +        print '   [default]'
  +
  +    # get the script element
  +    script=project.script
  +
  +    if script:
  +      print ' BUILD WITH SCRIPT '
  +      print '   ', script.name
  +
  +    if not (script or ant):
  +      print ' THIS PROJECT IS NOT TO BE BUILT '
  +      
  +    print ' SRCDIR'
  +    buildbasedir = os.path.normpath(os.path.join(module.srcdir,ant.basedir or ''))
  +    print '   ',buildbasedir
  +
  +    print ' CLASSPATH'          #FIXME (nicolaken) has to use this too
  +    classpath=''
  +    for depend in project.depend:#+project.option:
  +      p=Project.list[depend.project]
  +      srcdir=Module.list[p.module].srcdir
  +
  +      for jar in p.jar:
  +        classpath = classpath + os.path.normpath(os.path.join(srcdir,jar.name)) + ';'
  +        print '  ',os.path.normpath(os.path.join(srcdir,jar.name))
  +
  +    print
  +    print ' PROPERTIES'                #FIXME (nicolaken) it's not necessarily there
  +    for property in workspace.property:#+ant.property:
  +      print '  ',property.name,'=',property.value
  +
  +    print ' ------------------------------------------------------- '
  +    print
  +
  +    if ant:
  +      execString=default.antCommand + ' ' + target
  +      print 'Building using ant!'
  +      print '    cd', buildbasedir
  +      print '    export CLASSPATH=' + classpath
  +      print '   ', execString
  +
  +      # TODO: don't just brag about it!
  +      #os.environ['CLASSPATH']=classpath
  +      #os.chdir( buildbasedir )
  +      #exec( execString )
  +
  +    if script:
  +      scriptfile = os.path.normpath(os.path.join(module.srcdir, script.name))
  +      print 'Building using ant!'
  +      print '    cd', buildbasedir
  +      print '    export CLASSPATH=' + classpath
  +      print '   ', scriptfile
  +
  +      # TODO: don't just brag about it!
  +      #os.environ['CLASSPATH']=classpath
  +      #os.chdir( buildbasedir )
  +      #exec( scriptfile )
  +      
  +    print
  +    print ' ------------------------------------------------------- '
  +    print
  +
  +  os.environ['CLASSPATH'] = oldPath
  +
  +
  +# static void main()
  +if __name__=='__main__':
  +  # cd into the base Gump dir; all dirs are relative to it
  +  os.chdir(dir.base)
  +    
  +  # load commandline args or use default values
  +  if len(sys.argv)>1 :
  +    ws=sys.argv[1]
  +  else:
  +    ws=default.workspace
  +    
  +  if len(sys.argv)>2 :
  +    ps=sys.argv[2]
  +  else:
  +    ps=default.project    
  +
  +  # get parsed workspace definition
  +  workspace=load(ws)
  +  # print info on the definition
  +  dumpDeps(workspace, ps);          
  +  sys.exit(0)
  
  
  
  1.8       +1 -82     jakarta-gump/python/gen.py
  
  Index: gen.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gen.py,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- gen.py	25 Apr 2003 00:11:39 -0000	1.7
  +++ gen.py	26 Apr 2003 08:46:19 -0000	1.8
  @@ -1,82 +1 @@
  -#!/usr/bin/python
  -"""
  -        Generate the merged XML description of the workspace
  -"""
  -
  -import os.path,os,sys
  -from gumpcore import *
  -from gumpconf import *
  -
  -#########################################################################
  -#                     Dump the object module as XML                     #
  -#########################################################################
  -
  -def xmlize(nodeName,object,f,indent='',delta='  '):
  -  from xml.sax.saxutils import escape
  -  import types
  -
  -  attrs=[nodeName]
  -  elements=[]
  -  text=''
  -  encoding='latin-1'
  -
  -  # iterate over the object properties
  -  for name in object.__dict__:
  -    if name.startswith('__') and name.endswith('__'): continue
  -    var=getattr(object,name)
  -
  -    # avoid nulls, metadata, and methods
  -    if not var: continue
  -    if isinstance(var,types.TypeType): continue
  -    if isinstance(var,types.MethodType): continue
  -
  -    # determine if the property is text, attribute, or element
  -    if name=='@text':
  -      text=var
  -    elif isinstance(var,types.StringTypes):
  -      attrs.append('%s="%s"' % (name,escape(var)))
  -    else:
  -      elements.append((name,var))
  -
  -  # format for display
  -  if not elements:
  -    # use compact form for elements without children
  -    if text.strip():
  -      f.write( '%s<%s>%s</%s>\n' % (indent.encode(encoding),' '.join(attrs).encode(encoding),text.strip().encode(encoding),nodeName))
  -    else:
  -      f.write( '%s<%s/>\n' % (indent.encode(encoding),' '.join(attrs).encode(encoding)))
  -  else:
  -    # use full form for elements with children
  -    f.write( '%s<%s>\n' % (indent.encode(encoding),' '.join(attrs).encode(encoding)))
  -    newindent=indent+delta
  -    for (name,var) in elements:
  -      if isinstance(var,list):
  -        # multiple valued elements
  -        for e in var: xmlize(name,e,f,newindent,delta)
  -      elif isinstance(var,Single):
  -       # single valued elements
  -        xmlize(name,var.delegate,f,newindent,delta)
  -    f.write( '%s</%s>\n' % (indent.encode(encoding),nodeName.encode(encoding)))
  -
  -
  -if __name__=='__main__':
  -  # cd into the base Gump dir; all dirs are relative to it
  -  os.chdir(dir.base)
  -
  -  # load commandline args or use default values
  -  if len(sys.argv)>1 :
  -    ws=sys.argv[1]
  -  else:
  -    ws=default.workspace
  -
  -  workspace=load(ws)
  -
  -  try:
  -    if not os.path.exists(dir.work):
  -      os.path.mkdir(dir.work)
  -    f=open(dir.work+'/'+default.merge, 'w')
  -    xmlize('workspace',workspace,f)
  -  finally:
  -    # Since we may exit via an exception, close fp explicitly.
  -    if f:
  -      f.close()
  +#!/usr/bin/python
"""
        Generate the merged XML description of the workspace
"""

import
os.path,os,sys
from gumpcore import *
from gumpconf import *

#########################################################################
#
                    Dump the object module as XML                     #
#########################################################################

def
xmlize(nodeName,object,f,indent='',delta='  '):
  from xml.sax.saxutils import escape
  import
types

  attrs=[nodeName]
  elements=[]
  text=''
  encoding='latin-1'

  # iterate over the
object properties
  for name in object.__dict__:
    if name.startswith('__') and name.endswith('__'):
continue
    var=getattr(object,name)

    # avoid nulls, metadata, and methods
    if not
var: continue
    if isinstance(var,types.TypeType): continue
    if isinstance(var,types.MethodType):
continue

    # determine if the property is text, attribute, or element
    if name=='@text':
     text=var
    elif isinstance(var,types.StringTypes):
      attrs.append('%s="%s"' % (name,escape(var)))
   else:
      elements.append((name,var))

  # format for display
  if not elements:
   
# use compact form for elements without children
    if text.strip():
      f.write( '%s<%s>%s</%s>\n'
% (indent.encode(encoding),' '.join(attrs).encode(encoding),text.strip().encode(encoding),nodeName))
   else:
      f.write( '%s<%s/>\n' % (indent.encode(encoding),' '.join(attrs).encode(encoding)))
 else:
    # use full form for elements with children
    f.write( '%s<%s>\n' % (indent.encode(encoding),'
'.join(attrs).encode(encoding)))
    newindent=indent+delta
    for (name,var) in elements:
     if isinstance(var,list):
        # multiple valued elements
        for e in var: xmlize(name,e,f,newindent,delta)
     elif isinstance(var,Single):
       # single valued elements
        xmlize(name,var.delegate,f,newindent,delta)
   f.write( '%s</%s>\n' % (indent.encode(encoding),nodeName.encode(encoding)))


if
__name__=='__main__':
  # cd into the base Gump dir; all dirs are relative to it
  os.chdir(dir.base)

 # load commandline args or use default values
  if len(sys.argv)>1 :
    ws=sys.argv[1]
 else:
    ws=default.workspace

  workspace=load(ws)

  try:
    if not os.path.exists(dir.work):
     os.path.mkdir(dir.work)
    f=open(dir.work+'/'+default.merge, 'w')
    xmlize('workspace',workspace,f)
 finally:
    # Since we may exit via an exception, close fp explicitly.
    if f:
      f.close()
  \ No newline at end of file
  
  
  
  1.7       +1 -21     jakarta-gump/python/gumpconf.py
  
  Index: gumpconf.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gumpconf.py,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- gumpconf.py	25 Apr 2003 17:17:49 -0000	1.6
  +++ gumpconf.py	26 Apr 2003 08:46:19 -0000	1.7
  @@ -1,21 +1 @@
  -#!/usr/bin/python
  -"""
  -        Global configuration settings for gump, done as Python classes
  -"""
  -
  -import socket, time
  -
  -class dir:
  -   base      = ".."
  -   cache     = "cache"
  -   work      = "work"
  -
  -class default:
  -  workspace  = socket.gethostname().split('.')[0] + ".xml"
  -  project    = "krysalis-ruper-test"
  -  merge      = "merge.xml"
  -  date       = time.strftime('%Y%m%d')
  -  debug      = 1
  -  antCommand = 'java org.apache.tools.ant.Main -Dbuild.sysclasspath=only'
  -  syncCommand= 'cp -Rf'
  -  
  +#!/usr/bin/python
"""
        Global configuration settings for gump, done as Python classes
"""

import
socket, time

class dir:
   base      = ".."
   cache     = "cache"
   work      = "work"

class
default:
  workspace  = socket.gethostname().split('.')[0] + ".xml"
  project    = "krysalis-ruper-test"
 merge      = "merge.xml"
  date       = time.strftime('%Y%m%d')
  debug      = 1
  antCommand
= 'java org.apache.tools.ant.Main -Dbuild.sysclasspath=only'
  syncCommand= 'cp -Rf'
  
  \ No newline at end of file
  
  
  
  1.8       +24 -54    jakarta-gump/python/gumpcore.py
  
  Index: gumpcore.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gumpcore.py,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- gumpcore.py	25 Apr 2003 16:06:15 -0000	1.7
  +++ gumpcore.py	26 Apr 2003 08:46:19 -0000	1.8
  @@ -1,17 +1,6 @@
   #!/usr/bin/python
   """
  -	Gump core functionality. It contains a sax dispatcher tool, a dependency
  -	walker, and an object model (GOM) which is built from an xmlfile using
  -	the sax dispatcher.
  -
  -    The idea is that a subclass of GumpBase is used for each of the various
  -    xml tags which can appear in a gump profile, with a saxdispatcher
  -    generating a tree of GumpBase objects from the profile, dynamically
  -    merging as it finds href references.
  -
  -    You can then use the dependencies() method to get an ordered, flat vector
  -    of the projects in the profile.
  -"""
  +	Gump core functionality. It contains a sax dispatcher tool, a dependency
	walker, and
an object model (GOM) which is built from an xmlfile using
	the sax dispatcher.

    The idea
is that a subclass of GumpBase is used for each of the various
    xml tags which can appear
in a gump profile, with a saxdispatcher
    generating a tree of GumpBase objects from the
profile, dynamically
    merging as it finds href references.

    You can then use the dependencies()
method to get an ordered, flat vector
    of the projects in the profile.
"""
   
   import os.path, os, time, urllib, urlparse, shutil, string, os.path
   from xml.sax import parse
  @@ -63,18 +52,11 @@
     return workspace
   
   #########################################################################
  -#		  Base classes for the Gump object model		                #
  -#                                                                       #
  -# This is actually where most of the logic and complexity is handled,   #
  -# allowing the actual model to be rather simple and compact. All        #
  -# elements of the GOM should extend GumpBase or a subclass of GumpBase. #
  +#		  Base classes for the Gump object model		#
  +#                                                                       #
# This is actually
where most of the logic and complexity is handled,   #
# allowing the actual model to be rather
simple and compact. All        #
# elements of the GOM should extend GumpBase or a subclass
of GumpBase. #
   #########################################################################
  -
   # Base class for the entire Gump object model.  Attributes become
  -# properties.  Characters become the string value of the element.
  -#
  -# An internal attribute with name '@text' is used for storing all
  -# the characters (as opposed to xml elements and xml attributes).
  +# properties.  Characters become the string value of the element.
#
# An internal attribute
with name '@text' is used for storing all
# the characters (as opposed to xml elements and
xml attributes).
   class GumpBase(object):
     def __init__(self,attrs):
       # parse out '@@DATE@@'
  @@ -85,10 +67,7 @@
       if not '@text' in self.__dict__: self.init()
       self.__dict__['@text']=''
     
  -  def startElement(self, name, attrs):
  -    # possibility to customize behaviour based on
  -    # type of the element
  -    # TODO: can this difference just go here?
  +  def startElement(self, name, attrs):
    # possibility to customize behaviour based on
   # type of the element
    # TODO: can this difference just go here?
       try:
         attr=self.__getattribute__(name)
         if isinstance(attr,Single): return attr(attrs)
  @@ -284,8 +263,7 @@
       self.mkdir=Multiple(Mkdir)
       self.redistributable=Single()
   
  -  # provide default elements when not defined in xml
  -  def complete(self,workspace):
  +  # provide default elements when not defined in xml
  def complete(self,workspace):
   
       # compute home directory
       if self.home and isinstance(self.home,Single):
  @@ -296,32 +274,26 @@
       # complete properties
       if self.ant: self.ant.complete(self)
   
  -# represents an <ant/> element
  +# represents an <ant/> element
   class Ant(GumpBase): 
     def init(self): 
       self.depend=Multiple(Depend)
       self.property=Multiple(Property)
       self.jvmarg=Multiple()
   
  -  # provide default elements when not defined in xml
  -  def complete(self,project):
  +  # provide default elements when not defined in xml
  def complete(self,project):
       for property in self.property: property.complete(project)
   
  -# represents a <nag/> element
  -class Nag(GumpBase): 
  +# represents a <nag/> element
class Nag(GumpBase): 
     def init(self): 
       self.regexp=Multiple()
   
  -# represents a <javadoc/> element
  -class Javadoc(GumpBase): 
  +# represents a <javadoc/> element
class Javadoc(GumpBase): 
     def init(self): 
       self.description=Multiple()
   
  -# represents a <property/> element
  -class Property(GumpBase): 
  -
  -  # provide default elements when not defined in xml
  -  def complete(self,project):
  +# represents a <property/> element
class Property(GumpBase): 
  +
  # provide default elements when not defined in xml
  def complete(self,project):
       if self.reference=='home':
         self.value=Project.list[self.project].home
       if self.reference=='srcdir':
  @@ -329,21 +301,19 @@
         self.value=Module.list[module].srcdir
   
   # TODO: set up the below elements with defaults using complete()
  +# represents a <depend/> element
class Depend(GumpBase): pass
  +
  +# represents a <description/> element
class Description(GumpBase): pass
  +
  +# represents a <home/> element
class Home(GumpBase): pass
  +
  +# represents a <jar/> element
class Jar(GumpBase): pass
  +
  +# represents a <junitreport/> element
class JunitReport(GumpBase): pass
  +
  +# represents a <mkdir/> element
class Mkdir(GumpBase): pass
   
  -# represents a <depend/> element
  -class Depend(GumpBase): pass
  -# represents a <description/> element
  -class Description(GumpBase): pass
  -# represents a <home/> element
  -class Home(GumpBase): pass
  -# represents a <jar/> element
  -class Jar(GumpBase): pass
  -# represents a <junitreport/> element
  -class JunitReport(GumpBase): pass
  -# represents a <mkdir/> element
  -class Mkdir(GumpBase): pass
  -# represents a <work/> element
  -class Work(GumpBase): pass
  +# represents a <work/> element
class Work(GumpBase): pass
   
   #########################################################################
   #                     Utility functions                                 #
  
  
  
  1.4       +1 -57     jakarta-gump/python/gumputil.py
  
  Index: gumputil.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gumputil.py,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- gumputil.py	24 Apr 2003 22:57:54 -0000	1.3
  +++ gumputil.py	26 Apr 2003 08:46:19 -0000	1.4
  @@ -1,57 +1 @@
  -#!/usr/bin/python
  -"""
  -        Utility functions for Gump
  -"""
  -
  -import os, os.path, sys, urllib, urlparse
  -from gumpconf import *
  -
  -# output debug messages or not
  -debug = False #True
  -  
  -#########################################################################
  -#                     Utility functions                                 #
  -#########################################################################
  -
  - 
  -# returns the path of the file in the href, cached if remote
  -def gumpCache(href):
  -    
  -  #if it's a local file get it locally
  -  if not href.startswith('http://'):
  -    newHref=href;  
  -  else:
  -    if debug: print 'url: ' + href
  -    if not os.path.exists(dir.cache):  mkdir(dir.cache)
  -
  -    #the name of the cached descriptor
  -    quotedHref = urllib.quote_plus(href)
  -    #the path of the cached descriptor
  -    newHref = dir.cache+'/'+quotedHref
  -    
  -    #download the file if not present in the cache
  -    if os.path.exists(newHref): 
  -      if debug: print 'using cached descriptor'
  -    else:  
  -      if debug: print 'caching...'
  -      urllib.urlretrieve(href, newHref)
  -      if debug: print '...done' 
  -
  -  return newHref
  -
  -# display an error message in standard formatting
  -def gumpMessage(type, error, description):
  -  print
  -  print
  -  print ' ****************************************************************'
  -  print '     ',type
  -  print ' ****************************************************************'
  -  print ' **                                                            **'
  -  print '   ',error
  -  print
  -  print description
  -  print
  -  print ' **                                                            **'
  -  print ' ****************************************************************'
  -  print
  -  print
  +#!/usr/bin/python
"""
        Utility functions for Gump
"""

import os, os.path, sys,
urllib, urlparse
from gumpconf import *

# output debug messages or not
debug = False #True
 
#########################################################################
#            
        Utility functions                                 #
#########################################################################


# returns the path of the file in the href, cached if remote
def gumpCache(href):
    
 
#if it's a local file get it locally
  if not href.startswith('http://'):
    newHref=href;
 
  else:
    if debug: print 'url: ' + href
    if not os.path.exists(dir.cache):  mkdir(dir.cache)

   #the name of the cached descriptor
    quotedHref = urllib.quote_plus(href)
    #the path
of the cached descriptor
    newHref = dir.cache+'/'+quotedHref
    
    #download the file
if not present in the cache
    if os.path.exists(newHref): 
      if debug: print 'using
cached descriptor'
    else:  
      if debug: print 'caching...'
      urllib.urlretrieve(href,
newHref)
      if debug: print '...done' 

  return newHref

# display an error message in
standard formatting
def gumpMessage(type, error, description):
  print
  print
  print ' ****************************************************************'
 print '     ',type
  print ' ****************************************************************'
 print ' **                                                            **'
  print '   ',error
 print
  print description
  print
  print ' **                                          
                 **'
  print ' ****************************************************************'
 print
  print
  \ No newline at end of file
  
  
  
  1.4       +1 -153    jakarta-gump/python/gumpview.py
  
  Index: gumpview.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gumpview.py,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- gumpview.py	24 Apr 2003 22:57:54 -0000	1.3
  +++ gumpview.py	26 Apr 2003 08:46:19 -0000	1.4
  @@ -1,153 +1 @@
  -#!/usr/bin/python
  -"""
  -        Graphic GUI to navigate a Gump workspace
  -"""
  -
  -import sys
  -from xml.sax import parse
  -from xml.sax.handler import ContentHandler
  -
  -# http://wxpython.org/
  -from wxPython.wx import *
  -
  -from gumpcore import load,Module,Project,dependencies
  -from gen import xmlize
  -from gumpconf import *
  -
  -class gumpview(wxApp):
  -  # model
  -  mySubs=None
  -  items=None
  -  build_sequence=None
  -  
  -  # view
  -  tree=None
  -  list=None
  -  data=None
  -
  -  # tree index
  -  mItem={}
  -  pItem={}
  -
  -  def OnInit(self):
  -    # layout 
  -    frame = wxFrame(NULL, -1, "Gump Workspace Viewer")
  -    split1 = wxSplitterWindow(frame,-1)
  -    notebook = wxNotebook(split1, -1, style=wxCLIP_CHILDREN)
  -    split2 = wxSplitterWindow(notebook,-1)
  -    
  -    # panes 
  -    self.tree=wxTreeCtrl(split1,-1)
  -    self.list=wxListCtrl(split2,-1,style=wxLC_REPORT|wxSUNKEN_BORDER)
  -    self.dependencies=wxListCtrl(notebook,-1,style=wxLC_REPORT|wxSUNKEN_BORDER)
  -    self.data=wxTextCtrl(split2,-1,style=wxTE_MULTILINE)
  -
  -    # attach the panes to the frame
  -    split1.SplitVertically(self.tree, notebook)
  -    notebook.AddPage(split2, 'referenced')
  -    notebook.AddPage(self.dependencies, 'dependencies')
  -    split2.SplitHorizontally(self.list, self.data)
  -    self.SetTopWindow(frame)
  -    frame.Show(true)
  -    
  -    # resize
  -    split1.SetMinimumPaneSize(20)
  -    split2.SetMinimumPaneSize(20)
  -    split1.SetSashPosition(300,true)
  -    split2.SetSashPosition(200)
  -    
  -    # wire up the events
  -    EVT_TREE_SEL_CHANGED(self, self.tree.GetId(), self.selectTree)
  -    EVT_LIST_ITEM_SELECTED(self, self.list.GetId(), self.selectItem)
  -    EVT_LIST_ITEM_SELECTED(self, self.dependencies.GetId(), self.selectItem2)
  -    return true
  -    
  -  # list all modules and their projects
  -  def load(self,files):
  -    root = self.tree.AddRoot(files[0])
  -    self.workspace = load(files[0])
  -    names=Module.list.keys()
  -    names.sort()
  -    for name in names:
  -      module=Module.list[name]
  -      parent=self.mItem[name]=self.tree.AppendItem(root,name)
  -      self.tree.SetPyData(parent,module)
  -      for project in module.project:
  -        self.pItem[project.name]=self.tree.AppendItem(parent,project.name)
  -        self.tree.SetPyData(self.pItem[project.name],project)
  -
  -    self.tree.Expand(root)
  -
  -  # select a single feed and display titles from each item
  -  def selectTree(self, event):
  -    self.showProject(self.tree.GetPyData(event.GetItem()))
  -
  -  def showProject(self,project):
  -    if not project or not isinstance(project,Project): return
  -
  -    # gather a list of projects which reference this project
  -    self.items=[]
  -    for parent in Project.list.values():
  -      list=parent.depend+parent.option
  -      if parent.ant: list+=parent.ant.depend
  -      for depend in list:
  -        if depend.project==project.name:
  -          self.items.append(parent.name)
  -
  -    # display the list, sorted by name
  -    self.list.DeleteAllItems()
  -    if not self.list.GetColumn(0): 
  -      self.list.InsertColumn(0, 'Cross Reference')
  -      self.items.sort()
  -    for i in range(0,len(self.items)): 
  -      row=self.list.InsertStringItem(i,self.items[i])
  -      self.list.SetItemData(row,i)
  -
  -    self.list.SetColumnWidth(0,wxLIST_AUTOSIZE_USEHEADER)
  -
  -    # display the project definition
  -    import StringIO
  -    data = StringIO.StringIO()
  -    xmlize('project',project,data,)
  -    self.data.Clear()
  -    data.seek(0)
  -    self.data.AppendText(data.read())
  -    self.data.ShowPosition(0)
  -    
  -    # gather a list of project dependencies unrolled to build
  -    self.build_sequence = dependencies(project.name, project.depend)
  -    
  -    # display the project dependencies
  -    self.dependencies.DeleteAllItems()
  -    if not self.dependencies.GetColumn(0): 
  -      self.dependencies.InsertColumn(0, 'Build sequence')
  -      
  -    for i in range(0,len(self.build_sequence)): 
  -      row=self.dependencies.InsertStringItem(i,self.build_sequence[i].name)
  -      self.dependencies.SetItemData(row,i)
  -    
  -    self.list.SetColumnWidth(0,wxLIST_AUTOSIZE_USEHEADER)
  -
  -    
  -  # show the xml description for a single item
  -  def selectItem(self, event):
  -    project=Project.list[self.items[event.GetItem().GetData()]]
  -    self.showProject(project)
  -
  -    # expand the associated module and select the project
  -    self.tree.Expand(self.mItem[project.module])
  -    self.tree.SelectItem(self.pItem[project.name])
  -
  -  # show the xml description for a single item
  -  def selectItem2(self, event):
  -    project=Project.list[self.build_sequence[event.GetItem().GetData()].name]
  -    self.showProject(project)
  -
  -    # expand the associated module and select the project
  -    self.tree.Expand(self.mItem[project.module])
  -    self.tree.SelectItem(self.pItem[project.name])
  -    
  -if __name__ == '__main__':
  -  app = gumpview(0)
  -  app.load(sys.argv[1:] or [default.workspace])
  -  app.MainLoop()
  +#!/usr/bin/python
"""
        Graphic GUI to navigate a Gump workspace
"""

import sys
from
xml.sax import parse
from xml.sax.handler import ContentHandler

# http://wxpython.org/
from
wxPython.wx import *

from gumpcore import load,Module,Project,dependencies
from gen import
xmlize
from gumpconf import *

class gumpview(wxApp):
  # model
  mySubs=None
  items=None
 build_sequence=None
  
  # view
  tree=None
  list=None
  data=None

  # tree index
  mItem={}
 pItem={}

  def OnInit(self):
    # layout 
    frame = wxFrame(NULL, -1, "Gump Workspace
Viewer")
    split1 = wxSplitterWindow(frame,-1)
    notebook = wxNotebook(split1, -1, style=wxCLIP_CHILDREN)
   split2 = wxSplitterWindow(notebook,-1)
    
    # panes 
    self.tree=wxTreeCtrl(split1,-1)
   self.list=wxListCtrl(split2,-1,style=wxLC_REPORT|wxSUNKEN_BORDER)
    self.dependencies=wxListCtrl(notebook,-1,style=wxLC_REPORT|wxSUNKEN_BORDER)
   self.data=wxTextCtrl(split2,-1,style=wxTE_MULTILINE)

    # attach the panes to the frame
   split1.SplitVertically(self.tree, notebook)
    notebook.AddPage(split2, 'referenced')
   notebook.AddPage(self.dependencies, 'dependencies')
    split2.SplitHorizontally(self.list,
self.data)
    self.SetTopWindow(frame)
    frame.Show(true)
    
    # resize
    split1.SetMinimumPaneSize(20)
   split2.SetMinimumPaneSize(20)
    split1.SetSashPosition(300,true)
    split2.SetSashPosition(200)
   
    # wire up the events
    EVT_TREE_SEL_CHANGED(self, self.tree.GetId(), self.selectTree)
   EVT_LIST_ITEM_SELECTED(self, self.list.GetId(), self.selectItem)
    EVT_LIST_ITEM_SELECTED(self,
self.dependencies.GetId(), self.selectItem2)
    return true
    
  # list all modules and
their projects
  def load(self,files):
    root = self.tree.AddRoot(files[0])
    self.workspace
= load(files[0])
    names=Module.list.keys()
    names.sort()
    for name in names:
   
  module=Module.list[name]
      parent=self.mItem[name]=self.tree.AppendItem(root,name)
     self.tree.SetPyData(parent,module)
      for project in module.project:
        self.pItem[project.name]=self.tree.AppendItem(parent,project.name)
       self.tree.SetPyData(self.pItem[project.name],project)

    self.tree.Expand(root)

 # select a single feed and display titles from each item
  def selectTree(self, event):
   self.showProject(self.tree.GetPyData(event.GetItem()))

  def showProject(self,project):
   if not project or not isinstance(project,Project): return

    # gather a list of projects
which reference this project
    self.items=[]
    for parent in Project.list.values():
 
    list=parent.depend+parent.option
      if parent.ant: list+=parent.ant.depend
      for
depend in list:
        if depend.project==project.name:
          self.items.append(parent.name)

   # display the list, sorted by name
    self.list.DeleteAllItems()
    if not self.list.GetColumn(0):

      self.list.InsertColumn(0, 'Cross Reference')
      self.items.sort()
    for i in range(0,len(self.items)):

      row=self.list.InsertStringItem(i,self.items[i])
      self.list.SetItemData(row,i)

   self.list.SetColumnWidth(0,wxLIST_AUTOSIZE_USEHEADER)

    # display the project definition
   import StringIO
    data = StringIO.StringIO()
    xmlize('project',project,data,)
   
self.data.Clear()
    data.seek(0)
    self.data.AppendText(data.read())
    self.data.ShowPosition(0)
   
    # gather a list of project dependencies unrolled to build
    self.build_sequence
= dependencies(project.name, project.depend)
    
    # display the project dependencies
   self.dependencies.DeleteAllItems()
    if not self.dependencies.GetColumn(0): 
      self.dependencies.InsertColumn(0,
'Build sequence')
      
    for i in range(0,len(self.build_sequence)): 
      row=self.dependencies.InsertStringItem(i,self.build_sequence[i].name)
     self.dependencies.SetItemData(row,i)
    
    self.list.SetColumnWidth(0,wxLIST_AUTOSIZE_USEHEADER)

   
  # show the xml description for a single item
  def selectItem(self, event):
    project=Project.list[self.items[event.GetItem().GetData()]]
   self.showProject(project)

    # expand the associated module and select the project
 
  self.tree.Expand(self.mItem[project.module])
    self.tree.SelectItem(self.pItem[project.name])

 # show the xml description for a single item
  def selectItem2(self, event):
    project=Project.list[self.build_sequence[event.GetItem().GetData()].name]
   self.showProject(project)

    # expand the associated module and select the project
 
  self.tree.Expand(self.mItem[project.module])
    self.tree.SelectItem(self.pItem[project.name])
   
if __name__ == '__main__':
  app = gumpview(0)
  app.load(sys.argv[1:] or [default.workspace])
 app.MainLoop()
  \ No newline at end of file
  
  
  
  1.5       +1 -59     jakarta-gump/python/orphans.py
  
  Index: orphans.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/orphans.py,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- orphans.py	24 Apr 2003 22:57:54 -0000	1.4
  +++ orphans.py	26 Apr 2003 08:46:19 -0000	1.5
  @@ -1,59 +1 @@
  -#!/usr/bin/python
  -"""
  -        Look for obsolete installed packages, cvs checkouts, and build
  -        directories.
  -"""
  -
  -from xml.sax import parse
  -from xml.sax.handler import ContentHandler
  -from glob import glob
  -import os
  -
  -class Workspace(ContentHandler):
  -    cvsdir = None
  -    pkgdir = None
  -    logdir = None
  -    basedir = None
  -    jardir = ""
  -    modules=[]
  -    packages=[]
  -    def startElement(self, name, attrs):
  -        if name == 'workspace':
  -            attrs=dict(attrs)
  -            self.pkgdir = attrs['pkgdir']
  -            self.cvsdir = attrs['cvsdir']
  -            self.basedir = attrs['basedir']
  -            if 'jardir' in attrs: self.jardir = attrs['jardir']
  -            self.logdir = attrs['logdir']
  -        if name == 'module':
  -            attrs=dict(attrs)
  -            self.modules.append(attrs['name'])
  -        if name == 'project':
  -            attrs=dict(attrs)
  -        if 'home' in attrs and attrs['home'].find(self.pkgdir) ==0:
  -            self.packages.append(attrs['home'].replace('\\','/'))
  -
  -workspace=Workspace()
  -parse(open('work/merge.xml'),workspace)
  -
  -# orphan packages
  -for dir in glob(workspace.pkgdir+'/*'):
  -    if not dir.replace('\\','/') in workspace.packages:
  -        if os.path.isdir(dir): print dir.replace('/',os.sep)
  -
  -# orphan cvs checkouts
  -for dir in glob(workspace.cvsdir+'/*'):
  -    if dir.endswith('Entries') or dir.endswith('Entries.log'): continue
  -    if not dir[len(workspace.cvsdir)+1:] in workspace.modules:
  -        if os.path.isdir(dir): print dir.replace('/',os.sep)
  -
  -# orphan builds
  -for dir in glob(workspace.basedir+'/*'):
  -    if not dir[len(workspace.basedir)+1:] in workspace.modules:
  -        dir=dir.replace('/',os.sep)
  -        if dir==workspace.basedir.replace('/',os.sep)+os.sep+"dist": continue
  -        if dir==workspace.jardir.replace('/',os.sep): continue
  -        if dir==workspace.logdir.replace('/',os.sep): continue
  -        if dir==workspace.cvsdir.replace('/',os.sep): continue
  -        if os.path.isdir(dir): print dir
  -
  +#!/usr/bin/python
"""
        Look for obsolete installed packages, cvs checkouts, and
build
        directories.
"""

from xml.sax import parse
from xml.sax.handler import ContentHandler
from
glob import glob
import os

class Workspace(ContentHandler):
    cvsdir = None
    pkgdir
= None
    logdir = None
    basedir = None
    jardir = ""
    modules=[]
    packages=[]
   def startElement(self, name, attrs):
        if name == 'workspace':
            attrs=dict(attrs)
           self.pkgdir = attrs['pkgdir']
            self.cvsdir = attrs['cvsdir']
      
     self.basedir = attrs['basedir']
            if 'jardir' in attrs: self.jardir = attrs['jardir']
           self.logdir = attrs['logdir']
        if name == 'module':
            attrs=dict(attrs)
           self.modules.append(attrs['name'])
        if name == 'project':
            attrs=dict(attrs)
       if 'home' in attrs and attrs['home'].find(self.pkgdir) ==0:
            self.packages.append(attrs['home'].replace('\\','/'))

workspace=Workspace()
parse(open('work/merge.xml'),workspace)

#
orphan packages
for dir in glob(workspace.pkgdir+'/*'):
    if not dir.replace('\\','/') in
workspace.packages:
        if os.path.isdir(dir): print dir.replace('/',os.sep)

# orphan
cvs checkouts
for dir in glob(workspace.cvsdir+'/*'):
    if dir.endswith('Entries') or dir.endswith('Entries.log'):
continue
    if not dir[len(workspace.cvsdir)+1:] in workspace.modules:
        if os.path.isdir(dir):
print dir.replace('/',os.sep)

# orphan builds
for dir in glob(workspace.basedir+'/*'):
 
  if not dir[len(workspace.basedir)+1:] in workspace.modules:
        dir=dir.replace('/',os.sep)
       if dir==workspace.basedir.replace('/',os.sep)+os.sep+"dist": continue
        if dir==workspace.jardir.replace('/',os.sep):
continue
        if dir==workspace.logdir.replace('/',os.sep): continue
        if dir==workspace.cvsdir.replace('/',os.sep):
continue
        if os.path.isdir(dir): print dir

  \ No newline at end of file
  
  
  
  1.3       +2 -66     jakarta-gump/python/ruper.py
  
  Index: ruper.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/ruper.py,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ruper.py	24 Apr 2003 22:57:54 -0000	1.2
  +++ ruper.py	26 Apr 2003 08:46:19 -0000	1.3
  @@ -1,66 +1,2 @@
  -#!/usr/bin/python
  -"""
  -        Resource updater for Gump
  -"""
  -
  -import os, os.path, sys, urllib
  -from gumpconf import *
  -
  -# output debug messages or not
  -debug = True #True
  -
  -# Repository
  -class RuperRepository(object):
  -  def __init__(self,url,type):
  -    self.url=url
  -    self.type=type
  -    
  -  def resolve(self, resource):
  -    # FIXME (nicolaken)
  -    # delegate the getting of a resource to an outside file
  -    # named after the repository type
  -    if self.type == 'maven':
  -      # not necessarily Maven uses our resource.standardName()
  -      if resource.type == 'jar':
  -        resolvedUrl = '%s/%s/jars/%s-%s.jar' % (self.url,resource.name,resource.name,resource.version)
  -      else:
  -        raise Error, 'Unknown Resource Type; type: '+type
  -    else:
  -      raise Error, 'Unknown Repository; type: '+type
  -
  -    return resolvedUrl
  -  
  -  def download(self, resource, destinationDir):
  -    if not os.path.isdir(destinationDir):
  -      raise IOError, 'This method needs a directory, instead it got:'+destinationDir
  -    
  -    remoteurl = self.resolve(resource)
  -    urllib.urlretrieve(remoteurl, '%s/%s' % (destinationDir,resource.standardName()))
  -
  -
  -  
  -# Resource
  -class RuperResource(object):
  -  def __init__(self,name,version,type):
  -    self.name=name
  -    self.version=version
  -    self.type=type
  -    
  -  def standardName(self):
  -    if self.type == 'jar':
  -      return '%s-%s.jar' % (self.name,self.version)
  -    else:
  -      raise Error, 'Unknown Resource Type; type: '+type
  -
  -    
  - 
  -if __name__=='__main__':
  -  os.chdir(dir.base)
  -  resource = RuperResource('log4j','1.3.4','jar')
  -  print resource.standardName()
  -  repository = RuperRepository('http://www.ibiblio.org/maven','maven')
  -  print repository.resolve(resource)
  -  repository.download(resource,dir.cache)
  -
  -
  -  
  +#!/usr/bin/python
"""
        Resource updater for Gump
"""

import os, os.path, sys, urllib
from
gumpconf import *

# output debug messages or not
debug = True #True
  +# Repository
class RuperRepository(object):
  def __init__(self,url,type):
    self.url=url
   self.type=type
    
  def resolve(self, resource):
    # FIXME (nicolaken)
    # delegate
the getting of a resource to an outside file
    # named after the repository type
    if
self.type == 'maven':
      # not necessarily Maven uses our resource.standardName()
    
 if resource.type == 'jar':
        resolvedUrl = '%s/%s/jars/%s-%s.jar' % (self.url,resource.name,resource.name,resource.version)
     else:
        raise Error, 'Unknown Resource Type; type: '+type
    else:
      raise
Error, 'Unknown Repository; type: '+type

    return resolvedUrl
  
  def download(self, resource,
destinationDir):
    if not os.path.isdir(destinationDir):
      raise IOError, 'This method
needs a directory, instead it got:'+destinationDir
    
    remoteurl = self.resolve(resource)
   urllib.urlretrieve(remoteurl, '%s/%s' % (destinationDir,resource.standardName()))


  
#
Resource
class RuperResource(object):
  def __init__(self,name,version,type):
    self.name=name
   self.version=version
    self.type=type
    
  def standardName(self):
    if self.type
== 'jar':
      return '%s-%s.jar' % (self.name,self.version)
    else:
      raise Error,
'Unknown Resource Type; type: '+type

    
 
if __name__=='__main__':
  os.chdir(dir.base)
 resource = RuperResource('log4j','1.3.4','jar')
  print resource.standardName()
  repository
= RuperRepository('http://www.ibiblio.org/maven','maven')
  print repository.resolve(resource)
 repository.download(resource,dir.cache)


  
  \ No newline at end of file
  
  
  

Mime
View raw message