incubator-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject svn commit: r1537793 - /incubator/public/trunk/clutch2report.py
Date Fri, 01 Nov 2013 01:02:34 GMT
Author: marvin
Date: Fri Nov  1 01:02:34 2013
New Revision: 1537793

URL: http://svn.apache.org/r1537793
Log:
Add shepherd assignments to autogenerated wiki report template.

Additionally, add subheadings and flesh out a complete wiki page instead
of generatig merely the report text.

Modified:
    incubator/public/trunk/clutch2report.py

Modified: incubator/public/trunk/clutch2report.py
URL: http://svn.apache.org/viewvc/incubator/public/trunk/clutch2report.py?rev=1537793&r1=1537792&r2=1537793&view=diff
==============================================================================
--- incubator/public/trunk/clutch2report.py (original)
+++ incubator/public/trunk/clutch2report.py Fri Nov  1 01:02:34 2013
@@ -8,6 +8,8 @@ import textwrap
 import calendar
 import xmlrpc
 import xmlrpc.client
+import json
+import os
 
 '''
 'clutch2report' reads the pickle file which was created by 'clutch' and generates
@@ -20,6 +22,13 @@ months2groups = [ 'group-1', 'group-2', 
                   'group-1', 'group-2', 'group-3']
 
 boilerplate = """
+= Incubator PMC report for {month} 2013 =
+
+=== Shepherd Assignments ===
+{shepherds}
+
+=== Report content ===
+{{{{{{
 Incubator PMC report for {month} 2013
 
 The Apache Incubator is the entry path into the ASF for projects and codebases
@@ -148,7 +157,7 @@ def push(name, password, pagename, repor
     token =  srcwiki.getAuthToken(name, password)
     
     pushresults = srcwiki.system.multicall([{'methodName':'applyAuthToken', 'params': [token]},

-                                            {'methodName':'putPage', 'params': [pagename,
"{{{\n" + reportcontent + "\n}}}\n"]}])
+                                            {'methodName':'putPage', 'params': [pagename,
reportcontent]}])
     print(pushresults)
 
 def cliargs():
@@ -157,6 +166,36 @@ def cliargs():
     parser.add_argument('--month', type=int, help='the month to report for, defaults to current
month.', default=0)
     return parser.parse_args()  # note that this exits on errors.
 
+def gen_shepherd_assignments(projects, month):
+    # Load the shepherd assignments data for this month's report.
+    now = datetime.datetime.now()
+    year = now.year if month >= now.month else now.year + 1
+    date = "{0:04d}-{1:02d}".format(year, month)
+    assignments_path = os.path.join("content", "shepherd_assignments.json")
+    with open(assignments_path, "r") as f:
+        assignments_data = json.load(f)
+    if date not in assignments_data:
+        print("Shepherds have not yet been assigned for {}.".format(date))
+        print("Please run `assign_shepherds.py --month={}`".format(month))
+        sys.exit(1)
+    report = assignments_data[date]
+
+    # Load the roster of active shepherds, which we'll use to get full names.
+    shepherds_path = os.path.join("content", "shepherds.json")
+    with open(shepherds_path, "r") as f:
+        shepherds_data = json.load(f)
+    shepherds = {}
+    for shepherd in shepherds_data:
+        shepherds[shepherd['apache_id']] = shepherd
+
+    # Generate and return the wikified list of assignments.
+    lines = []
+    for podling_id, shepherd_id in report.items():
+        podling_name = projects[podling_id]['fullName']
+        shepherd_name = shepherds[shepherd_id]['name']
+        lines.append("||{} ||{} ||".format(shepherd_name, podling_name))
+    lines.sort()
+    return "\n".join(lines)
 
 def main():
     options = cliargs()
@@ -169,14 +208,19 @@ def main():
     inputFile = open('clutch.pkl', 'rb')
     projects = pickle.load(inputFile)
     inputFile.close()
+
+    shepherds = gen_shepherd_assignments(projects, month)
+
     output = open('report.txt', 'w')
+
     toc = ""
     for project in sorted(projects.keys()):
         pdata = projects[project]
         if pdata['rawReportingGroup'] == curGroup or pdata['reportingMonthly']:
             toc = toc + projects[project]['fullName'] + "\n"
          
-    output.write(boilerplate.format(month=calendar.month_abbr[month], toc=toc))
+    output.write(boilerplate.format(month=calendar.month_abbr[month],
+                                    toc=toc, shepherds=shepherds))
     
     ptemplate = Template(perproject)
     
@@ -195,6 +239,10 @@ def main():
                       'start': pdata['startDate'],
                       'mentorlist' : mentorlist}
             output.write(ptemplate.substitute(pdict))
+
+    # Close `Report Content` section.
+    output.write("\n}}}\n")
+
     output.close()
     pushdata = options.push
     if pushdata != None:



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


Mime
View raw message