Skip to content

Commit 2be5e3b

Browse files
authored
Use only the urlpath parent as registry key (#1342)
1 parent 801129d commit 2be5e3b

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

fiona/_vsiopener.pyx

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ from pathlib import Path
1111

1212
import stat
1313

14-
from urllib.parse import urlparse
1514
from uuid import uuid4
1615

1716
from libc.string cimport memcpy
@@ -81,9 +80,7 @@ cdef int pyopener_stat(
8180
# Reminder: openers are registered by URI scheme, authority, and
8281
# *directory* path.
8382
urlpath = pszFilename.decode("utf-8")
84-
parsed_uri = urlparse(urlpath)
85-
parent = Path(parsed_uri.path).parent
86-
key = (parsed_uri.scheme, parsed_uri.netloc, parent.as_posix())
83+
key = Path(urlpath).parent
8784

8885
registry = _OPENER_REGISTRY.get()
8986
log.debug("Looking up opener in pyopener_stat: registry=%r, key=%r", registry, key)
@@ -125,8 +122,7 @@ cdef char ** pyopener_read_dir(
125122
) with gil:
126123
"""Provides a directory listing to GDAL from a Python filesystem."""
127124
urlpath = pszDirname.decode("utf-8")
128-
parsed_uri = urlparse(urlpath)
129-
key = (parsed_uri.scheme, parsed_uri.netloc, parsed_uri.path)
125+
key = Path(urlpath).parent
130126

131127
registry = _OPENER_REGISTRY.get()
132128
log.debug("Looking up opener in pyopener_read_dir: registry=%r, key=%r", registry, key)
@@ -171,10 +167,7 @@ cdef void* pyopener_open(
171167
"""
172168
urlpath = pszFilename.decode("utf-8")
173169
mode = pszAccess.decode("utf-8")
174-
parsed_uri = urlparse(urlpath)
175-
path_to_check = Path(parsed_uri.path)
176-
parent = path_to_check.parent
177-
key = (parsed_uri.scheme, parsed_uri.netloc, parent.as_posix())
170+
key = Path(urlpath).parent
178171

179172
registry = _OPENER_REGISTRY.get()
180173
log.debug("Looking up opener in pyopener_open: registry=%r, key=%r", registry, key)
@@ -288,10 +281,7 @@ cdef int pyopener_close(void *pFile) with gil:
288281

289282
@contextlib.contextmanager
290283
def _opener_registration(urlpath, obj):
291-
parsed_uri = urlparse(urlpath)
292-
path_to_check = Path(parsed_uri.path)
293-
parent = path_to_check.parent
294-
key = (parsed_uri.scheme, parsed_uri.netloc, parent.as_posix())
284+
key = Path(urlpath).parent
295285

296286
# Might raise.
297287
opener = _create_opener(obj)

0 commit comments

Comments
 (0)