@@ -11,7 +11,6 @@ from pathlib import Path
11
11
12
12
import stat
13
13
14
- from urllib.parse import urlparse
15
14
from uuid import uuid4
16
15
17
16
from libc.string cimport memcpy
@@ -81,9 +80,7 @@ cdef int pyopener_stat(
81
80
# Reminder: openers are registered by URI scheme, authority, and
82
81
# *directory* path.
83
82
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
87
84
88
85
registry = _OPENER_REGISTRY.get()
89
86
log.debug(" Looking up opener in pyopener_stat: registry=%r , key=%r " , registry, key)
@@ -125,8 +122,7 @@ cdef char ** pyopener_read_dir(
125
122
) with gil:
126
123
""" Provides a directory listing to GDAL from a Python filesystem."""
127
124
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
130
126
131
127
registry = _OPENER_REGISTRY.get()
132
128
log.debug(" Looking up opener in pyopener_read_dir: registry=%r , key=%r " , registry, key)
@@ -171,10 +167,7 @@ cdef void* pyopener_open(
171
167
"""
172
168
urlpath = pszFilename.decode(" utf-8" )
173
169
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
178
171
179
172
registry = _OPENER_REGISTRY.get()
180
173
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:
288
281
289
282
@contextlib.contextmanager
290
283
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
295
285
296
286
# Might raise.
297
287
opener = _create_opener(obj)
0 commit comments