Author: julianfoad
Date: Mon Jun  6 14:23:36 2011
New Revision: 1132657

URL: http://svn.apache.org/viewvc?rev=1132657&view=rev
Log:
Add textual bar graphs to the translation status report.

* tools/po/l10n-report.py
  (bar_graph): New function.
  (main): Append a bar graph to each row of statistics.

Modified:
    subversion/trunk/tools/po/l10n-report.py

Modified: subversion/trunk/tools/po/l10n-report.py
URL: 
http://svn.apache.org/viewvc/subversion/trunk/tools/po/l10n-report.py?rev=1132657&r1=1132656&r2=1132657&view=diff
==============================================================================
--- subversion/trunk/tools/po/l10n-report.py (original)
+++ subversion/trunk/tools/po/l10n-report.py Mon Jun  6 14:23:36 2011
@@ -133,6 +133,25 @@ class l10nReport:
         self.safe_command(cmd)
 
 
+def bar_graph(nominal_length, trans, untrans, fuzzy, obsolete):
+    """Format the given four counts into a bar graph string in which the
+    total length of the bars representing the TRANS, UNTRANS and FUZZY
+    counts is NOMINAL_LENGTH characters, and the bar representing the
+    OBSOLETE count extends beyond that."""
+
+    total_count = trans + untrans + fuzzy  # don't include 'obsolete'
+    accum_bar = 0
+    accum_count = 0
+    s = ''
+    for count, letter in [(trans, '+'), (untrans, 'U'), (fuzzy, '~'),
+                          (obsolete, 'o')]:
+        accum_count += count
+        new_bar_end = nominal_length * accum_count / total_count
+        s += letter * (new_bar_end - accum_bar)
+        accum_bar = new_bar_end
+    return s
+
+
 def main():
     # Parse the command-line options and arguments.
     try:
@@ -187,6 +206,7 @@ def main():
         [trans, untrans, fuzzy, obsolete]  = l10n.get_msgattribs(file)
         po_format = "%6s %7d %7d %7d %7d" %\
                     (lang, trans, untrans, fuzzy, obsolete)
+        po_format += "  " + bar_graph(30, trans, untrans, fuzzy, obsolete)
         body += "%s\n" % po_format
         print(po_format)
 


Reply via email to