incubator-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1187122 - /incubator/public/trunk/clutch.py
Date Thu, 20 Oct 2011 22:49:50 GMT
Author: sebb
Date: Thu Oct 20 22:49:50 2011
New Revision: 1187122

URL: http://svn.apache.org/viewvc?rev=1187122&view=rev
Log:
Simplify mentor list procesing by storing as a list

Modified:
    incubator/public/trunk/clutch.py

Modified: incubator/public/trunk/clutch.py
URL: http://svn.apache.org/viewvc/incubator/public/trunk/clutch.py?rev=1187122&r1=1187121&r2=1187122&view=diff
==============================================================================
--- incubator/public/trunk/clutch.py (original)
+++ incubator/public/trunk/clutch.py Thu Oct 20 22:49:50 2011
@@ -184,7 +184,7 @@ for token in tokens:
     projects[id]['hasEntryIssues'] = False
     projects[id]['description'] = ""
     projects[id]['sponsor'] = "? not known"
-    projects[id]['mentors'] = ""
+    projects[id]['mentors'] = []
     projects[id]['resourceNames'] = [id]
     projects[id]['startDate'] = ""
     projects[id]['entryDate'] = None
@@ -270,9 +270,7 @@ for row in dom.getElementsByTagName("pod
   fileBaseName = row.getAttribute("resource")
   sponsor = row.getAttribute("sponsor")
   description = getText(row.getElementsByTagName("description"))
-  mentors = row.getElementsByTagName("mentor")[0].firstChild.data
-  for mentor in row.getElementsByTagName("mentor")[1:]:
-    mentors += ', ' + mentor.firstChild.data
+  mentors = [mentor.firstChild.data.strip() for mentor in row.getElementsByTagName("mentor")]
 
   try:
     projectsTable[id]
@@ -283,19 +281,15 @@ for row in dom.getElementsByTagName("pod
     projectsTable[id]['sponsor'] = sponsor
     projectsTable[id]['startDate'] = startDate
     projectsTable[id]['statusFileName'] = fileBaseName
-    projectsTable[id]['mentors'] = mentors.strip()
+    projectsTable[id]['mentors'] = mentors
 
     # determine projects for each mentor
-    if projectsTable[id]['mentors'] != "":
-      mentorsList = projectsTable[id]['mentors'].split(",")
-      for mentor in mentorsList:
-        theMentor = mentor.strip()
-        try:
-          mentorsProjects[theMentor]
-        except KeyError:
-          mentorsProjects[theMentor] = projectsTable[id]['name']
-        else:
-          mentorsProjects[theMentor] += ", {0}".format(projectsTable[id]['name'])
+    for mentor in projectsTable[id]['mentors']:
+      try:
+        mentorsProjects[mentor]
+      except KeyError:
+        mentorsProjects[mentor] = []
+      mentorsProjects[mentor].append(projectsTable[id]['name'])
   else:
     print("ERROR: {0}: row exists".format(id))
  history[id] = {}
@@ -1138,7 +1132,7 @@ mentors.sort()
 fileXmlm = open('site-author/clutchm.ent', 'w')
 fileXmlm.write("<!-- generated by clutch; do not edit -->\n")
 for mentor in mentors:
-  fileXmlm.write("        <li><strong>{0}</strong>: {1}</li>\n".format(mentor,
mentorsProjects[mentor]))
+  fileXmlm.write("        <li><strong>{0}</strong>: {1}</li>\n".format(mentor,
', '.join(mentorsProjects[mentor])))
 fileXmlm.close()
 
 fileList.close()



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


Mime
View raw message