1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
"""
SPARQL implementation for RDFLib
.. versionadded:: 4.0
"""
import sys
from typing import TYPE_CHECKING
SPARQL_LOAD_GRAPHS = True
"""
If True, using FROM <uri> and FROM NAMED <uri>
will load/parse more data
"""
SPARQL_DEFAULT_GRAPH_UNION = True
"""
If True - the default graph in the RDF Dataset is the union of all
named graphs (like RDFLib's ConjunctiveGraph)
"""
CUSTOM_EVALS = {}
"""
Custom evaluation functions
These must be functions taking (ctx, part) and raise
NotImplementedError if they cannot handle a certain part
"""
PLUGIN_ENTRY_POINT = "rdf.plugins.sparqleval"
from . import operators, parser, parserutils # noqa: E402
from .processor import prepareQuery, prepareUpdate, processUpdate # noqa: F401, E402
assert parser
assert operators
assert parserutils
if sys.version_info < (3, 8):
from importlib_metadata import entry_points
else:
from importlib.metadata import entry_points
all_entry_points = entry_points()
if hasattr(all_entry_points, "select"):
for ep in all_entry_points.select(group=PLUGIN_ENTRY_POINT):
CUSTOM_EVALS[ep.name] = ep.load()
else:
# Prior to Python 3.10, this returns a dict instead of the selection interface
if TYPE_CHECKING:
assert isinstance(all_entry_points, dict)
for ep in all_entry_points.get(PLUGIN_ENTRY_POINT, []):
CUSTOM_EVALS[ep.name] = ep.load()
__all__ = [
"prepareQuery",
"prepareUpdate",
"processUpdate",
"operators",
"parser",
"parserutils",
"CUSTOM_EVALS",
]
|