You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@community.apache.org by ni...@apache.org on 2013/09/07 12:43:52 UTC
svn commit: r1520755 - /comdev/nearby_people/nearby/foaf.py
Author: nick
Date: Sat Sep 7 10:43:51 2013
New Revision: 1520755
URL: http://svn.apache.org/r1520755
Log:
More robust handling of invalid xml in FOAF files (as http://www.jeremias-maerki.ch/webwho.rdf currently triggers)
Modified:
comdev/nearby_people/nearby/foaf.py
Modified: comdev/nearby_people/nearby/foaf.py
URL: http://svn.apache.org/viewvc/comdev/nearby_people/nearby/foaf.py?rev=1520755&r1=1520754&r2=1520755&view=diff
==============================================================================
--- comdev/nearby_people/nearby/foaf.py (original)
+++ comdev/nearby_people/nearby/foaf.py Sat Sep 7 10:43:51 2013
@@ -88,6 +88,7 @@ class FOAF(object):
else:
sys.stderr.write("Missing FOAF file %s\n" % people_rel_uri)
else:
+ file = None
usock = urllib.urlopen(uri)
self._parse_foaf(usock, uri)
usock.close()
@@ -105,7 +106,12 @@ class FOAF(object):
depiction = None
weblogs = []
- foaf = parse(data)
+ try:
+ foaf = parse(data)
+ except Exception as e:
+ sys.stderr.write("Skipping %s due to invalid/corrupt file: %s\n" % (filename,e))
+ return None
+
surnameN = foaf.getElementsByTagNameNS(NS_FOAF,"family_name")
nameN = foaf.getElementsByTagNameNS(NS_FOAF,"name")
longN = foaf.getElementsByTagNameNS(NS_GEO,"long")