1
1
"""Convenience functions for working with Terms and Graphs."""
2
2
from rdflib import BNode , Graph , Literal , URIRef , Variable
3
3
from rdflib .graph import QuotedGraph
4
- from rdflib .py3compat import format_doctest_out
5
4
from rdflib .term import Statement
6
5
7
6
from rdflib_sqlalchemy .constants import (
25
24
}
26
25
27
26
28
- @format_doctest_out
29
27
def normalize_graph (graph ):
30
28
"""
31
29
Take an instance of a ``Graph`` and return the instance's identifier and ``type``.
@@ -42,13 +40,13 @@ def normalize_graph(graph):
42
40
>>> memstore = plugin.get('IOMemory', Store)()
43
41
>>> g = Graph(memstore, URIRef("http://purl.org/net/bel-epa/gjh"))
44
42
>>> normalize_graph(g)
45
- (rdflib.term.URIRef(%(u)s 'http://purl.org/net/bel-epa/gjh'), 'U')
43
+ (rdflib.term.URIRef(u 'http://purl.org/net/bel-epa/gjh'), 'U')
46
44
>>> g = ConjunctiveGraph(memstore, Namespace("http://rdflib.net/ns"))
47
45
>>> normalize_graph(g) #doctest: +ELLIPSIS
48
- (rdflib.term.URIRef(%(u)s 'http://rdflib.net/ns'), 'U')
46
+ (rdflib.term.URIRef(u 'http://rdflib.net/ns'), 'U')
49
47
>>> g = QuotedGraph(memstore, Namespace("http://rdflib.net/ns"))
50
48
>>> normalize_graph(g)
51
- (rdflib.term.URIRef(%(u)s 'http://rdflib.net/ns'), 'F')
49
+ (rdflib.term.URIRef(u 'http://rdflib.net/ns'), 'F')
52
50
53
51
"""
54
52
if isinstance (graph , QuotedGraph ):
@@ -57,7 +55,6 @@ def normalize_graph(graph):
57
55
return graph .identifier , term_to_letter (graph .identifier )
58
56
59
57
60
- @format_doctest_out
61
58
def term_to_letter (term ):
62
59
"""
63
60
Relate a given term to one of several key types.
@@ -79,9 +76,9 @@ def term_to_letter(term):
79
76
'U'
80
77
>>> term_to_letter(BNode())
81
78
'B'
82
- >>> term_to_letter(Literal(%(u)s '')) # noqa
79
+ >>> term_to_letter(Literal(u '')) # noqa
83
80
'L'
84
- >>> term_to_letter(Variable(%(u)s 'x')) # noqa
81
+ >>> term_to_letter(Variable(u 'x')) # noqa
85
82
'V'
86
83
>>> term_to_letter(Graph())
87
84
'B'
0 commit comments