Skip to content

Commit cc951ca

Browse files
committed
BUG: Recognize chained fsspec URLs
1 parent 826f0d3 commit cc951ca

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

pandas/io/common.py

Lines changed: 1 addition & 1 deletion
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+\-+.]*://")
74+
_RFC_3986_PATTERN = re.compile(r"^[A-Za-z][A-Za-z0-9+\-+.]*(::[A-Za-z0-9+\-+.]+)?://")
7575

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

pandas/tests/io/json/test_pandas.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1753,6 +1753,7 @@ def test_read_timezone_information(self):
17531753
[
17541754
"s3://example-fsspec/",
17551755
"gcs://another-fsspec/file.json",
1756+
"filecache::s3://yet-another-fsspec/file.json",
17561757
"https://example-site.com/data",
17571758
"some-protocol://data.txt",
17581759
],

pandas/tests/io/test_common.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,15 @@ def test_is_fsspec_url():
501501
assert icom.is_fsspec_url("RFC-3986+compliant.spec://something")
502502

503503

504+
def test_is_fsspec_url_chained():
505+
# GH#48978 Support chained fsspec URLs
506+
# See https://filesystem-spec.readthedocs.io/en/latest/features.html#url-chaining.
507+
assert icom.is_fsspec_url("filecache::s3://pandas/test.csv")
508+
assert not icom.is_fsspec_url("filecache:s3://pandas/test.csv")
509+
assert not icom.is_fsspec_url("filecache:::s3://pandas/test.csv")
510+
assert not icom.is_fsspec_url("filecache::://pandas/test.csv")
511+
512+
504513
@pytest.mark.parametrize("encoding", [None, "utf-8"])
505514
@pytest.mark.parametrize("format", ["csv", "json"])
506515
def test_codecs_encoding(encoding, format):

0 commit comments

Comments
 (0)