Skip to content

Commit 42f6d65

Browse files
committed
more pythonic renamings
1 parent 3a88290 commit 42f6d65

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

rdflib_sqlalchemy/termutils.py

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,6 @@
99
from rdflib.term import Statement
1010

1111

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-
1912
SUBJECT = 0
2013
PREDICATE = 1
2114
OBJECT = 2
@@ -70,7 +63,7 @@
7063

7164

7265
@format_doctest_out
73-
def normalizeGraph(graph):
66+
def normalize_graph(graph):
7467
"""
7568
Take an instance of a ``Graph`` and return the instance's identifier and ``type``.
7669
@@ -82,16 +75,16 @@ def normalizeGraph(graph):
8275
>>> from rdflib.graph import Graph, ConjunctiveGraph, QuotedGraph
8376
>>> from rdflib.store import Store
8477
>>> from rdflib import URIRef, Namespace
85-
>>> from rdflib_sqlalchemy.termutils import normalizeGraph
78+
>>> from rdflib_sqlalchemy.termutils import normalize_graph
8679
>>> memstore = plugin.get('IOMemory', Store)()
8780
>>> g = Graph(memstore, URIRef("http://purl.org/net/bel-epa/gjh"))
88-
>>> normalizeGraph(g)
81+
>>> normalize_graph(g)
8982
(rdflib.term.URIRef(%(u)s'http://purl.org/net/bel-epa/gjh'), 'U')
9083
>>> g = ConjunctiveGraph(memstore, Namespace("http://rdflib.net/ns"))
91-
>>> normalizeGraph(g) #doctest: +ELLIPSIS
84+
>>> normalize_graph(g) #doctest: +ELLIPSIS
9285
(rdflib.term.URIRef(%(u)s'http://rdflib.net/ns'), 'U')
9386
>>> g = QuotedGraph(memstore, Namespace("http://rdflib.net/ns"))
94-
>>> normalizeGraph(g)
87+
>>> normalize_graph(g)
9588
(rdflib.term.URIRef(%(u)s'http://rdflib.net/ns'), 'F')
9689
9790
"""
@@ -178,11 +171,10 @@ def construct_graph(key):
178171
return GRAPH_TERM_DICT[key]
179172

180173

181-
def triplePattern2termCombinations(triple):
174+
def triple_pattern_to_term_combinations(triple):
182175
"""Map a triple pattern to term combinations (non-functioning)."""
183176
s, p, o = triple
184177
combinations = []
185-
# combinations.update(TERM_COMBINATIONS)
186178
if isinstance(o, Literal):
187179
for key, val in TERM_COMBINATIONS.items():
188180
if key[OBJECT] == 'O':
@@ -196,7 +188,7 @@ def type_to_term_combination(member, klass, context):
196188
rt = TERM_COMBINATIONS["%sU%s%s" %
197189
(term_to_letter(member),
198190
term_to_letter(klass),
199-
normalizeGraph(context)[-1])]
191+
normalize_graph(context)[-1])]
200192
return rt
201193
except:
202194
raise Exception("Unable to persist" +
@@ -208,7 +200,7 @@ def statement_to_term_combination(subject, predicate, obj, context):
208200
"""Map a statement to a Term Combo."""
209201
return TERM_COMBINATIONS["%s%s%s%s" %
210202
(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])]
212204

213205

214206
def escape_quotes(qstr):

0 commit comments

Comments
 (0)