[Libreoffice-commits] dev-tools.git: scripts/bugcommenters-by-target.py

Robinson Tryon qubit at runcibility.com
Wed Sep 17 09:01:15 PDT 2014


 scripts/bugcommenters-by-target.py |   39 +++++++++++++++++++++++++++++++++++--
 1 file changed, 37 insertions(+), 2 deletions(-)

New commits:
commit 95e494703c62c7e5dd29a8c36b2ef7f25fa2b88b
Author: Robinson Tryon <qubit at runcibility.com>
Date:   Wed Sep 17 10:54:46 2014 -0500

    bugcommenters: Add optional 'wiki' format (70col wrap, group by #)
    
    This commit adds support for a new 'wiki' format for the
    bugcommenters. Users are grouped by total # of bug comments, and
    output is wrapped to 70cols max.
    
    USAGE:
      ./bugcommenters-by-target.py 4.3.2 wiki
    
    This format is used on our Releases pages on the wiki. Example:
    https://wiki.documentfoundation.org/Releases/4.3.2/RC2#Thanks_to_all_who_took_part_in_handling_the_issues
    
    Change-Id: I91754a9e951548e59fb307b1cb9584344cdfa3f9

diff --git a/scripts/bugcommenters-by-target.py b/scripts/bugcommenters-by-target.py
index f03b38e..9998072 100755
--- a/scripts/bugcommenters-by-target.py
+++ b/scripts/bugcommenters-by-target.py
@@ -9,6 +9,7 @@
 
 import sys
 import re
+import textwrap
 from urllib.request import urlopen, URLError
 from io import BytesIO
 
@@ -59,8 +60,42 @@ def get_target_toucher_counts(target):
                 touch_counts[toucher]=1
     touch_counts_sorted = reversed(sorted((count, name) for (name, count) in touch_counts.items()))
     return touch_counts_sorted
-    
-if __name__ == '__main__':
+
+# Print one line (wrapped to 70 cols) for each set of users who made
+# the same # of bug comments.
+#
+# (We use this format for Release pages on the wiki)
+def print_for_wiki():
+    counts = {}
+    for count, name in get_target_toucher_counts(sys.argv[1]):
+        if name == 'Commit Notification':
+            # Throw out these lines
+            pass
+        elif count in counts:
+            counts[count] += ", " + name
+        else:
+            counts[count] = name
+
+    # Sort dictionary keys from largest # of comments to least and
+    # print them out.
+    pad = 5
+
+    # Text body is indented 1 additional char from comment count.
+    tw = textwrap.TextWrapper(subsequent_indent=" " * (pad + 1))
+    for count, names in sorted(counts.items(), reverse=True):
+        print("{n:{width}} ".format(n=count, width=pad) + tw.fill(names))
+
+# Print one line for each commenter.
+def print_regular():
     for touch_count in get_target_toucher_counts(sys.argv[1]):
         if not touch_count[1] == 'Commit Notification':
             print("%5d %s" % (touch_count[0], touch_count[1]))
+
+if __name__ == '__main__':
+    if(len(sys.argv) > 2 and
+       sys.argv[2] == "wiki"):
+        print_for_wiki()
+    elif(len(sys.argv) > 1):
+        print_regular()
+    else:
+        print('Error: Please provide a LibreOffice version!')


More information about the Libreoffice-commits mailing list