Using librdf to process RDF in Python

From ActiveArchives
Jump to: navigation, search


Examples of using Redland from Python.

RDF.Model

When iterated a model yields statements.

for s in model:
    obj = s.object
    if obj.is_resource():
        print obj.uri

RDF.Node

def rdfnode (n):
    """
    Unpeel an RDF.Node object to a displayable string
    """
    ret = n
    if type(n) == str or type(n) == unicode: return n
    if n.is_resource():
        ret = str(n.uri)
    elif n.is_literal():
        ret = n.literal_value.get("string")
    return ret
Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox