Skip to content

Commit c5ff127

Browse files
author
Nicholas Car
authored
Merge pull request #1191 from FlorianLudwig/random-cleanup
small cleanups
2 parents dde9db8 + b5d998c commit c5ff127

File tree

7 files changed

+22
-38
lines changed

7 files changed

+22
-38
lines changed

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def find_version(filename):
102102
exclude_trees = ["_build", "draft"]
103103

104104
# The reST default role (used for this markup: `text`) to use for all documents.
105-
default_role = 'py:obj'
105+
default_role = "py:obj"
106106

107107
# If true, '()' will be appended to :func: etc. cross-reference text.
108108
add_function_parentheses = True

rdflib/plugins/sparql/operators.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,6 +1119,8 @@ def calculateFinalDateTime(obj1, dt1, obj2, dt2, operation):
11191119

11201120
def EBV(rt):
11211121
"""
1122+
Effective Boolean Value (EBV)
1123+
11221124
* If the argument is a typed literal with a datatype of xsd:boolean,
11231125
the EBV is the value of that argument.
11241126
* If the argument is a plain literal or a typed literal with a

rdflib/plugins/sparql/parserutils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def get(self, a, variables=False, errors=False):
173173
def __getattr__(self, a):
174174
# Hack hack: OrderedDict relies on this
175175
if a in ("_OrderedDict__root", "_OrderedDict__end"):
176-
raise AttributeError
176+
raise AttributeError()
177177
try:
178178
return self[a]
179179
except KeyError:

rdflib/plugins/sparql/sparql.py

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def __getitem__(self, key):
164164
if not isinstance(key, Node):
165165
key = Variable(key)
166166

167-
if not type(key) in (BNode, Variable):
167+
if not isinstance(key, (BNode, Variable)):
168168
return key
169169

170170
if key not in self._d:
@@ -177,22 +177,20 @@ def project(self, vars):
177177

178178
def merge(self, other):
179179
res = FrozenBindings(self.ctx, itertools.chain(self.items(), other.items()))
180-
181180
return res
182181

183-
def _now(self):
182+
@property
183+
def now(self):
184184
return self.ctx.now
185185

186-
def _bnodes(self):
186+
@property
187+
def bnodes(self):
187188
return self.ctx.bnodes
188189

189-
def _prologue(self):
190+
@property
191+
def prologue(self):
190192
return self.ctx.prologue
191193

192-
prologue = property(_prologue)
193-
bnodes = property(_bnodes)
194-
now = property(_now)
195-
196194
def forget(self, before, _except=None):
197195
"""
198196
return a frozen dict only of bindings made in self
@@ -222,8 +220,7 @@ def remember(self, these):
222220
return FrozenBindings(self.ctx, (x for x in self.items() if x[0] in these))
223221

224222

225-
class QueryContext(object):
226-
223+
class QueryContext:
227224
"""
228225
Query context - passed along when evaluating the query
229226
"""
@@ -260,7 +257,9 @@ def clone(self, bindings=None):
260257
r.bnodes = self.bnodes
261258
return r
262259

263-
def _get_dataset(self):
260+
@property
261+
def dataset(self):
262+
""""current dataset"""
264263
if self._dataset is None:
265264
raise Exception(
266265
"You performed a query operation requiring "
@@ -269,8 +268,6 @@ def _get_dataset(self):
269268
)
270269
return self._dataset
271270

272-
dataset = property(_get_dataset, doc="current dataset")
273-
274271
def load(self, source, default=False, **kwargs):
275272
def _load(graph, source):
276273
try:
@@ -306,7 +303,7 @@ def _load(graph, source):
306303

307304
def __getitem__(self, key):
308305
# in SPARQL BNodes are just labels
309-
if not type(key) in (BNode, Variable):
306+
if not isinstance(key, (BNode, Variable)):
310307
return key
311308
try:
312309
return self.bindings[key]
@@ -348,11 +345,6 @@ def push(self):
348345
def clean(self):
349346
return self.clone([])
350347

351-
# def pop(self):
352-
# self.bindings = self.bindings.outer
353-
# if self.bindings is None:
354-
# raise Exception("We've bottomed out of the bindings stack!")
355-
356348
def thaw(self, frozenbindings):
357349
"""
358350
Create a new read/write query context from the given solution
@@ -362,8 +354,7 @@ def thaw(self, frozenbindings):
362354
return c
363355

364356

365-
class Prologue(object):
366-
357+
class Prologue:
367358
"""
368359
A class for holding prefixing bindings and base URI information
369360
"""
@@ -402,7 +393,7 @@ def absolutize(self, iri):
402393
return iri
403394

404395

405-
class Query(object):
396+
class Query:
406397
"""
407398
A parsed and translated query
408399
"""

rdflib/plugins/stores/sleepycat.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,11 @@ def bb(u):
1212

1313

1414
try:
15-
from bsddb import db
15+
from bsddb3 import db
1616

1717
has_bsddb = True
1818
except ImportError:
19-
try:
20-
from bsddb3 import db
21-
22-
has_bsddb = True
23-
except ImportError:
24-
has_bsddb = False
19+
has_bsddb = False
2520

2621

2722
if has_bsddb:

rdflib/plugins/stores/sparqlstore.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,6 @@ def __init__(
101101
auth=None,
102102
**sparqlconnector_kwargs
103103
):
104-
"""
105-
"""
106104
super(SPARQLStore, self).__init__(
107105
query_endpoint=query_endpoint, returnFormat=returnFormat, auth=auth, **sparqlconnector_kwargs
108106
)
@@ -374,7 +372,7 @@ def remove_graph(self, graph):
374372
raise TypeError("The SPARQL store is read only")
375373

376374
def _is_contextual(self, graph):
377-
""" Returns `True` if the "GRAPH" keyword must appear
375+
"""Returns `True` if the "GRAPH" keyword must appear
378376
in the final SPARQL query sent to the endpoint.
379377
"""
380378
if (not self.context_aware) or (graph is None):

rdflib/resource.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
# -*- coding: utf-8 -*-
2-
3-
__doc__ = """
1+
"""
42
The :class:`~rdflib.resource.Resource` class wraps a
53
:class:`~rdflib.graph.Graph`
64
and a resource reference (i.e. a :class:`rdflib.term.URIRef` or

0 commit comments

Comments
 (0)