incubator-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1387306 - in /incubator/public/trunk: build.xml clutch.py current.pl current.xsl entry.xsl
Date Tue, 18 Sep 2012 18:25:37 GMT
Author: sebb
Date: Tue Sep 18 18:25:37 2012
New Revision: 1387306

URL: http://svn.apache.org/viewvc?rev=1387306&view=rev
Log:
Auto-generate history files.

Added:
    incubator/public/trunk/current.pl   (with props)
    incubator/public/trunk/current.xsl   (with props)
    incubator/public/trunk/entry.xsl   (with props)
Modified:
    incubator/public/trunk/build.xml
    incubator/public/trunk/clutch.py

Modified: incubator/public/trunk/build.xml
URL: http://svn.apache.org/viewvc/incubator/public/trunk/build.xml?rev=1387306&r1=1387305&r2=1387306&view=diff
==============================================================================
--- incubator/public/trunk/build.xml (original)
+++ incubator/public/trunk/build.xml Tue Sep 18 18:25:37 2012
@@ -35,7 +35,8 @@
         </echo>
     </target>
 
-    <target name="docs" depends="prepare-error,generate-site-map,generate-menu,generate-index,report-groups,report-next-month"
if="AnakiaTask.present"
+    <target name="docs" depends="prepare-error,generate-site-map,generate-menu,generate-index,report-groups,report-next-month,history"
+        if="AnakiaTask.present"
         description="Build all the documents">
         <taskdef name="anakia" classname="org.apache.anakia.AnakiaTask">
             <classpath refid="classpath"/>
@@ -326,5 +327,31 @@ Audit Tasks
         style='report-next-month.xsl'>
       </xslt>
   </target>
-  
+
+  <target name="__history_current">
+    <xslt force="true"
+      in="${docs.src}/podlings.xml"
+      out="${docs.dest}/history/current.tmp"
+      style="current.xsl">
+    </xslt>
+    <exec executable="perl" logerror="true" failonerror="true" failifexecutionfails="true">
+      <arg value="-f"/>
+      <arg value="current.pl"/>
+      <arg value="-o"/>
+      <arg value="${docs.dest}/history/current.txt"/>
+      <arg value="${docs.dest}/history/current.tmp"/>
+    </exec>
+  </target>
+
+  <target name="__history_entry">
+    <xslt
+      in="${docs.src}/podlings.xml"
+      out="${docs.dest}/history/entry.txt"
+      style="entry.xsl">
+    </xslt>
+  </target>
+
+  <target name="history" depends="__history_current,__history_entry"
+       description="Generate entry.txt and current.txt history files"/>
+
 </project>

Modified: incubator/public/trunk/clutch.py
URL: http://svn.apache.org/viewvc/incubator/public/trunk/clutch.py?rev=1387306&r1=1387305&r2=1387306&view=diff
==============================================================================
--- incubator/public/trunk/clutch.py (original)
+++ incubator/public/trunk/clutch.py Tue Sep 18 18:25:37 2012
@@ -60,7 +60,6 @@ SITE_CONTENT/clutchmy.ent
 SITE_CONTENT/report_due_1.txt
 SITE_CONTENT/report_due_2.txt
 SITE_CONTENT/report_due_3.txt
-SITE_CONTENT/history/entry.txt
 
 Pickle file:
 - clutch.pkl (I/O)
@@ -208,7 +207,6 @@ inputFile.close()
 dom = xml.dom.minidom.parse(SITE_CONTENT_DIR + "podlings.xml")
 
 graduatedProjects = {}
-history = {}
 graduates = []
 
 print("Gather data from podlings.xml ...")
@@ -301,25 +299,6 @@ for row in dom.getElementsByTagName("pod
         else:
           projects[id]['reportingGroup'] = 'group-'+group
 
-  history[id] = {}
-  history[id]['name'] = name
-  match = re.search(startDateRE, startDate)
-  if match:
-    if match.group(3) != None:
-      entryDateDay = int(match.group(3))
-    else:
-      entryDateDay = 1
-    if match.group(2) != None:
-      entryDateMonth = int(match.group(2))
-    else:
-      entryDateMonth = 1
-    try:
-      entryDate = datetime.datetime(int(match.group(1)), entryDateMonth, entryDateDay)
-    except ValueError:
-      print("ERROR: {0}: ValueError with date".format(id))
-    else:
-      history[id]['startDate'] = entryDate
-
 dom.unlink()
 
 # Process the incubation table data, detect some potential issues. ---
@@ -1129,17 +1108,6 @@ fileReport3 = open(SITE_CONTENT_DIR + 'r
 fileReport3.write(reportList3)
 fileReport3.close()
 
-fileHistory = open(SITE_CONTENT_DIR + 'history/entry.txt', 'w')
-fileHistory.write('# podlings entered incubation\n')
-sequence = len(history) + 1
-# sorted by name then date
-historyS = sorted(history.items(), key=lambda x: x[1]['name'])
-for item in sorted(historyS, key=lambda x: x[1]['startDate'], reverse=True):
-  sequence -= 1
-  startDate = item[1]['startDate'].strftime("%Y-%m-%d")
-  fileHistory.write('{0},"{1}",{2}\n'.format(startDate, item[1]['name'], sequence))
-fileHistory.close()
-
 # Create the persistent data file.
 outputFile = open('clutch.pkl', 'wb')
 pickle.dump(persist, outputFile, pickle.HIGHEST_PROTOCOL)

Added: incubator/public/trunk/current.pl
URL: http://svn.apache.org/viewvc/incubator/public/trunk/current.pl?rev=1387306&view=auto
==============================================================================
--- incubator/public/trunk/current.pl (added)
+++ incubator/public/trunk/current.pl Tue Sep 18 18:25:37 2012
@@ -0,0 +1,50 @@
+# Process current list to calculate active podlings - rather tricky to do this in XSLT
+
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing,
+#  software distributed under the License is distributed on an
+#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#  KIND, either express or implied.  See the License for the
+#  specific language governing permissions and limitations
+#  under the License. 
+
+use strict;
+if ($ARGV[0] eq '-o') {
+    shift;
+    open OUT,">",shift;
+    select OUT;   
+}
+my $last;
+my $lastcount;
+my $active=0;
+while(<>){
+    if (m(^#)) {
+        print;
+        next;
+    }
+    chomp;
+    my ($date,$name,$type)=split(/,/);
+    if ($type == 1) {
+        $active++; 
+    } elsif ($type == 2){
+        $active--;        
+    } else {
+        print STDERR "Unrecognised type $type in $_\n";
+    }
+    if ($date ne $last && defined($last)) {
+        print "$last,$lastcount\n";   
+    }
+    $last=$date;
+    $lastcount=$active;
+}
+print "$last,$lastcount\n";   
+close OUT;
\ No newline at end of file

Propchange: incubator/public/trunk/current.pl
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/public/trunk/current.xsl
URL: http://svn.apache.org/viewvc/incubator/public/trunk/current.xsl?rev=1387306&view=auto
==============================================================================
--- incubator/public/trunk/current.xsl (added)
+++ incubator/public/trunk/current.xsl Tue Sep 18 18:25:37 2012
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License. 
+-->
+<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
+                xmlns:exsl="http://exslt.org/common"
+                version='1.0'>
+
+<xsl:output method='text' indent='no' encoding='utf-8'/>
+
+<xsl:template match='podlings'>
+    <xsl:text># total in incubation
+</xsl:text>
+
+    <!-- Generate document containing list of start and end dates -->
+    <xsl:variable name="workDoc">
+        <!-- Generate start date entries -->
+        <xsl:for-each select="podling">
+            <xsl:element name="entry">
+                <xsl:attribute name="type">1</xsl:attribute>
+                <xsl:attribute name="date">
+                    <xsl:value-of select="@startdate"/>
+                    <xsl:if test="string-length(@startdate)=7"><xsl:text>-01</xsl:text></xsl:if>
+                </xsl:attribute>
+                <xsl:attribute name="name">
+                    <xsl:value-of select="@name"/>
+                </xsl:attribute>
+            </xsl:element>
+        </xsl:for-each>
+        <!-- Generate end date entries -->
+        <xsl:for-each select="podling[@enddate]">
+            <xsl:element name="entry">
+                <xsl:attribute name="type">2</xsl:attribute>
+                <xsl:attribute name="date">
+                    <xsl:value-of select="@enddate"/>
+                    <!-- If day is missing, assume 01 -->
+                    <xsl:if test="string-length(@enddate)=7"><xsl:text>-01</xsl:text></xsl:if>
+                </xsl:attribute>
+                <xsl:attribute name="name">
+                    <xsl:value-of select="@name"/>
+                </xsl:attribute>
+             </xsl:element>
+        </xsl:for-each>
+    </xsl:variable>
+    
+    <!-- Sort the list by date then type -->
+    <xsl:variable name="sortedDoc">
+        <xsl:for-each select="exsl:node-set($workDoc)/entry">
+            <xsl:sort select="@date"/>
+            <xsl:sort select="@type"/>
+            <xsl:copy-of select="."/>
+        </xsl:for-each>
+    </xsl:variable>
+    
+    <!-- extract the sorted data -->
+    <!--
+          N.B. It's not trivial to keep a running total with only one output per date in
xslt,
+          so this is done in a separate Perl script for now.
+     -->
+    <xsl:for-each select="exsl:node-set($sortedDoc)/entry">
+        <xsl:value-of select="@date"/>
+        <xsl:text>,"</xsl:text>
+        <xsl:value-of select="@name"/>
+        <xsl:text>"</xsl:text>
+        <xsl:text>,</xsl:text>
+        <xsl:value-of select="@type"/>
+        <xsl:text>
+</xsl:text>
+    </xsl:for-each>
+</xsl:template>
+
+</xsl:stylesheet>

Propchange: incubator/public/trunk/current.xsl
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/public/trunk/entry.xsl
URL: http://svn.apache.org/viewvc/incubator/public/trunk/entry.xsl?rev=1387306&view=auto
==============================================================================
--- incubator/public/trunk/entry.xsl (added)
+++ incubator/public/trunk/entry.xsl Tue Sep 18 18:25:37 2012
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License. 
+-->
+<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>
+
+<xsl:output method='text' indent='no' encoding='utf-8'/>
+
+<!--
+ -->
+
+<xsl:template match="text()"/>
+
+<xsl:template match='podlings'>
+    <xsl:text># podlings entered incubation
+</xsl:text>
+    <xsl:variable name="total">
+        <xsl:value-of select="count(podling)+1"/>
+    </xsl:variable>
+    <xsl:for-each select="podling">
+        <xsl:sort select="@startdate" order="descending"/>
+        <xsl:sort select="@name" order="ascending"/>
+        <xsl:value-of select="@startdate"/>
+        <!-- If day is missing, assume 01 -->
+        <xsl:if test="string-length(@startdate)=7"><xsl:text>-01</xsl:text></xsl:if>
+        <xsl:text>,"</xsl:text><xsl:value-of select="@name"/><xsl:text>",</xsl:text>
+        <xsl:value-of select="$total - position()"/>
+        <xsl:text>
+</xsl:text>
+    </xsl:for-each>
+
+</xsl:template>
+
+</xsl:stylesheet>

Propchange: incubator/public/trunk/entry.xsl
------------------------------------------------------------------------------
    svn:eol-style = native



---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@incubator.apache.org
For additional commands, e-mail: cvs-help@incubator.apache.org


Mime
View raw message