community-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1708517 - /comdev/projects.apache.org/scripts/cronjobs/parsecommitteeinfoBETA.py
Date Tue, 13 Oct 2015 21:27:58 GMT
Author: sebb
Date: Tue Oct 13 21:27:58 2015
New Revision: 1708517

URL: http://svn.apache.org/viewvc?rev=1708517&view=rev
Log:
Need to specify encodings

Modified:
    comdev/projects.apache.org/scripts/cronjobs/parsecommitteeinfoBETA.py

Modified: comdev/projects.apache.org/scripts/cronjobs/parsecommitteeinfoBETA.py
URL: http://svn.apache.org/viewvc/comdev/projects.apache.org/scripts/cronjobs/parsecommitteeinfoBETA.py?rev=1708517&r1=1708516&r2=1708517&view=diff
==============================================================================
--- comdev/projects.apache.org/scripts/cronjobs/parsecommitteeinfoBETA.py (original)
+++ comdev/projects.apache.org/scripts/cronjobs/parsecommitteeinfoBETA.py Tue Oct 13 21:27:58
2015
@@ -104,7 +104,7 @@ def handleChild(el):
     return tag, retval
 
 print("reading people Data (site/json/foundation/people.json)")
-with open("../../site/json/foundation/people.json", "r") as f:
+with open("../../site/json/foundation/people.json", "r", encoding='utf-8') as f:
     people = json.loads(f.read())
     f.close()
 
@@ -124,7 +124,7 @@ for loc in xmldoc.getElementsByTagName('
         if url.startswith('http'):
             rdf = urllib.request.urlopen(url).read()
         else:
-            rdf = open("../../data/%s" % url, 'r').read()
+            rdf = open("../../data/%s" % url, 'r', encoding='utf-8').read()
             url = "https://svn.apache.org/repos/asf/comdev/projects.apache.org/data/%s" %
url
         rdfxml = ET.fromstring(rdf)
         rdfdata = rdfxml[0]
@@ -153,20 +153,22 @@ for loc in xmldoc.getElementsByTagName('
         # copy PMC RDF data to /doap/{committeeId}/pmc-doap.rdf
         if type(rdf) is str:
             mode = "w"
+            encoding = 'utf-8'
         else:
             mode = "wb"
+            encoding = None
         path = "../../site/doap/%s" % committeeId
         try:
             os.stat(path)
         except:
             print("INFO: creating new directory %s for %s" % (path, url))
             os.mkdir(path)
-        with open("%s/pmc-doap.rdf" % path, mode) as f:
+        with open("%s/pmc-doap.rdf" % path, mode, encoding=encoding) as f:
             f.write(rdf)
             f.close()
 
     except Exception as err:
-        print("ERROR: %s" % err, file=sys.stderr)
+        print("ERROR: %s processing %s" % (err, url), file=sys.stderr)
 
 committeeCount = 0
 committeesList = []
@@ -265,7 +267,7 @@ for group in sorted(committees, key=keyo
                 print("INFO: creating directory %s" % directory)
                 os.makedirs(directory)
 #             print("INFO: creating %s/pmc.pdf" % directory)
-            with open("%s/pmc.rdf" % directory, "w") as f:
+            with open("%s/pmc.rdf" % directory, "w", encoding='utf-8') as f:
                 f.write(minidom.parseString(ET.tostring(doap, encoding="utf-8")).toprettyxml(indent="\t"))
                 f.close()
         else:
@@ -333,3 +335,4 @@ print("Writing json/foundation/pmcs.json
 with open ("../../site/json/foundation/pmcs.json", "w") as f:
     json.dump(pmcs, f, sort_keys=True, indent=0)
     f.close()
+print("All done")
\ No newline at end of file



Mime
View raw message