community-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hbout...@apache.org
Subject svn commit: r1688055 - in /comdev/projects.apache.org/scripts/import: parsecommittees.py parsepmcs.py
Date Sun, 28 Jun 2015 20:14:15 GMT
Author: hboutemy
Date: Sun Jun 28 20:14:14 2015
New Revision: 1688055

URL: http://svn.apache.org/r1688055
Log:
imroved code for maintainability

Modified:
    comdev/projects.apache.org/scripts/import/parsecommittees.py
    comdev/projects.apache.org/scripts/import/parsepmcs.py

Modified: comdev/projects.apache.org/scripts/import/parsecommittees.py
URL: http://svn.apache.org/viewvc/comdev/projects.apache.org/scripts/import/parsecommittees.py?rev=1688055&r1=1688054&r2=1688055&view=diff
==============================================================================
--- comdev/projects.apache.org/scripts/import/parsecommittees.py (original)
+++ comdev/projects.apache.org/scripts/import/parsecommittees.py Sun Jun 28 20:14:14 2015
@@ -42,15 +42,6 @@ shortdescs = {
     'labs': 'A place for innovation where committers of the foundation can experiment with
new ideas'
 }
 
-with open("../../site/json/foundation/committees-retired.json", "r") as f:
-    committeesRetired = json.loads(f.read())
-    f.close()
-
-# to detect retired committees to add to committees-retired.json
-with open("../../site/json/foundation/committees.json", "r") as f:
-    committeesPrevious = json.loads(f.read())
-    f.close()
-
 with open("../../site/json/foundation/people.json", "r") as f:
     people = json.loads(f.read())
     f.close()
@@ -247,11 +238,13 @@ addedCommittees.sort()
 for added in addedCommittees:
     print("- %s" % added)
 
-with open("../../site/json/foundation/committees.json", "w") as f:
-    f.write(json.dumps(committeesList, sort_keys=True, indent=0))
-    f.close()
-
 # detect retired committees to add to committees-retired.json
+with open("../../site/json/foundation/committees.json", "r") as f:
+    committeesPrevious = json.loads(f.read())
+    f.close()
+with open("../../site/json/foundation/committees-retired.json", "r") as f:
+    committeesRetired = json.loads(f.read())
+    f.close()
 for previous in committeesPrevious:
     if not previous['id'] in committeesMap:
         print("found retired committee: %s" % previous['name'])
@@ -262,6 +255,11 @@ for previous in committeesPrevious:
         previous.pop('rdf', None)
         previous.pop('reporting', None)
         committeesRetired.append(previous)
+
+with open("../../site/json/foundation/committees.json", "w") as f:
+    f.write(json.dumps(committeesList, sort_keys=True, indent=0))
+    f.close()
+
 with open("../../site/json/foundation/committees-retired.json", "w") as f:
     f.write(json.dumps(committeesRetired, sort_keys=True, indent=0))
     f.close()

Modified: comdev/projects.apache.org/scripts/import/parsepmcs.py
URL: http://svn.apache.org/viewvc/comdev/projects.apache.org/scripts/import/parsepmcs.py?rev=1688055&r1=1688054&r2=1688055&view=diff
==============================================================================
--- comdev/projects.apache.org/scripts/import/parsepmcs.py (original)
+++ comdev/projects.apache.org/scripts/import/parsepmcs.py Sun Jun 28 20:14:14 2015
@@ -12,7 +12,7 @@ with open("../../data/committees.xml", "
 xmldoc = minidom.parseString(data)
 itemlist = xmldoc.getElementsByTagName('location')
 
-projects = {}
+pmcs = {}
 
 def handleChild(el):
     retval = None
@@ -44,28 +44,34 @@ for s in itemlist :
             rdf = open("../../data/%s" % url, 'r').read()
             url = "https://svn.apache.org/repos/asf/comdev/projects.apache.org/data/%s" %
url
         rdfxml = ET.fromstring(rdf)
-        project = rdfxml[0]
-        pjson = {
+        pmc = rdfxml[0]
+
+        # transform PMC data RDF to json
+        pmcjson = {
             'rdf': url
         }
-        prname = None
-        for el in project:
+        pmcname = None
+        for el in pmc:
             k, v = handleChild(el)
-            if k in pjson:
-                if type(pjson[k]) is str:
-                    pjson[k] = "%s, %s" % (pjson[k], v)
+            if k in pmcjson:
+                # merge multiple values
+                if type(pmcjson[k]) is str:
+                    pmcjson[k] = "%s, %s" % (pmcjson[k], v)
                 else:
                     for xk in v:
-                        pjson[k][xk] = v[xk]
+                        pmcjson[k][xk] = v[xk]
             else:
-                pjson[k] = v
-        id = project.attrib['{http://www.w3.org/1999/02/22-rdf-syntax-ns#}about']
-        projects[id] = pjson
+                pmcjson[k] = v
+
+        committeeId = pmc.attrib['{http://www.w3.org/1999/02/22-rdf-syntax-ns#}about']
+        pmcs[committeeId] = pmcjson
+
+        # copy PMC RDF data to /doap/{committeeId}/pmc-doap.rdf
         if type(rdf) is str:
             mode = "w"
         else:
             mode = "wb"
-        with open("../../site/doap/%s/pmc-doap.rdf" % id, mode) as f:
+        with open("../../site/doap/%s/pmc-doap.rdf" % committeeId, mode) as f:
             f.write(rdf)
             f.close()
 
@@ -76,6 +82,6 @@ for s in itemlist :
         print("-"*60)
 
 with open ("../../site/json/foundation/pmcs.json", "w") as f:
-    f.write(json.dumps(projects, sort_keys=True, indent=0))
+    f.write(json.dumps(pmcs, sort_keys=True, indent=0))
     f.close()
 print("Done!")



Mime
View raw message