summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Car <nicholas.car@surroundaustralia.com>2020-09-17 19:49:07 +1000
committerGitHub <noreply@github.com>2020-09-17 19:49:07 +1000
commit0ed594eb8ca8a595863c18c4b3065f8f7ca56c01 (patch)
tree9e018143a682e2c6155d60c6928cf6ffb38f45f3
parentb8ab037f23a204b973dfc31a96155aa9f219138b (diff)
parent302fbf45031cf4e78f7c92cc40122acdc2f0b1ee (diff)
downloadrdflib-0ed594eb8ca8a595863c18c4b3065f8f7ca56c01.tar.gz
Merge pull request #1167 from RDFLib/fix_deprecated_load
Move to using graph.parse() rather than deprecated graph.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
)