diff options
author | Anatoly Scherbakov <altaisoft@gmail.com> | 2020-09-08 23:07:57 +0700 |
---|---|---|
committer | Anatoly Scherbakov <altaisoft@gmail.com> | 2020-09-08 23:07:57 +0700 |
commit | 65987a39996c045cb9b7156723369483040ab5df (patch) | |
tree | 72855b03fc48ee5fcd30bba4d48edd71790d7186 /rdflib/parser.py | |
parent | 5e06430887dc50d8c0f072051d0c4b0b9a1d0662 (diff) | |
download | rdflib-65987a39996c045cb9b7156723369483040ab5df.tar.gz |
#1160 create_input_source() conflicting arguments and a test for them
Diffstat (limited to 'rdflib/parser.py')
-rw-r--r-- | rdflib/parser.py | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/rdflib/parser.py b/rdflib/parser.py index fcaed5e4..cad000e1 100644 --- a/rdflib/parser.py +++ b/rdflib/parser.py @@ -206,18 +206,12 @@ def create_input_source( """ # test that exactly one of source, location, file, and data is not None. - if ( - sum( - ( - source is not None, - location is not None, - file is not None, - data is not None, - ) + non_empty_arguments = list(filter(bool, [source, location, file, data])) + + if len(non_empty_arguments) != 1: + raise ValueError( + "exactly one of source, location, file or data must be given", ) - != 1 - ): - raise ValueError("exactly one of source, location, file or data must be given") input_source = None @@ -259,7 +253,7 @@ def create_input_source( if os.path.exists(location): location = pathname2url(location) base = urljoin("file:", "%s/" % pathname2url(os.getcwd())) - absolute_location = URIRef(location, base=base).defrag() + absolute_location = URIRef(location, base=base) if absolute_location.startswith("file:///"): filename = url2pathname(absolute_location.replace("file:///", "/")) file = open(filename, "rb") |