summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAshley Sommer <ashley.sommer@csiro.au>2020-09-17 15:51:25 +1000
committerAshley Sommer <ashley.sommer@csiro.au>2020-09-17 15:51:48 +1000
commit302fbf45031cf4e78f7c92cc40122acdc2f0b1ee (patch)
treeef611c537e392d6554976f4d55258179753513c7
parent63f46e476e6dd0ae3eef5b71a35e3c8b97a01c6b (diff)
downloadrdflib-302fbf45031cf4e78f7c92cc40122acdc2f0b1ee.tar.gz
Move to using graph.parse() rather than deprecated graph.load() for sparql graph loaderfix_deprecated_load
-rw-r--r--rdflib/plugins/sparql/results/rdfresults.py2
-rw-r--r--rdflib/plugins/sparql/sparql.py16
2 files changed, 11 insertions, 7 deletions
diff --git a/rdflib/plugins/sparql/results/rdfresults.py b/rdflib/plugins/sparql/results/rdfresults.py
index 7f64bbf4..52df64ff 100644
--- a/rdflib/plugins/sparql/results/rdfresults.py
+++ b/rdflib/plugins/sparql/results/rdfresults.py
@@ -15,7 +15,7 @@ class RDFResult(Result):
if not isinstance(source, Graph):
graph = Graph()
- graph.load(source, **kwargs)
+ graph.parse(source, **kwargs)
else:
graph = source
diff --git a/rdflib/plugins/sparql/sparql.py b/rdflib/plugins/sparql/sparql.py
index 888ca667..f24aa564 100644
--- a/rdflib/plugins/sparql/sparql.py
+++ b/rdflib/plugins/sparql/sparql.py
@@ -274,16 +274,20 @@ class QueryContext(object):
def load(self, source, default=False, **kwargs):
def _load(graph, source):
try:
- return graph.load(source, **kwargs)
- except:
+ return graph.parse(source, format="turtle", **kwargs)
+ except Exception:
pass
try:
- return graph.load(source, format="n3", **kwargs)
- except:
+ return graph.parse(source, format="xml", **kwargs)
+ except Exception:
pass
try:
- return graph.load(source, format="nt", **kwargs)
- except:
+ return graph.parse(source, format="n3", **kwargs)
+ except Exception:
+ pass
+ try:
+ return graph.parse(source, format="nt", **kwargs)
+ except Exception:
raise Exception(
"Could not load %s as either RDF/XML, N3 or NTriples" % source
)