Monday, 6 December 2004
Sparta.py 0.6: RDF (and RSS!) Made Easy
Version 0.6 of sparta.py is now available. Changes include:
- Before, a property that didn’t have an owl:maxCardinality of “1” was mapped to a Python generator. Based on feedback (thanks, John), it’s now mapped to an object that implements a subset of the sets.Set interface, and produces a full sets.Set when you call the copy() method.
- rdf:Seq is mapped to a list, joining rdf:List; this allows Sparta to work with RSS 1.0, along with other formats that use Seq.
- The factory takes an optional schema_store argument, so you can store schema hints for Spara separately, if you wish.
A nice example is RSS 1.0 parsing; see rss_test.py, which makes RSS pretty darned easy:
blog = Thing(URI(blog_uri)) for item in blog.rss_items: print "*", item.rss_title print indent(item.rss_description)
I like this so much that I’m considering moving away from other RSS parsing approaches and just normalising everything to RSS1.0 (maybe with XSLT) and shoving it into this.
I’ve got good feedback on this so far. I think the main things that need to be done before 1.0 are:
- Reconsidering instantiation; Right now, there’s a hack in the instantiation of a Thing that’s a little ugly; e.g., foo = Thing(“foo_bar”, rdf_type=my_widget); here, rdf_type is really a set, and should raise a TypeError. I either need another way to conveniently instantiate such properties, or get rid of this “feature.”
- Support for all relevant Schema types, namely those related to dates and times. This will probably wait for PEP 321 to be completed.
- Getting type information from rdf:type; this will require Sparta to know about multiple types for a single node, because it might already have type information from rdfs:range. In the long run, this is good, because nodes can have multiple types (e.g., it’s both a car and a Volkswagen), but it’s a little tricky to implement well.
- Support for at least one more store, like Redland.
- Better documentation, more format tests, and any associated refactoring and bugfixes.