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 gumprss.py
Date Sat, 12 Apr 2003 12:37:18 GMT
rubys       2003/04/12 05:37:18

  Modified:    python   gumprss.py
  Log:
  Add a few comments
  
  Revision  Changes    Path
  1.5       +31 -8     jakarta-gump/python/gumprss.py
  
  Index: gumprss.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gumprss.py,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- gumprss.py	12 Apr 2003 10:33:45 -0000	1.4
  +++ gumprss.py	12 Apr 2003 12:37:18 -0000	1.5
  @@ -3,12 +3,22 @@
   from xml.sax import parse
   from xml.sax.handler import ContentHandler
   
  +############################################################################
  +
  +# Where to find the historical data
   gumproot='http://cvs.apache.org/builds/gump/'
  +
  +# Format of index files entries
   summary=re.compile('<td>\s(\d\d:\d\d:\d\d)\s</td>\s' +
                      '<td.*?>\s<a href="(.*?)">([-\w]*)</a>\s</td>\s'
+
   		   '<td.*?>\s(\w+)\s</td>\s')
  +
  +# Local time zone, in offset from GMT
   TZ='%+.2d:00' % (-time.timezone/3600)
   
  +############################################################################
  +
  +# parse the gump data for a list of projects/modules, and the logdir
   module={}
   class Workspace(ContentHandler):
     logdir='.'
  @@ -24,27 +34,32 @@
   
   parse(open('work/merge.xml'),Workspace())
   
  +# update project summary based on a single days run
   def analyze(file,pstat,date):
     print file
     index=urllib.urlopen(file).read()
     for (time, url, project, status) in summary.findall(index):
       if project not in pstat:
  -      pstat[project]=(date, time, status, url, project, 1)
  +      pstat[project]=(date, time, status, url, project, 1) # first
       elif pstat[project][2]<>status: 
  -      pstat[project]=(date, time, status, url, project, 0)
  +      pstat[project]=(date, time, status, url, project, 0) # non-first
   
  +# analyze all of the historical data
   pstat={}
   builds=urllib.urlopen(gumproot).read()
   for date in re.findall('<a href="([\d-]*)/">',builds):
     analyze(gumproot+date,pstat,date)
   
  +# analyze today's run
   today=time.strftime('%Y-%m-%d')
   analyze(Workspace.logdir+'/index.html',pstat,today)
   
  +# order the values in reverse chronological order 
   result=pstat.values()
   result.sort()
   result.reverse()
   
  +# dump the output in rss format
   gumprss=open(Workspace.logdir + '/index.rss','w')
   gumprss.write("""<rss version="2.0"
     xmlns:admin="http://webns.net/mvcb/" 
  @@ -64,18 +79,26 @@
       <sy:updatePeriod>daily</sy:updatePeriod>""")
   
   for (date,time,status,url,project,first) in result:
  -  if first: continue
  -  if not project in module: continue
  -  link=gumproot + date + '/' + url
  +  if first: continue # not newsworthy
  +  if not project in module: continue # no longer relevant
  +
  +  link = gumproot + date + '/' + url
     print link
  +
  +  # read the details for the selected build
     if date==today:
       data=urllib.urlopen(Workspace.logdir+'/'+url).read()
     else:
       data=urllib.urlopen(link).read()
  +
  +  # extract out only the relevant content
     content=re.split('</?XMP>',data)
  -  if len(content)<2: content=re.split('</?p>',data)
  -  content=escape('\n'.join((content+[''])[1].splitlines()[-25:]))
  +  if len(content)<2: 
  +    content=(re.split('</?p>',data)+[''])[1]
  +  else:
  +    content=escape('\n'.join((content+[''])[1].splitlines()[-25:]))
   
  +  # write out the item to the rss feed
     gumprss.write("""
       <item>
         <title>%s %s %s</title>
  @@ -85,7 +108,7 @@
         <dc:date>%sT%s%s</dc:date>
       </item>""" % (project,status,date, link, content, module[project], date,time,TZ))
   
  -
  +# complete the rss feed
   gumprss.write("""
     </channel>
   </rss>
  
  
  

Mime
View raw message