[yelp-tools] yelp-check: Added --totals to yelp-check status



commit ad1cf2b7bbd40b84f6ad8179d5995001b0666d27
Author: Shaun McCance <shaunm gnome org>
Date:   Mon May 23 12:33:07 2011 -0400

    yelp-check: Added --totals to yelp-check status

 tools/yelp-check.in |    6 ++++++
 xslt/mal-status.xsl |   42 +++++++++++++++++++++++++++++++++++++++---
 2 files changed, 45 insertions(+), 3 deletions(-)
---
diff --git a/tools/yelp-check.in b/tools/yelp-check.in
index 4c8006a..79951b0 100755
--- a/tools/yelp-check.in
+++ b/tools/yelp-check.in
@@ -94,6 +94,7 @@ yelp_usage_status () {
         echo "  --newer DATE        Only show pages newer than DATE"
         echo "  --only STATUSES     Only show pages whose status is in STATUSES"
         echo "  --except STATUSES   Exclude pages whose status is in STATUSES"
+        echo "  --totals            Show total counts for each status"
         echo "For --only and --except, STATUSES is a space-separated list."
     ) 1>&2
 }
@@ -311,6 +312,10 @@ yelp_status () {
                 check_except="$1"
                 shift
                 ;;
+            "--totals")
+                check_totals="1"
+                shift
+                ;;
             *)
                 break
                 ;;
@@ -330,6 +335,7 @@ yelp_status () {
         --stringparam older "$check_older" \
         --stringparam only "$check_only" \
         --stringparam except "$check_except" \
+        --stringparam totals "$check_totals" \
         "$xsl_mal_status" "$check_cache_file"
     rm "$check_cache_file"
     return 0
diff --git a/xslt/mal-status.xsl b/xslt/mal-status.xsl
index 11bf31d..3e95dba 100644
--- a/xslt/mal-status.xsl
+++ b/xslt/mal-status.xsl
@@ -3,6 +3,7 @@
     xmlns:mal="http://projectmallard.org/1.0/";
     xmlns:cache="http://projectmallard.org/cache/1.0/";
     xmlns:exsl="http://exslt.org/common";
+    xmlns:str="http://exslt.org/strings";
     xmlns:dyn="http://exslt.org/dynamic";
     exclude-result-prefixes="mal cache exsl dyn"
     version="1.0">
@@ -21,6 +22,32 @@
 <xsl:param name="except" select="''"/>
 <xsl:variable name="except_" select="concat(' ', $except, ' ')"/>
 
+<xsl:param name="totals" select="''"/>
+
+<xsl:template match="/">
+  <xsl:choose>
+    <xsl:when test="$totals = '1'">
+      <xsl:variable name="statuses">
+        <xsl:apply-templates/>
+      </xsl:variable>
+      <xsl:variable name="stlist" select="str:split($statuses)"/>
+      <xsl:for-each select="$stlist">
+        <xsl:sort select="string(.)"/>
+        <xsl:variable name="stval" select="string(.)"/>
+        <xsl:if test="not(preceding-sibling::*[string(.) = $stval])">
+          <xsl:value-of select="$stval"/>
+          <xsl:text>: </xsl:text>
+          <xsl:value-of select="count($stlist[string(.) = $stval])"/>
+          <xsl:text>&#x000A;</xsl:text>
+        </xsl:if>
+      </xsl:for-each>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:apply-templates/>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
 <xsl:template match="/cache:cache">
   <xsl:for-each select="mal:page">
     <xsl:sort select="@id"/>
@@ -67,10 +94,19 @@
                       (translate($revision/@date, '-', '') &lt; translate($older, '-', '')))">
           <xsl:if test="$newer = '' or ($revision/@date and
                         (translate($revision/@date, '-', '') &gt; translate($newer, '-', '')))">
-            <xsl:value-of select="@id"/>
-            <xsl:text>: </xsl:text>
+            <xsl:if test="$totals != '1'">
+              <xsl:value-of select="@id"/>
+              <xsl:text>: </xsl:text>
+            </xsl:if>
             <xsl:value-of select="$status"/>
-            <xsl:text>&#x000A;</xsl:text>
+            <xsl:choose>
+              <xsl:when test="$totals != '1'">
+                <xsl:text>&#x000A;</xsl:text>
+              </xsl:when>
+              <xsl:otherwise>
+                <xsl:text> </xsl:text>
+              </xsl:otherwise>
+            </xsl:choose>
           </xsl:if>
         </xsl:if>
       </xsl:if>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]