9
9
from rdflib .term import Statement
10
10
11
11
12
- __all__ = ["SUBJECT" , "PREDICATE" , "OBJECT" , "CONTEXT" , "TERM_COMBINATIONS" ,
13
- "REVERSE_TERM_COMBINATIONS" , "TERM_INSTANTIATION_DICT" ,
14
- "GRAPH_TERM_DICT" , "normalizeGraph" , "term_to_letter" ,
15
- "construct_graph" , "triplePattern2termCombinations" ,
16
- "type_to_term_combination" , "statement_to_term_combination" ,
17
- "escape_quotes" ]
18
-
19
12
SUBJECT = 0
20
13
PREDICATE = 1
21
14
OBJECT = 2
70
63
71
64
72
65
@format_doctest_out
73
- def normalizeGraph (graph ):
66
+ def normalize_graph (graph ):
74
67
"""
75
68
Take an instance of a ``Graph`` and return the instance's identifier and ``type``.
76
69
@@ -82,16 +75,16 @@ def normalizeGraph(graph):
82
75
>>> from rdflib.graph import Graph, ConjunctiveGraph, QuotedGraph
83
76
>>> from rdflib.store import Store
84
77
>>> from rdflib import URIRef, Namespace
85
- >>> from rdflib_sqlalchemy.termutils import normalizeGraph
78
+ >>> from rdflib_sqlalchemy.termutils import normalize_graph
86
79
>>> memstore = plugin.get('IOMemory', Store)()
87
80
>>> g = Graph(memstore, URIRef("http://purl.org/net/bel-epa/gjh"))
88
- >>> normalizeGraph (g)
81
+ >>> normalize_graph (g)
89
82
(rdflib.term.URIRef(%(u)s'http://purl.org/net/bel-epa/gjh'), 'U')
90
83
>>> g = ConjunctiveGraph(memstore, Namespace("http://rdflib.net/ns"))
91
- >>> normalizeGraph (g) #doctest: +ELLIPSIS
84
+ >>> normalize_graph (g) #doctest: +ELLIPSIS
92
85
(rdflib.term.URIRef(%(u)s'http://rdflib.net/ns'), 'U')
93
86
>>> g = QuotedGraph(memstore, Namespace("http://rdflib.net/ns"))
94
- >>> normalizeGraph (g)
87
+ >>> normalize_graph (g)
95
88
(rdflib.term.URIRef(%(u)s'http://rdflib.net/ns'), 'F')
96
89
97
90
"""
@@ -178,11 +171,10 @@ def construct_graph(key):
178
171
return GRAPH_TERM_DICT [key ]
179
172
180
173
181
- def triplePattern2termCombinations (triple ):
174
+ def triple_pattern_to_term_combinations (triple ):
182
175
"""Map a triple pattern to term combinations (non-functioning)."""
183
176
s , p , o = triple
184
177
combinations = []
185
- # combinations.update(TERM_COMBINATIONS)
186
178
if isinstance (o , Literal ):
187
179
for key , val in TERM_COMBINATIONS .items ():
188
180
if key [OBJECT ] == 'O' :
@@ -196,7 +188,7 @@ def type_to_term_combination(member, klass, context):
196
188
rt = TERM_COMBINATIONS ["%sU%s%s" %
197
189
(term_to_letter (member ),
198
190
term_to_letter (klass ),
199
- normalizeGraph (context )[- 1 ])]
191
+ normalize_graph (context )[- 1 ])]
200
192
return rt
201
193
except :
202
194
raise Exception ("Unable to persist" +
@@ -208,7 +200,7 @@ def statement_to_term_combination(subject, predicate, obj, context):
208
200
"""Map a statement to a Term Combo."""
209
201
return TERM_COMBINATIONS ["%s%s%s%s" %
210
202
(term_to_letter (subject ), term_to_letter (predicate ),
211
- term_to_letter (obj ), normalizeGraph (context )[- 1 ])]
203
+ term_to_letter (obj ), normalize_graph (context )[- 1 ])]
212
204
213
205
214
206
def escape_quotes (qstr ):
0 commit comments