Changeset 230


Ignore:
Timestamp:
19-05-07 12:52:04 (6 years ago)
Author:
thomas
Message:
  • moap/command/doap.py (Rss.do): break into two lines
  • moap/doap/rss.py (doapsToRss, createdToPubDate, cheetah_toRss): Make the two template language's output as similar as possible.
  • moap/test/Makefile.am:
  • moap/test/rss/mach.rss.cheetah:
  • moap/test/rss/mach.rss.genshi: Add two rss feeds based on the two templating languages.
  • moap/test/test_commands_doap.py (TestDoapMach?.setUp, TestDoapMach?.testRssGenshi, TestDoapMach?.testRssCheetah): Add tests for the specific template languages. Coverage: 72 % ( 844 / 1157)
Location:
trunk
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r228 r230  
     12007-05-19  Thomas Vander Stichele  <thomas at apestaart dot org> 
     2 
     3        * moap/command/doap.py (Rss.do): 
     4          break into two lines 
     5        * moap/doap/rss.py (doapsToRss, createdToPubDate, cheetah_toRss): 
     6          Make the two template language's output as similar as possible. 
     7        * moap/test/Makefile.am: 
     8        * moap/test/rss/mach.rss.cheetah: 
     9        * moap/test/rss/mach.rss.genshi: 
     10          Add two rss feeds based on the two templating languages. 
     11        * moap/test/test_commands_doap.py (TestDoapMach.setUp, 
     12          TestDoapMach.testRssGenshi, TestDoapMach.testRssCheetah): 
     13          Add tests for the specific template languages. 
     14 
     15          Coverage: 72 %   ( 844 / 1157) 
     16 
    1172007-05-19  Thomas Vander Stichele  <thomas at apestaart dot org> 
    218 
  • trunk/moap/command/doap.py

    r228 r230  
    412412 
    413413        # FIXME: if one can be found close to the .doap file, use it 
    414         self.stdout.write(rss.doapsToRss(self.parentCommand.doaps, template, 
    415             templateType=self._language)) 
     414        text = rss.doapsToRss(self.parentCommand.doaps, template, 
     415            templateType=self._language) 
     416        self.stdout.write(text) 
    416417 
    417418class Show(util.LogCommand): 
  • trunk/moap/doap/rss.py

    r228 r230  
    2222    @type  templateType: str 
    2323    @param templateType: cheetah or genshi 
     24 
     25    @rtype: str 
    2426    """ 
    2527    projects = [d.getProject() for d in doaps] 
     
    5052# template language specific templates/handlers 
    5153 
    52 CHEETAH_TEMPLATE = """<rss version="2.0"> 
     54CHEETAH_TEMPLATE = """<rss version="2.0" lang="en"> 
    5355  <channel> 
    5456#set $names = ", ".join([p.name for p in $projects]) 
     
    6163#for $release in $project.release 
    6264#set $v = $release.version 
    63         <item> 
    64           <title>$project.name $v.revision '$v.name' released</title> 
    65             <guid>$project.shortname-$v.revision</guid> 
    66             <link>release-$project.homepage</link> 
    67             <pubDate>$createdToPubDate($v.created)</pubDate> 
    68             <description> 
     65    <item> 
     66      <title>$project.name $v.revision '$v.name' released</title> 
     67      <guid>release-$project.shortname-$v.revision</guid> 
     68      <link>$project.homepage</link> 
     69      <pubDate>$createdToPubDate($v.created)</pubDate> 
     70      <description> 
    6971For more information, visit 
    7072&lt;A HREF="$project.homepage"&gt;the project homepage&lt;/A&gt; 
    71             </description> 
     73      </description> 
     74    </item> 
    7275#end for 
    7376#end for 
     
    8386        template = CHEETAH_TEMPLATE 
    8487 
    85     t = Cheetah.Template.Template(template, searchList={ 
     88    t = Cheetah.Template.Template(template, searchList=[ 
     89    { 
    8690        'projects': projects, 
    8791        'createdToPubDate': createdToPubDate 
    88     }) 
    89     return t 
     92    }]) 
     93    return str(t) 
    9094 
    9195GENSHI_TEMPLATE = """<rss version="2.0" 
     
    9397            lang="en"> 
    9498  <channel> 
    95     <title>${projects[0].name}</title> 
     99    <title>Release feed for ${projects[0].name}</title> 
     100    <description>Release feed for ${projects[0].name}</description> 
     101    <link>${projects[0].homepage}</link> 
    96102    <language>en</language> 
    97103 
    98104    <py:for each="project in projects"> 
    99       <item py:for="release in project.release"> 
    100         <py:with vars="v=release.version; 
    101                        n=v.name; 
    102                       "> 
    103           <title>${project.name} ${v.revision} '${v.name}' released</title> 
    104           <link>${project.homepage}</link> 
    105           <guid>release-${project.shortname}-${v.revision}</guid> 
    106           <pubdate>${createdToPubDate(v.created)}</pubdate> 
    107           <description> 
     105    <item py:for="release in project.release"> 
     106      <py:with vars="v=release.version; 
     107                     n=v.name; 
     108                    "> 
     109      <title>${project.name} ${v.revision} '${v.name}' released</title> 
     110      <guid>release-${project.shortname}-${v.revision}</guid> 
     111      <link>${project.homepage}</link> 
     112      <pubDate>${createdToPubDate(v.created)}</pubDate> 
     113      <description> 
    108114For more information, visit 
    109115&lt;A HREF="${project.homepage}"&gt;the project homepage&lt;/A&gt; 
    110           </description> 
    111         </py:with> 
    112       </item> 
     116      </description> 
     117      </py:with> 
     118    </item> 
    113119    </py:for> 
    114120 
  • trunk/moap/test/Makefile.am

    r228 r230  
    2121        doap/mach.doap \ 
    2222        ical/mach.ical \ 
    23         rss/mach.rss \ 
     23        rss/mach.rss.cheetah \ 
     24        rss/mach.rss.genshi \ 
    2425        diff/svn_add_one_line.diff \ 
    2526        diff/svn_multiple.diff \ 
     
    3233        make $* 
    3334 
    34 rss/mach.rss: 
    35         moap doap -f doap/mach.doap rss > $@ 
     35rss/mach.rss.cheetah: 
     36        moap doap -f doap/mach.doap rss -t cheetah > $@ 
     37 
     38rss/mach.rss.genshi: 
     39        moap doap -f doap/mach.doap rss -t genshi > $@ 
  • trunk/moap/test/rss/mach.rss.genshi

    r229 r230  
    11<rss version="2.0" lang="en"> 
    22  <channel> 
    3     <title>Mach</title> 
     3    <title>Release feed for Mach</title> 
     4    <description>Release feed for Mach</description> 
     5    <link>http://thomas.apestaart.org/projects/mach/</link> 
    46    <language>en</language> 
    5       <item> 
    6           <title>Mach 0.9.0 'Cambria' released</title> 
    7           <link>http://thomas.apestaart.org/projects/mach/</link> 
    8           <guid>release-mach-0.9.0</guid> 
    9           <pubdate>Fri, 09 Jun 2006 00:00:00 +0000</pubdate> 
    10           <description> 
     7    <item> 
     8      <title>Mach 0.9.0 'Cambria' released</title> 
     9      <guid>release-mach-0.9.0</guid> 
     10      <link>http://thomas.apestaart.org/projects/mach/</link> 
     11      <pubDate>Fri, 09 Jun 2006 00:00:00 +0000</pubDate> 
     12      <description> 
    1113For more information, visit 
    1214&lt;A HREF="http://thomas.apestaart.org/projects/mach/"&gt;the project homepage&lt;/A&gt; 
    13           </description> 
    14       </item><item> 
    15           <title>Mach 0.4.9 'China' released</title> 
    16           <link>http://thomas.apestaart.org/projects/mach/</link> 
    17           <guid>release-mach-0.4.9</guid> 
    18           <pubdate>Sat, 08 Apr 2006 00:00:00 +0000</pubdate> 
    19           <description> 
     15      </description> 
     16    </item><item> 
     17      <title>Mach 0.4.9 'China' released</title> 
     18      <guid>release-mach-0.4.9</guid> 
     19      <link>http://thomas.apestaart.org/projects/mach/</link> 
     20      <pubDate>Sat, 08 Apr 2006 00:00:00 +0000</pubDate> 
     21      <description> 
    2022For more information, visit 
    2123&lt;A HREF="http://thomas.apestaart.org/projects/mach/"&gt;the project homepage&lt;/A&gt; 
    22           </description> 
    23       </item><item> 
    24           <title>Mach 0.4.8 'More Than One' released</title> 
    25           <link>http://thomas.apestaart.org/projects/mach/</link> 
    26           <guid>release-mach-0.4.8</guid> 
    27           <pubdate>Mon, 21 Nov 2005 00:00:00 +0000</pubdate> 
    28           <description> 
     24      </description> 
     25    </item><item> 
     26      <title>Mach 0.4.8 'More Than One' released</title> 
     27      <guid>release-mach-0.4.8</guid> 
     28      <link>http://thomas.apestaart.org/projects/mach/</link> 
     29      <pubDate>Mon, 21 Nov 2005 00:00:00 +0000</pubDate> 
     30      <description> 
    2931For more information, visit 
    3032&lt;A HREF="http://thomas.apestaart.org/projects/mach/"&gt;the project homepage&lt;/A&gt; 
    31           </description> 
    32       </item><item> 
    33           <title>Mach 0.4.7 'Long Time No See' released</title> 
    34           <link>http://thomas.apestaart.org/projects/mach/</link> 
    35           <guid>release-mach-0.4.7</guid> 
    36           <pubdate>Sun, 03 Jul 2005 00:00:00 +0000</pubdate> 
    37           <description> 
     33      </description> 
     34    </item><item> 
     35      <title>Mach 0.4.7 'Long Time No See' released</title> 
     36      <guid>release-mach-0.4.7</guid> 
     37      <link>http://thomas.apestaart.org/projects/mach/</link> 
     38      <pubDate>Sun, 03 Jul 2005 00:00:00 +0000</pubDate> 
     39      <description> 
    3840For more information, visit 
    3941&lt;A HREF="http://thomas.apestaart.org/projects/mach/"&gt;the project homepage&lt;/A&gt; 
    40           </description> 
    41       </item><item> 
    42           <title>Mach 0.4.6 'Lenrek' released</title> 
    43           <link>http://thomas.apestaart.org/projects/mach/</link> 
    44           <guid>release-mach-0.4.6</guid> 
    45           <pubdate>Tue, 08 Feb 2005 00:00:00 +0000</pubdate> 
    46           <description> 
     42      </description> 
     43    </item><item> 
     44      <title>Mach 0.4.6 'Lenrek' released</title> 
     45      <guid>release-mach-0.4.6</guid> 
     46      <link>http://thomas.apestaart.org/projects/mach/</link> 
     47      <pubDate>Tue, 08 Feb 2005 00:00:00 +0000</pubDate> 
     48      <description> 
    4749For more information, visit 
    4850&lt;A HREF="http://thomas.apestaart.org/projects/mach/"&gt;the project homepage&lt;/A&gt; 
    49           </description> 
    50       </item><item> 
    51           <title>Mach 0.4.5 'Snow' released</title> 
    52           <link>http://thomas.apestaart.org/projects/mach/</link> 
    53           <guid>release-mach-0.4.5</guid> 
    54           <pubdate>Thu, 18 Mar 2004 00:00:00 +0000</pubdate> 
    55           <description> 
     51      </description> 
     52    </item><item> 
     53      <title>Mach 0.4.5 'Snow' released</title> 
     54      <guid>release-mach-0.4.5</guid> 
     55      <link>http://thomas.apestaart.org/projects/mach/</link> 
     56      <pubDate>Thu, 18 Mar 2004 00:00:00 +0000</pubDate> 
     57      <description> 
    5658For more information, visit 
    5759&lt;A HREF="http://thomas.apestaart.org/projects/mach/"&gt;the project homepage&lt;/A&gt; 
    58           </description> 
    59       </item><item> 
    60           <title>Mach 0.4.4 'Madrid' released</title> 
    61           <link>http://thomas.apestaart.org/projects/mach/</link> 
    62           <guid>release-mach-0.4.4</guid> 
    63           <pubdate>Thu, 11 Mar 2004 00:00:00 +0000</pubdate> 
    64           <description> 
     60      </description> 
     61    </item><item> 
     62      <title>Mach 0.4.4 'Madrid' released</title> 
     63      <guid>release-mach-0.4.4</guid> 
     64      <link>http://thomas.apestaart.org/projects/mach/</link> 
     65      <pubDate>Thu, 11 Mar 2004 00:00:00 +0000</pubDate> 
     66      <description> 
    6567For more information, visit 
    6668&lt;A HREF="http://thomas.apestaart.org/projects/mach/"&gt;the project homepage&lt;/A&gt; 
    67           </description> 
    68       </item><item> 
    69           <title>Mach 0.4.3 'Hot Water' released</title> 
    70           <link>http://thomas.apestaart.org/projects/mach/</link> 
    71           <guid>release-mach-0.4.3</guid> 
    72           <pubdate>Tue, 16 Dec 2003 00:00:00 +0000</pubdate> 
    73           <description> 
     69      </description> 
     70    </item><item> 
     71      <title>Mach 0.4.3 'Hot Water' released</title> 
     72      <guid>release-mach-0.4.3</guid> 
     73      <link>http://thomas.apestaart.org/projects/mach/</link> 
     74      <pubDate>Tue, 16 Dec 2003 00:00:00 +0000</pubDate> 
     75      <description> 
    7476For more information, visit 
    7577&lt;A HREF="http://thomas.apestaart.org/projects/mach/"&gt;the project homepage&lt;/A&gt; 
    76           </description> 
    77       </item><item> 
    78           <title>Mach 0.4.2 'No More Betas' released</title> 
    79           <link>http://thomas.apestaart.org/projects/mach/</link> 
    80           <guid>release-mach-0.4.2</guid> 
    81           <pubdate>Tue, 21 Oct 2003 00:00:00 +0000</pubdate> 
    82           <description> 
     78      </description> 
     79    </item><item> 
     80      <title>Mach 0.4.2 'No More Betas' released</title> 
     81      <guid>release-mach-0.4.2</guid> 
     82      <link>http://thomas.apestaart.org/projects/mach/</link> 
     83      <pubDate>Tue, 21 Oct 2003 00:00:00 +0000</pubDate> 
     84      <description> 
    8385For more information, visit 
    8486&lt;A HREF="http://thomas.apestaart.org/projects/mach/"&gt;the project homepage&lt;/A&gt; 
    85           </description> 
    86       </item><item> 
    87           <title>Mach 0.4.1 'Get A Room' released</title> 
    88           <link>http://thomas.apestaart.org/projects/mach/</link> 
    89           <guid>release-mach-0.4.1</guid> 
    90           <pubdate>Fri, 10 Oct 2003 00:00:00 +0000</pubdate> 
    91           <description> 
     87      </description> 
     88    </item><item> 
     89      <title>Mach 0.4.1 'Get A Room' released</title> 
     90      <guid>release-mach-0.4.1</guid> 
     91      <link>http://thomas.apestaart.org/projects/mach/</link> 
     92      <pubDate>Fri, 10 Oct 2003 00:00:00 +0000</pubDate> 
     93      <description> 
    9294For more information, visit 
    9395&lt;A HREF="http://thomas.apestaart.org/projects/mach/"&gt;the project homepage&lt;/A&gt; 
    94           </description> 
    95       </item><item> 
    96           <title>Mach 0.4.0 'Barcelona' released</title> 
    97           <link>http://thomas.apestaart.org/projects/mach/</link> 
    98           <guid>release-mach-0.4.0</guid> 
    99           <pubdate>Mon, 08 Sep 2003 00:00:00 +0000</pubdate> 
    100           <description> 
     96      </description> 
     97    </item><item> 
     98      <title>Mach 0.4.0 'Barcelona' released</title> 
     99      <guid>release-mach-0.4.0</guid> 
     100      <link>http://thomas.apestaart.org/projects/mach/</link> 
     101      <pubDate>Mon, 08 Sep 2003 00:00:00 +0000</pubDate> 
     102      <description> 
    101103For more information, visit 
    102104&lt;A HREF="http://thomas.apestaart.org/projects/mach/"&gt;the project homepage&lt;/A&gt; 
    103           </description> 
    104       </item> 
     105      </description> 
     106    </item> 
    105107  </channel> 
    106108</rss> 
  • trunk/moap/test/test_commands_doap.py

    r228 r230  
    1717        self.ical = os.path.join(os.path.dirname(__file__), 'ical', 
    1818            'mach.ical') 
    19         self.rss = os.path.join(os.path.dirname(__file__), 'rss', 
    20             'mach.rss') 
     19        self.grss = os.path.join(os.path.dirname(__file__), 'rss', 
     20            'mach.rss.genshi') 
     21        self.crss = os.path.join(os.path.dirname(__file__), 'rss', 
     22            'mach.rss.cheetah') 
    2123        self.stdout = StringIO.StringIO() 
    2224        self.command = doap.Doap(stdout=self.stdout) 
     
    2729        self.assertEquals(self.stdout.getvalue(), ref) 
    2830 
    29     def testRss(self): 
     31    def testRssGenshi(self): 
    3032        ret = self.command.parse(['-f', self.doap, 'rss']) 
    31         ref = open(self.rss).read() 
     33        ref = open(self.grss).read() 
     34        self.assertEquals(self.stdout.getvalue(), ref) 
     35 
     36    def testRssCheetah(self): 
     37        ret = self.command.parse(['-f', self.doap, 'rss', '-t', 'cheetah']) 
     38        ref = open(self.crss).read() 
    3239        self.assertEquals(self.stdout.getvalue(), ref) 
    3340 
Note: See TracChangeset for help on using the changeset viewer.