Skip to content

Commit 85a5c38

Browse files
committed
Rename regex variable appropriately and allow more complex chaining
1 parent 12d1609 commit 85a5c38

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

pandas/io/common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171

7272
_VALID_URLS = set(uses_relative + uses_netloc + uses_params)
7373
_VALID_URLS.discard("")
74-
_RFC_3986_PATTERN = re.compile(r"^[A-Za-z][A-Za-z0-9+\-+.]*(::[A-Za-z0-9+\-+.]+)?://")
74+
_FSSPEC_URL_PATTERN = re.compile(r"^[A-Za-z][A-Za-z0-9+\-+.]*(::[A-Za-z0-9+\-+.]+)*://")
7575

7676
BaseBufferT = TypeVar("BaseBufferT", bound=BaseBuffer)
7777

@@ -291,7 +291,7 @@ def is_fsspec_url(url: FilePath | BaseBuffer) -> bool:
291291
"""
292292
return (
293293
isinstance(url, str)
294-
and bool(_RFC_3986_PATTERN.match(url))
294+
and bool(_FSSPEC_URL_PATTERN.match(url))
295295
and not url.startswith(("http://", "https://"))
296296
)
297297

pandas/tests/io/test_common.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,9 @@ def test_is_fsspec_url_chained():
505505
# GH#48978 Support chained fsspec URLs
506506
# See https://filesystem-spec.readthedocs.io/en/latest/features.html#url-chaining.
507507
assert icom.is_fsspec_url("filecache::s3://pandas/test.csv")
508+
assert icom.is_fsspec_url("zip://test.csv::filecache::gcs://bucket/afile.zip")
509+
assert icom.is_fsspec_url("filecache::zip://test.csv::gcs://bucket/afile.zip")
510+
assert icom.is_fsspec_url("filecache::dask::s3://pandas/test.csv")
508511
assert not icom.is_fsspec_url("filecache:s3://pandas/test.csv")
509512
assert not icom.is_fsspec_url("filecache:::s3://pandas/test.csv")
510513
assert not icom.is_fsspec_url("filecache::://pandas/test.csv")

0 commit comments

Comments
 (0)