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/test model.py
Date Fri, 05 Dec 2003 00:51:50 GMT
ajack       2003/12/04 16:51:50

  Modified:    python/gump/syndication rss.py __init__.py
               python/gump/utils commandLine.py
               python/gump/test model.py
  Added:       python/gump/syndication syndicator.py
  Log:
  Some more RSS tweaks
  
  Revision  Changes    Path
  1.2       +27 -10    jakarta-gump/python/gump/syndication/rss.py
  
  Index: rss.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/syndication/rss.py,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- rss.py	4 Dec 2003 23:16:24 -0000	1.1
  +++ rss.py	5 Dec 2003 00:51:49 -0000	1.2
  @@ -71,7 +71,9 @@
   from gump.model.state import *
   from gump.model.project import ProjectStatistics
   
  -from gump.syndication import Syndicator
  +from gump.config import setting
  +
  +from gump.syndication.syndicator import Syndicator
   
   ###############################################################################
   
  @@ -104,11 +106,11 @@
           self.rssStream.write('   <image>\n')
           
           # Mandatory Fields
  -        self.rssStream.write(('  <url>%s</url>\n') %(escape(self.url)))
  -        self.rssStream.write(('  <link>%s</link>\n') %(escape(self.link)))
  -        self.rssStream.write(('  <title>%s</title>\n') %(escape(self.title)))
  +        self.rssStream.write(('    <url>%s</url>\n') %(escape(self.url)))
  +        self.rssStream.write(('    <link>%s</link>\n') %(escape(self.link)))
  +        self.rssStream.write(('    <title>%s</title>\n') %(escape(self.title)))
               
  -        self.rssStream.write('  </image>\n')
  +        self.rssStream.write('   </image>\n')
   
   class Item:
       def __init__(self,title,link,description,subject,date,url=None,image=None):
  @@ -126,9 +128,11 @@
           self.rssStream.write('   <item>\n')
           
           # Mandatory Fields
  -        self.rssStream.write(('    <title>Jakarta Gump: %s</title>\n') %(escape(self.title)))
  +        self.rssStream.write(('    <title>Gump: %s</title>\n') %(escape(self.title)))
           self.rssStream.write(('    <link>%s</link>\n') %(escape(self.link)))
           self.rssStream.write(('    <description>%s</description>\n') %(escape(self.description)))
  +        self.rssStream.write('    <author>gump@jakarta.apache.org</author>\n')
               
  +        
           self.rssStream.write(('      <dc:subject>%s</dc:subject>\n') %(escape(self.subject)))
           self.rssStream.write(('      <dc:date>%s</dc:date>\n') %(escape(self.date)))
           
  @@ -155,22 +159,31 @@
           self.rssStream.write('  <channel>\n')
           
           # Mandatory Fields
  -        self.rssStream.write(('  <title>Jakarta Gump: %s</title>\n') %(escape(self.title)))
  +        self.rssStream.write(('  <title>Gump: %s</title>\n') %(escape(self.title)))
           self.rssStream.write(('  <link>%s</link>\n') %(escape(self.link)))
           self.rssStream.write(('  <description>%s</description>\n') %(escape(self.description)))
           
  +        self.rssStream.write('  <language>en-us</language>\n')
  +        self.rssStream.write('  <copyright>Copyright 2003, Apache Software Foundation</copyright>\n')
  +        self.rssStream.write(('  <generator>Jakarta Gump : %s</generator>\n')
& (escape(setting.version)))
  +        self.rssStream.write('  <webMaster>gump@jakarta.apache.org</webMaster>\n')
  +        self.rssStream.write('  <docs>http://blogs.law.harvard.edu/tech/rss</docs>\n')
  +        self.rssStream.write('  <category domain="http://www.apache.org/namespaces">Gump</category>\n')
  +                
           # Optional Fields
           if self.image:
               self.image.serialize(self.rssStream)
           
           # Admin stuff
           self.rssStream.write("""
  +    <gump:version>%s</gump:version>
  +    
       <admin:generatorAgent rdf:resource="http://cvs.apache.org/viewcvs/jakarta-gump/python/gump/output/rss.py"/>
       <admin:errorReportsTo rdf:resource="mailto:gump@jakarta.apache.org"/>
   
       <sy:updateFrequency>1</sy:updateFrequency>
       <sy:updatePeriod>daily</sy:updatePeriod>
  -""")
  +""" % setting.version)
               
       def endChannel(self):
           self.rssStream.write('  </channel>\n')
  @@ -199,6 +212,7 @@
   
       def startRSS(self):
           self.rssStream.write("""<rss version="2.0"
  +  xmlns:gump="http://jakarta.apache.org/gump/" 
     xmlns:admin="http://webns.net/mvcb/" 
     xmlns:dc="http://purl.org/dc/elements/1.1/" 
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
  @@ -267,7 +281,7 @@
           moduleURL=self.run.getOptions().getResolver().getUrl(module)
           
           moduleRSS=RSS(rssFile,	\
  -            Channel('Jakarta Gump : Module ' + escape(module.getName()),	\
  +            Channel('Gump : Module ' + escape(module.getName()),	\
                       moduleURL,	\
                       escape(module.getDescription()), \
                       self.gumpImage))
  @@ -283,7 +297,7 @@
           projectURL=self.run.getOptions().getResolver().getUrl(project)
           
           projectRSS=RSS(rssFile,	\
  -            Channel('Jakarta Gump : Project ' + escape(project.getName()),	\
  +            Channel('Gump : Project ' + escape(project.getName()),	\
                       projectURL,	\
                       escape(project.getDescription()), \
                       self.gumpImage))
  @@ -297,6 +311,9 @@
           #
           content=self.getProjectContent(project,self.run)
                           
  +        #
  +        #
  +        #
           item=Item(('%s %s %s') % (project.getName(),project.getStateDescription(),datestr),
\
                     projectURL, \
                     content, \
  
  
  
  1.3       +0 -87     jakarta-gump/python/gump/syndication/__init__.py
  
  Index: __init__.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/syndication/__init__.py,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- __init__.py	4 Dec 2003 23:26:01 -0000	1.2
  +++ __init__.py	5 Dec 2003 00:51:49 -0000	1.3
  @@ -74,93 +74,6 @@
   # tell Python what modules make up the gump.syndication package
   __all__ = ["rss","atom"]
   
  -class Syndicator:
  -    def __init__(self):     pass        
  -        
  -    #
  -    # Populate a method called 'document(run)'
  -    #
  -    def syndicate(self,run):
  -        if not hasattr(self,'syndicateRun'):
  -            raise RuntimeException, 'Complete [' + self.__class__ + '] with syndicateRun(self,run)'
  -        
  -        if not callable(self.syndicateRun):
  -            raise RuntimeException, 'Complete [' + self.__class__ + '] with a callable
syndicateRun(self,run)'
  -        
  -        log.info('Syndicate run using [' + `self` + ']')
  -        
  -        self.syndicateRun(run)
  -
  -    def getProjectContent(self,project,run):
  -        
  -        resolver=run.getOptions().getResolver()
  -        
  -        stats=project.getStats()
  -        
  -        content='Project ' + project.getName() \
  -                                + ' : ' \
  -                                + project.getStateDescription() \
  -                                + ' ' \
  -                                + project.getReasonDescription() \
  -                                + '\n\n'
  -                        
  -        if not stats.previousState == STATE_NONE \
  -            and not stats.previousState == STATE_UNSET:
  -            content += 'Previous state: ' \
  -                                    + stateName(stats.previousState)  \
  -                                    + '\n\n'
  -    
  -        self.addSundries(project,content)
  -                
  -        return content
  -
  -    
  -
  -    def getModuletContent(self,module,run):
  -        
  -        resolver=self.run.getOptions().getResolver()
  -        
  -        stats=module.getStats()
  -        
  -        content='Module ' + module.getName() \
  -                                + ' : ' \
  -                                + module.getStateDescription()	\
  -                                + ' ' \
  -                                + module.getReasonDescription() \
  -                                + '\n\n'
  -                        
  -        if not stats.previousState == STATE_NONE \
  -            and not stats.previousState == STATE_UNSET:
  -            content += 'Previous state: ' \
  -                                    + stateName(stats.previousState)  \
  -                                    + '\n\n'
  -    
  -        self.addSundries(module,content)
  -                
  -        return content
  -
  -    def addSundries(self,object,content):
  -        
  -        resolver=self.run.getOptions().getResolver()    
  -        
  -        if object.annotations:
  -            content += '<table>'
  -            for note in object.annotations:
  -                    content += ('<tr><td>' \
  -                        + note.getLevelName() + '</td><td>' \
  -                        + note.getText() + '</td></tr>\n')                
  -            content += '<table>'
  -            
  -        if object.worklist:
  -            content += '<table>'    
  -            for work in object.worklist:
  -                url=resolver.getAbsoluteUrl(work)
  -                state=stateName(work.state)                 
  -                content += ('<tr><td><a href=\'' + 	\
  -                    url + '\'>' + work.getName() + 	\
  -                    '</a></td><td>' + state + 		\
  -                    '</td></tr>\n')                   
  -            content += '<table>'
       
   def syndicate(run):
       
  
  
  
  1.1                  jakarta-gump/python/gump/syndication/syndicator.py
  
  Index: syndicator.py
  ===================================================================
  #!/usr/bin/env python
  
  # $Header: /home/cvs/jakarta-gump/python/gump/rss.py,v 1.7 2003/09/11 21:11:42 ajack Exp
$
  # $Revision: 1.7 $
  # $Date: 2003/09/11 21:11:42 $
  #
  # ====================================================================
  #
  # The Apache Software License, Version 1.1
  #
  # Copyright (c) 2003 The Apache Software Foundation.  All rights
  # reserved.
  #
  # Redistribution and use in source and binary forms, with or without
  # modification, are permitted provided that the following conditions
  # are met:
  #
  # 1. Redistributions of source code must retain the above copyright
  #    notice, this list of conditions and the following disclaimer.
  #
  # 2. Redistributions in binary form must reproduce the above copyright
  #    notice, this list of conditions and the following disclaimer in
  #    the documentation and/or other materials provided with the
  #    distribution.
  #
  # 3. The end-user documentation included with the redistribution, if
  #    any, must include the following acknowlegement:
  #       "This product includes software developed by the
  #        Apache Software Foundation (http://www.apache.org/)."
  #    Alternately, this acknowlegement may appear in the software itself,
  #    if and wherever such third-party acknowlegements normally appear.
  #
  # 4. The names "The Jakarta Project", "Alexandria", and "Apache Software
  #    Foundation" must not be used to endorse or promote products derived
  #    from this software without prior written permission. For written
  #    permission, please contact apache@apache.org.
  #
  # 5. Products derived from this software may not be called "Apache"
  #    nor may "Apache" appear in their names without prior written
  #    permission of the Apache Group.
  #
  # THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  # DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  # ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  # SUCH DAMAGE.
  # ====================================================================
  #
  # This software consists of voluntary contributions made by many
  # individuals on behalf of the Apache Software Foundation.  For more
  # information on the Apache Software Foundation, please see
  # <http://www.apache.org/>.
  
  """
    Highly experimental RSS feeds.
  """
  
  import os
  import time
  
  from xml.sax.saxutils import escape
  
  from gump import log
  from gump.model.state import *
  from gump.model.project import ProjectStatistics
  
  # tell Python what modules make up the gump.syndication package
  __all__ = ["rss","atom"]
  
  class Syndicator:
      def __init__(self):     pass        
          
      #
      # Populate a method called 'document(run)'
      #
      def syndicate(self,run):
          if not hasattr(self,'syndicateRun'):
              raise RuntimeException, 'Complete [' + self.__class__ + '] with syndicateRun(self,run)'
          
          if not callable(self.syndicateRun):
              raise RuntimeException, 'Complete [' + self.__class__ + '] with a callable syndicateRun(self,run)'
          
          log.info('Syndicate run using [' + `self` + ']')
          
          self.syndicateRun(run)
  
      def getProjectContent(self,project,run):
          
          resolver=run.getOptions().getResolver()
          
          stats=project.getStats()
          
          content='Project ' + project.getName() \
                                  + ' : ' \
                                  + project.getStateDescription()
                              
          if not project.getStatePair().isReasonUnset():
             content += ' with reason ' \
                  + project.getReasonDescription()
              
          content += '\n\n'
                          
          if not stats.previousState == STATE_NONE \
              and not stats.previousState == STATE_UNSET:
              content += 'Previous state: ' \
                                      + stateName(stats.previousState)  \
                                      + '\n\n'
      
          self.addSundries(project,content)
                  
          return content
  
      
  
      def getModuletContent(self,module,run):
          
          resolver=self.run.getOptions().getResolver()
          
          stats=module.getStats()
          
          content='Module ' + module.getName() \
                                  + ' : ' \
                                  + module.getStateDescription()	
                              
          if not module.getStatePair().isReasonUnset():
             content += ' with reason ' \
                  + module.getReasonDescription()
              
          content += '\n\n'
                          
          if not stats.previousState == STATE_NONE \
              and not stats.previousState == STATE_UNSET:
              content += 'Previous state: ' \
                                      + stateName(stats.previousState)  \
                                      + '\n\n'
      
          self.addSundries(module,content)
                  
          return content
  
      def addSundries(self,object,content):
          
          resolver=self.run.getOptions().getResolver()    
          
          if object.annotations:
              content += '<table>'
              for note in object.annotations:
                      content += ('<tr><td>' \
                          + note.getLevelName() + '</td><td>' \
                          + note.getText() + '</td></tr>\n')                
              content += '<table>'
              
          if object.worklist:
              content += '<table>'    
              for work in object.worklist:
                  url=resolver.getAbsoluteUrl(work)
                  state=stateName(work.state)                 
                  content += ('<tr><td><a href=\'' + 	\
                      url + '\'>' + work.getName() + 	\
                      '</a></td><td>' + state + 		\
                      '</td></tr>\n')                   
              content += '<table>'
              
          context += '\n\n\n<img alt=\'Brought to you by Jakarta Gump\' src=\'http://jakarta.apache.org/gump/images/bench.png\'/>'
                
  def syndicate(run):
      
      from gump.syndication.rss import RSSSyndicator
      simple=RSSSyndicator()
      simple.syndicate(run)
      
      #atom=AtomSyndicator()
      #atom.syndicate(run)
  
  
  1.3       +2 -1      jakarta-gump/python/gump/utils/commandLine.py
  
  Index: commandLine.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/utils/commandLine.py,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- commandLine.py	24 Nov 2003 16:14:06 -0000	1.2
  +++ commandLine.py	5 Dec 2003 00:51:49 -0000	1.3
  @@ -143,7 +143,8 @@
                   log.setLevel(logging.DEBUG ) 
               elif arg in ['-v','--verbose']: 
                   log.info('Setting log level to VERBOSE')
  -                log.setLevel(logging.VERBOSE )  
  +                # :TODO:
  +                log.setLevel(logging.DEBUG )  
       
       def getArguments(self):
           return self.args
  
  
  
  1.10      +1 -0      jakarta-gump/python/gump/test/model.py
  
  Index: model.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/test/model.py,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- model.py	2 Dec 2003 23:58:47 -0000	1.9
  +++ model.py	5 Dec 2003 00:51:50 -0000	1.10
  @@ -207,6 +207,7 @@
           
       def testJunitReport(self):
                   
  +        self.assertTrue('This has a <junitreport', self.project3.hasReports())
           self.assertLengthAbove('This has a <junitreport', self.project3.getReports(),
0)
           
           for report in self.project3.getReports():
  
  
  

Mime
View raw message