gjhiggins/rdflib — Issue #131: Suggested method on Graph for BNode Closure
Author: gjhiggins
Created: 2011-10-19 01:28:48+00:00
State: open

Originally filed by wwai...@gmail.com on 2010-07-22T16:05:40

def bnc(self, triple, *av, **kw):
"""
Return the BNode closure(s) for triples that are matched
by the given "triple". Any additional positional or keyword
arguments are passed to the constructor for the new graph.
"""
result = Graph(*av, **kw)
for s,p,o in self.triples(triple):
result.add((s,p,o))
if isinstance(o, BNode):
result += self.bnc((o, None, None))
return result