diff options
author | Nicholas Car <nicholas.car@surroundaustralia.com> | 2020-09-17 19:49:07 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-17 19:49:07 +1000 |
commit | 0ed594eb8ca8a595863c18c4b3065f8f7ca56c01 (patch) | |
tree | 9e018143a682e2c6155d60c6928cf6ffb38f45f3 | |
parent | b8ab037f23a204b973dfc31a96155aa9f219138b (diff) | |
parent | 302fbf45031cf4e78f7c92cc40122acdc2f0b1ee (diff) | |
download | rdflib-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.py | 2 | ||||
-rw-r--r-- | rdflib/plugins/sparql/sparql.py | 16 |
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 ) |