Esempio n. 1
0
def func_even(a):
    # Should this be required, or be done automatically?
    from rdflib.sparql.sparqlOperators import getValue
    value = getValue(a)

    if isinstance(value, Literal) and value.datatype in NUMERIC_TYPES:
        return Literal(int(value.toPython() % 2 == 0), datatype=_XSD_NS.boolean)
    else:
        raise TypeError(a)
def func_even(a):
    # Should this be required, or be done automatically?
    from rdflib.sparql.sparqlOperators import getValue
    value = getValue(a)

    if isinstance(value, Literal) and value.datatype in NUMERIC_TYPES:
        return Literal(int(value.toPython() % 2 == 0), datatype=XSD.boolean)
    else:
        raise TypeError(a)
Esempio n. 3
0
def describe(terms, bindings, graph):
    """ 
    Default DESCRIBE returns all incomming and outgoing statements about the given terms 
    """
    from rdflib.sparql.sparqlOperators import getValue
    g = Graph()
    terms = [getValue(i)(bindings) for i in terms]
    for s, p, o in graph.triples_choices((terms, None, None)):
        g.add((s, p, o))
    for s, p, o in graph.triples_choices((None, None, terms)):
        g.add((s, p, o))
    return g
Esempio n. 4
0
def describe(terms,bindings,graph):
    """ 
    Default DESCRIBE returns all incomming and outgoing statements about the given terms 
    """
    from rdflib.sparql.sparqlOperators import getValue
    g=Graph()
    terms=[getValue(i)(bindings) for i in terms]
    for s,p,o in graph.triples_choices((terms,None,None)):
        g.add((s,p,o))
    for s,p,o in graph.triples_choices((None,None,terms)):
        g.add((s,p,o))
    return g