community-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgard...@apache.org
Subject svn commit: r894429 - /comdev/nearby_people/nearby/foaf.py
Date Tue, 29 Dec 2009 16:13:48 GMT
Author: rgardler
Date: Tue Dec 29 16:13:47 2009
New Revision: 894429

URL: http://svn.apache.org/viewvc?rev=894429&view=rev
Log:
Grab weblog data

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=894429&r1=894428&r2=894429&view=diff
==============================================================================
--- comdev/nearby_people/nearby/foaf.py (original)
+++ comdev/nearby_people/nearby/foaf.py Tue Dec 29 16:13:47 2009
@@ -28,6 +28,7 @@
 NS_FOAF = "http://xmlns.com/foaf/0.1/"
 NS_DOAP = "http://usefulinc.com/ns/doap#"
 NS_PM = "http://www.web-semantics.org/ns/pm#"
+NS_DC = "http://purl.org/dc/elements/1.1/"
 
 class FOAF(object):
     def __init__(self, doap_file):
@@ -67,6 +68,7 @@
             long = None
             projects = []
             depiction = None
+            weblogs = []
 
             if uri.startswith(PEOPLE_FOAF_NAMESPACE):
                 file = os.path.join(PEOPLE_FOAF_PATH, uri.replace(PEOPLE_FOAF_NAMESPACE,""))
@@ -79,6 +81,8 @@
                 uidN = foaf.getElementsByTagNameNS(NS_FOAF,"Person")
                 currentProjectsN = foaf.getElementsByTagNameNS(NS_FOAF,"currentProject")
                 depictionN = foaf.getElementsByTagNameNS(NS_FOAF,"depiction")
+                weblogsN = foaf.getElementsByTagNameNS(NS_FOAF,"weblog")
+                
                 if surnameN:
                     surname = surnameN[0].firstChild.data
                 if nameN:
@@ -119,14 +123,21 @@
                         projectName = projectN.getElementsByTagNameNS(NS_PM,"name")
                     if projectName:
                         projects.append({"name": projectName[0].firstChild.data})
-                print projects
+
+            if weblogsN:
+                for weblogN in weblogsN:
+                    documentN = weblogN.getElementsByTagNameNS(NS_FOAF, "Document")
+                    if documentN:
+                        title = documentN[0].getElementsByTagNameNS(NS_DC,"title")[0].firstChild.data
+                        url = documentN[0].getAttribute("rdf:about")
+                        weblogs.append({"title": title, "url": url})
 
             # Finish building up
             if name and surname and uid and lat and long:
                 self.people[name] = {
                     "name": name, "surname": surname, "uid":uid, 
                     "latitude": lat, "longitude": long, "projects": projects,
-                    "avatar": depiction
+                    "avatar": depiction, "weblogs": weblogs
                 }
 
         self.updated_at = datetime.datetime.utcnow()



Mime
View raw message