gump-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ru...@apache.org
Subject cvs commit: jakarta-gump/python gumpcore.py gumpview.py
Date Sun, 27 Apr 2003 15:14:37 GMT
rubys       2003/04/27 08:14:37

  Modified:    python   gumpcore.py gumpview.py
  Log:
  Compute build sequence in more of an OO style - this will be important
  when adding back in the logic to handle inferred dependencies and the
  like.
  
  Also some minor tweaks to the UI
  
  Revision  Changes    Path
  1.13      +46 -72    jakarta-gump/python/gumpcore.py
  
  Index: gumpcore.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gumpcore.py,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- gumpcore.py	26 Apr 2003 10:32:45 -0000	1.12
  +++ gumpcore.py	27 Apr 2003 15:14:36 -0000	1.13
  @@ -282,6 +282,52 @@
       # complete properties
       if self.ant: self.ant.complete(self)
   
  +  # Determine if this project has any unsatisfied dependencies left
  +  # on the todo list.
  +  def isReady(self,todo):
  +    for depend in self.depend+self.option:
  +      if Project.list[depend.project] in todo: return 0
  +    return 1
  +
  +  # add this element and all of it's dependencies to a todo list 
  +  def addToTodoList(self,todo):
  +    todo.append(self)
  +    for depend in self.depend+self.option:
  +      project=Project.list[depend.project]
  +      if not project in todo: project.addToTodoList(todo)
  +
  +  # determine if this project is a prereq of any project on the todo list
  +  def isPrereq(self,todo):
  +    for project in todo:
  +      for depend in project.depend+project.option:
  +	if depend.project==self.name: return 1
  +    return 0
  +
  +  # determine the build sequence
  +  def buildSequence(self):
  +    result=[]
  +    todo=[]
  +    self.addToTodoList(todo)
  +    todo.sort()
  +    while todo:
  +      # one by one, remove the first ready project and append it to the result
  +      for project in todo:
  +	if project.isReady(todo):
  +	  todo.remove(project)
  +	  if project.ant or project.script: result.append(project)
  +	  break
  +      else:
  +        # we have a circular dependency, remove all innocent victims
  +	while todo:
  +	  for project in todo:
  +	    if project.isPrereq(todo):
  +	      todo.remove(project)
  +	      break
  +          else:
  +	    for project in todo: print project.name
  +	    raise "circular dependency"
  +    return result
  +
   # represents an <ant/> element
   class Ant(GumpBase): 
     def init(self): 
  @@ -337,78 +383,6 @@
   # represents a <work/> element
   class Work(GumpBase): pass
   
  -#########################################################################
  -#                     Utility functions                                 #
  -#########################################################################
  -
  -# sort project dependencies of a project and returns build sequence
  -def dependencies(root, #string
  -         projects, #hashtable
  -         state = {}, #hashtable
  -         visiting= [], #stack
  -         ret = [], #vector
  -         internalProjects = [],#vector
  -         indent = ''):
  -
  -        VISITING = 0
  -        VISITED = 1
  -        indent=indent+' '
  -        state[root] = VISITING
  -        visiting.append(root)
  -        project=Project.list[root]
  -
  -        # Make sure we exist
  -        if not project:
  -            print  "Project `" + root + "' does not exist in this project. ";
  -            visiting.pop();
  -            if visiting:
  -                parent = visiting[:];
  -                print ("\nIt is needed for project `" + parent + "'.");
  -                raise
  -
  -        if default.debug:
  -          print '------------------------- VISITING ' + root
  -          
  -        for depend in project.depend:#+project.option:
  -          cur = depend.project
  -          print indent + '(' + root + ' -- dep --> ' + cur
  -          
  -          try:
  -            p=Project.list[depend.project]
  -          except:
  -            print 'ERROR: Cannot find ' + depend.project
  -            print '  referenced by ' + project.name
  -            print '  that has the following dependencies:'
  -            for dep in project.depend:
  -              print '   ->' + dep.project
  -            print
  -            raise
  -            
  -          #print state.keys()
  -          
  -          if not state.has_key(cur):
  -            # Not been visited
  -            dependencies(cur, projects, state, visiting, ret, internalProjects, indent);
  -          elif (state[cur] == VISITING):
  -            # Currently visiting this node, so have a cycle
  -            print 'Circular exception'
  -            print 'current node: ' + cur
  -            print 'visited stack: ' + visiting
  -            raise
  -
  -
  -        p = visiting.pop();
  -        if not (root == p):
  -            print 'Unexpected internal error: expected to pop ' + root + ' but got ' +
p
  -            raise
  -
  -        print '------------------------- VISITED ' + root
  -        state[root] = VISITED
  -
  -        ret.append(project)
  -
  -        return ret
  -      
   #########################################################################
   #			    Demonstration code			        #
   #########################################################################
  
  
  
  1.7       +9 -9      jakarta-gump/python/gumpview.py
  
  Index: gumpview.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gumpview.py,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- gumpview.py	26 Apr 2003 21:50:05 -0000	1.6
  +++ gumpview.py	27 Apr 2003 15:14:36 -0000	1.7
  @@ -10,7 +10,7 @@
   # http://wxpython.org/
   from wxPython.wx import *
   
  -from gumpcore import load,Module,Project,dependencies
  +from gumpcore import load,Module,Project
   from gen import xmlize
   from gumpconf import *
   
  @@ -33,20 +33,20 @@
       # layout
       frame = wxFrame(NULL, -1, "Gump Workspace Viewer")
       split1 = wxSplitterWindow(frame,-1)
  -    notebook = wxNotebook(split1, -1, style=wxCLIP_CHILDREN)
  -    split2 = wxSplitterWindow(notebook,-1)
  +    split2 = wxSplitterWindow(split1,-1)
  +    notebook = wxNotebook(split2, -1, style=wxCLIP_CHILDREN)
   
       # panes
       self.tree=wxTreeCtrl(split1,-1)
  -    self.list=wxListCtrl(split2,-1,style=wxLC_REPORT|wxSUNKEN_BORDER)
  +    self.list=wxListCtrl(notebook,-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')
  +    split1.SplitVertically(self.tree, split2)
  +    notebook.AddPage(self.list, 'referenced')
       notebook.AddPage(self.dependencies, 'dependencies')
  -    split2.SplitHorizontally(self.list, self.data)
  +    split2.SplitHorizontally(notebook, self.data)
       self.SetTopWindow(frame)
       frame.Show(true)
   
  @@ -115,7 +115,7 @@
       self.data.ShowPosition(0)
   
       # gather a list of project dependencies unrolled to build
  -    self.build_sequence = dependencies(project.name, project.depend)
  +    self.build_sequence = project.buildSequence()
   
       # display the project dependencies
       self.dependencies.DeleteAllItems()
  @@ -126,7 +126,7 @@
         row=self.dependencies.InsertStringItem(i,self.build_sequence[i].name)
         self.dependencies.SetItemData(row,i)
   
  -    self.list.SetColumnWidth(0,wxLIST_AUTOSIZE_USEHEADER)
  +    self.dependencies.SetColumnWidth(0,wxLIST_AUTOSIZE_USEHEADER)
   
   
     # show the xml description for a single item
  
  
  

Mime
View raw message