diff options
author | Donny Winston <dwinston@alum.mit.edu> | 2020-05-11 15:52:07 -0400 |
---|---|---|
committer | Donny Winston <dwinston@alum.mit.edu> | 2020-05-11 15:52:07 -0400 |
commit | 56214859c434ae2dfc80078985a40a29635cc074 (patch) | |
tree | dd4b957059188a9aa1a622106a272a25376bedfe /rdflib | |
parent | a3245fb1fac921a5d8e07bce80914c42f5399b32 (diff) | |
download | rdflib-56214859c434ae2dfc80078985a40a29635cc074.tar.gz |
Use guess_format util to autodetect format
Diffstat (limited to 'rdflib')
-rw-r--r-- | rdflib/graph.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/rdflib/graph.py b/rdflib/graph.py index a92f3bc5..a666ac0c 100644 --- a/rdflib/graph.py +++ b/rdflib/graph.py @@ -1071,9 +1071,12 @@ class Graph(Node): if format is None: format = source.content_type if format is None: - # raise Exception("Could not determine format for %r. You can" + \ - # "expicitly specify one with the format argument." % source) - format = "application/rdf+xml" + try: + from rdflib.util import guess_format # local import avoids circular dependency + format = guess_format(source.file.name) + finally: + if format is None: + format = "application/rdf+xml" parser = plugin.get(format, Parser)() try: parser.parse(source, self, **args) |