[conduit/tracker] Add a properties() function for iterating over all *set* properties of a URI
- From: John Carr <johncarr src gnome org>
- To: svn-commits-list gnome org
- Subject: [conduit/tracker] Add a properties() function for iterating over all *set* properties of a URI
- Date: Mon, 15 Jun 2009 00:45:25 -0400 (EDT)
commit 1b6aea49874e2428d082268281dc78612d8ad34a
Author: John Carr <john carr unrouted co uk>
Date: Mon Jun 15 03:30:00 2009 +0100
Add a properties() function for iterating over all *set* properties of a URI
conduit/modules/TrackerModule/tralchemy/core.py | 20 ++++++++++++++------
1 files changed, 14 insertions(+), 6 deletions(-)
---
diff --git a/conduit/modules/TrackerModule/tralchemy/core.py b/conduit/modules/TrackerModule/tralchemy/core.py
index a5a7809..38fafa8 100644
--- a/conduit/modules/TrackerModule/tralchemy/core.py
+++ b/conduit/modules/TrackerModule/tralchemy/core.py
@@ -45,6 +45,14 @@ class Resource(object):
self.uri = get_classname(uri)
self.triples = {}
+ def properties(self):
+ uri = self.uri
+ if uri.startswith("http://"):
+ uri = "<%s>" % uri
+ results = tracker.SparqlQuery("SELECT ?key, ?value WHERE { %s ?key ?value }" % uri)
+ for key, value in results:
+ yield get_classname(str(key)), str(value)
+
@classmethod
def get(cls, **kwargs):
fragment = ""
@@ -180,12 +188,12 @@ class WrapperFactory(object):
"__doc__": cls.comment or ""
}
- # FIXME: subclassof should return an object!!
- baseclass = cls.subclassof
- if baseclass:
- baseclass = [self.get_class(baseclass.uri)]
- else:
- baseclass = [Resource]
+ baseclass = []
+ for key, value in cls.properties():
+ if key == "rdfs:subClassOf":
+ baseclass.append(self.get_class(value))
+ if not baseclass:
+ baseclass.append(Resource)
# Does this class have notifications?
if cls.notify:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]