11
11
12
12
__all__ = ["SUBJECT" , "PREDICATE" , "OBJECT" , "CONTEXT" , "TERM_COMBINATIONS" ,
13
13
"REVERSE_TERM_COMBINATIONS" , "TERM_INSTANTIATION_DICT" ,
14
- "GRAPH_TERM_DICT" , "normalizeGraph" , "term2Letter " ,
15
- "constructGraph " , "triplePattern2termCombinations" ,
16
- "type2TermCombination " , "statement2TermCombination " ,
14
+ "GRAPH_TERM_DICT" , "normalizeGraph" , "term_to_letter " ,
15
+ "construct_graph " , "triplePattern2termCombinations" ,
16
+ "type_to_term_combination " , "statement_to_term_combination " ,
17
17
"escape_quotes" ]
18
18
19
19
SUBJECT = 0
@@ -98,11 +98,11 @@ def normalizeGraph(graph):
98
98
if isinstance (graph , QuotedGraph ):
99
99
return graph .identifier , "F"
100
100
else :
101
- return graph .identifier , term2Letter (graph .identifier )
101
+ return graph .identifier , term_to_letter (graph .identifier )
102
102
103
103
104
104
@format_doctest_out
105
- def term2Letter (term ):
105
+ def term_to_letter (term ):
106
106
"""
107
107
Relate a given term to one of several key types.
108
108
@@ -118,22 +118,22 @@ def term2Letter(term):
118
118
>>> from rdflib.term import BNode
119
119
>>> # from rdflib.term import Statement
120
120
>>> from rdflib.graph import Graph, QuotedGraph
121
- >>> from rdflib_sqlalchemy.termutils import term2Letter
122
- >>> term2Letter (URIRef('http://purl.org/net/bel-epa.com/'))
121
+ >>> from rdflib_sqlalchemy.termutils import term_to_letter
122
+ >>> term_to_letter (URIRef('http://purl.org/net/bel-epa.com/'))
123
123
'U'
124
- >>> term2Letter (BNode())
124
+ >>> term_to_letter (BNode())
125
125
'B'
126
- >>> term2Letter (Literal(%(u)s'')) # noqa
126
+ >>> term_to_letter (Literal(%(u)s'')) # noqa
127
127
'L'
128
- >>> term2Letter (Variable(%(u)s'x')) # noqa
128
+ >>> term_to_letter (Variable(%(u)s'x')) # noqa
129
129
'V'
130
- >>> term2Letter (Graph())
130
+ >>> term_to_letter (Graph())
131
131
'B'
132
- >>> term2Letter (QuotedGraph("IOMemory", None))
132
+ >>> term_to_letter (QuotedGraph("IOMemory", None))
133
133
'F'
134
- >>> term2Letter (None)
134
+ >>> term_to_letter (None)
135
135
'L'
136
- >>> # term2Letter (Statement((None, None, None), None)) # Deprecated
136
+ >>> # term_to_letter (Statement((None, None, None), None)) # Deprecated
137
137
138
138
"""
139
139
if isinstance (term , URIRef ):
@@ -149,7 +149,7 @@ def term2Letter(term):
149
149
elif isinstance (term , Statement ):
150
150
return "s"
151
151
elif isinstance (term , Graph ):
152
- return term2Letter (term .identifier )
152
+ return term_to_letter (term .identifier )
153
153
elif term is None :
154
154
return "L"
155
155
else :
@@ -160,18 +160,18 @@ def term2Letter(term):
160
160
% (term , type (term )))
161
161
162
162
163
- def constructGraph (key ):
163
+ def construct_graph (key ):
164
164
"""
165
165
Return a tuple containing a ``Graph`` and an appropriate referent.
166
166
167
167
Takes a key (one of 'F', 'U' or 'B')
168
168
169
- >>> from rdflib_sqlalchemy.termutils import constructGraph
170
- >>> constructGraph ('F')
169
+ >>> from rdflib_sqlalchemy.termutils import construct_graph
170
+ >>> construct_graph ('F')
171
171
(<class 'rdflib.graph.QuotedGraph'>, <class 'rdflib.term.URIRef'>)
172
- >>> constructGraph ('U')
172
+ >>> construct_graph ('U')
173
173
(<class 'rdflib.graph.Graph'>, <class 'rdflib.term.URIRef'>)
174
- >>> constructGraph ('B')
174
+ >>> construct_graph ('B')
175
175
(<class 'rdflib.graph.Graph'>, <class 'rdflib.term.BNode'>)
176
176
177
177
"""
@@ -190,12 +190,12 @@ def triplePattern2termCombinations(triple):
190
190
return combinations
191
191
192
192
193
- def type2TermCombination (member , klass , context ):
193
+ def type_to_term_combination (member , klass , context ):
194
194
"""Map a type to a TermCombo."""
195
195
try :
196
196
rt = TERM_COMBINATIONS ["%sU%s%s" %
197
- (term2Letter (member ),
198
- term2Letter (klass ),
197
+ (term_to_letter (member ),
198
+ term_to_letter (klass ),
199
199
normalizeGraph (context )[- 1 ])]
200
200
return rt
201
201
except :
@@ -204,11 +204,11 @@ def type2TermCombination(member, klass, context):
204
204
(member , "rdf:type" , klass , context ))
205
205
206
206
207
- def statement2TermCombination (subject , predicate , obj , context ):
207
+ def statement_to_term_combination (subject , predicate , obj , context ):
208
208
"""Map a statement to a Term Combo."""
209
209
return TERM_COMBINATIONS ["%s%s%s%s" %
210
- (term2Letter (subject ), term2Letter (predicate ),
211
- term2Letter (obj ), normalizeGraph (context )[- 1 ])]
210
+ (term_to_letter (subject ), term_to_letter (predicate ),
211
+ term_to_letter (obj ), normalizeGraph (context )[- 1 ])]
212
212
213
213
214
214
def escape_quotes (qstr ):
0 commit comments