Changeset 206


Ignore:
Timestamp:
22-04-07 22:22:43 (6 years ago)
Author:
thomas
Message:
  • moap/command/doap.py (Rss, Rss.addOptions, Rss.handleOptions, Rss.do, Show, Doap, Doap.handleOptions):
  • moap/doap/Makefile.am:
  • moap/doap/rss.py (doapsToRss, createdToPubDate, cheetah_toRss, genshi_toRss): Add RSS feed generation based on Genshi or Cheetah templates.
Location:
trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r205 r206  
     12007-04-22  Thomas Vander Stichele  <thomas at apestaart dot org> 
     2 
     3        * moap/command/doap.py (Rss, Rss.addOptions, Rss.handleOptions, Rss.do, 
     4          Show, Doap, Doap.handleOptions): 
     5        * moap/doap/Makefile.am: 
     6        * moap/doap/rss.py (doapsToRss, createdToPubDate, cheetah_toRss, 
     7          genshi_toRss): 
     8          Add RSS feed generation based on Genshi or Cheetah templates. 
     9 
    1102007-04-22  Thomas Vander Stichele  <thomas at apestaart dot org> 
    211 
  • trunk/moap/command/doap.py

    r197 r206  
    297297        return 0 
    298298 
     299class Rss(util.LogCommand): 
     300    description = "Output RSS 2 feed from project releases" 
     301 
     302    def addOptions(self): 
     303        self.parser.add_option('-t', '--template-language', 
     304            action="store", dest="language", 
     305            help="template language to use (genshi/cheetah)") 
     306 
     307    def handleOptions(self, options): 
     308        self._language = options.language or 'genshi' 
     309 
     310    def do(self, args): 
     311        from moap.doap import rss 
     312        template = None 
     313 
     314        # if one is specified, prefer it 
     315        if args: 
     316            # FIXME: maybe find a default one based on the doap name ? 
     317            # like .doap -> .rss2.tmpl ? 
     318            path = args[0] 
     319            try: 
     320                handle = open(path) 
     321                template = handle.read() 
     322                handle.close() 
     323            except: 
     324                self.stderr.write("Could not read template %s.\n" % path) 
     325                return 3 
     326            self.debug("Using requested template %s" % template) 
     327 
     328        # if one can be found close to the .doap file, use it 
     329 
     330        print rss.doapsToRss([self.parentCommand.doap, ], template, 
     331            templateType=self._language) 
     332 
    299333class Show(util.LogCommand): 
    300334    description = "Show project information" 
     
    332366    usage = "doap [doap-options] %command" 
    333367    description = "read and act on DOAP file" 
    334     subCommandClasses = [Freshmeat, Ical, Mail, Show, bug.Bug] 
     368    subCommandClasses = [Freshmeat, Ical, Mail, Rss, Show, bug.Bug] 
    335369 
    336370    doap = None 
     
    363397 
    364398            return 
    365  
    366399 
    367400        for p in self.paths: 
  • trunk/moap/doap/Makefile.am

    r35 r206  
    44        __init__.py \ 
    55        common.py \ 
    6         doap.py 
     6        doap.py \ 
     7        rss.py 
Note: See TracChangeset for help on using the changeset viewer.