Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use only the urlpath parent as registry key #1342

Merged
merged 1 commit into from
Mar 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 4 additions & 14 deletions fiona/_vsiopener.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ from pathlib import Path

import stat

from urllib.parse import urlparse
from uuid import uuid4

from libc.string cimport memcpy
Expand Down Expand Up @@ -81,9 +80,7 @@ cdef int pyopener_stat(
# Reminder: openers are registered by URI scheme, authority, and
# *directory* path.
urlpath = pszFilename.decode("utf-8")
parsed_uri = urlparse(urlpath)
parent = Path(parsed_uri.path).parent
key = (parsed_uri.scheme, parsed_uri.netloc, parent.as_posix())
key = Path(urlpath).parent

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

registry = _OPENER_REGISTRY.get()
log.debug("Looking up opener in pyopener_read_dir: registry=%r, key=%r", registry, key)
Expand Down Expand Up @@ -171,10 +167,7 @@ cdef void* pyopener_open(
"""
urlpath = pszFilename.decode("utf-8")
mode = pszAccess.decode("utf-8")
parsed_uri = urlparse(urlpath)
path_to_check = Path(parsed_uri.path)
parent = path_to_check.parent
key = (parsed_uri.scheme, parsed_uri.netloc, parent.as_posix())
key = Path(urlpath).parent

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

@contextlib.contextmanager
def _opener_registration(urlpath, obj):
parsed_uri = urlparse(urlpath)
path_to_check = Path(parsed_uri.path)
parent = path_to_check.parent
key = (parsed_uri.scheme, parsed_uri.netloc, parent.as_posix())
key = Path(urlpath).parent

# Might raise.
opener = _create_opener(obj)
Expand Down
Loading