Skip to content

Commit

Permalink
parser.py fix pathlib mismatches
Browse files Browse the repository at this point in the history
  • Loading branch information
tgbugs committed Mar 30, 2021
1 parent dd6f620 commit 099e22f
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions rdflib/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,9 @@ def __repr__(self):

class FileInputSource(InputSource):
def __init__(self, file):
base = urljoin("file:", pathname2url(os.getcwd()))
system_id = URIRef(urljoin("file:", pathname2url(file.name)), base=base)
base = pathlib.Path.cwd().as_uri()
system_id = URIRef(pathlib.Path(file.name).absolute().as_uri(),
base=base)
super(FileInputSource, self).__init__(system_id)
self.file = file
if isinstance(file, TextIOBase): # Python3 unicode fp
Expand Down Expand Up @@ -284,9 +285,9 @@ def create_input_source(

def _create_input_source_from_location(file, format, input_source, location):
# Fix for Windows problem https://github.com/RDFLib/rdflib/issues/145
location = pathlib.Path(location)
if location.exists():
location = location.as_uri()
path = pathlib.Path(location)
if path.exists():
location = path.absolute().as_uri()

base = pathlib.Path.cwd().as_uri()

Expand Down

0 comments on commit 099e22f

Please sign in to comment.