#!/usr/bin/env python """ RDF Utilities (using rdflib) Author: Sean B. Palmer, inamidst.com Licence: GPL 2; share and enjoy! Requirement: http://rdflib.net/ """ import sys, re from rdflib.TripleStore import TripleStore from rdflib.Namespace import Namespace from rdflib.URIRef import URIRef as URI from rdflib.Literal import Literal from rdflib.BNode import BNode as bNode # class Namespace(unicode): # def __getattr__(self, attr): # return URI(self + attr) # def __getitem__(self, item): # return URI(self + item) class Graph(TripleStore): def theObject(self, subj, pred): objects = tuple(self.objects(subj, pred)) if len(objects) == 1: return objects[0] elif len(objects) == 0: return None else: raise "Some kind of an error" def main(): print __doc__ if __name__=="__main__": main()