On Mar 19, 2007, at 5:16 PM, Matt wrote:
The following of rdflib.Graph.Graph def seq(self, subject): """Check if subject is an rdf:Seq If yes, it returns a Seq class instance, None otherwise. """ if (subject, RDF.type, RDF.Seq) in self: return Seq(self, subject) else: return None would make more sense if it were named collection not seq and tested for more than just RDF.Seq - I do this by looking for any type derived from RDFS.Container (which requires the schema definitions of these to be loaded into the graph), but even just testing for RDF.Seq, RDF.Bag, and RDF.Alt would be a good start. For backwards compatibility I imagine it would be better to add alt and bag as their own methods as well as a general collection interface. The same also goes for class Seq(object): """Wrapper around an RDF Seq resource .... The mechanism in here works fine for Alt and Bag also. If this makes sense, I don't mind adding in support for these. I have also developed support for rdf Collections (i.e. the first rest structure), which I could add in.
Makes sense, I think. Go for it. I recently was thinking along the same lines when I had to switch some of my application code from Collections to Seq. In the process I ended up putting the conditionals in my application code to support either.
Just in case you haven't noticed it... there's a method called items on Graph that does the first rest dance. And there's rdflib.Collection -- would be good to unify the whole lot into one spot that works well.
cheers matt (a.k.a greenman on freenode) _______________________________________________ Dev mailing list Dev@rdflib.net http://rdflib.net/mailman/listinfo/dev
Daniel Krech, http://eikeon.com/
_______________________________________________ Dev mailing list Dev@rdflib.net http://rdflib.net/mailman/listinfo/dev