From 6e36c038e4269db351f17d89e62fddb105578d58 Mon Sep 17 00:00:00 2001 From: Nicholas Smith Date: Tue, 3 Sep 2024 17:45:17 -0500 Subject: [PATCH] Preserve parameters in paths (#65) * Preserve parameters in paths Fixes #64 * Add test * No glob * Add py3.12 --- .github/workflows/ci.yml | 2 +- src/fsspec_xrootd/xrootd.py | 4 ++-- tests/test_basicio.py | 11 ++++++++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ffe273f..a2da66f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,7 +39,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.8", "3.9", "3.10", "3.11"] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] runs-on: [ubuntu-latest] defaults: run: diff --git a/src/fsspec_xrootd/xrootd.py b/src/fsspec_xrootd/xrootd.py index 4090d3f..c578e68 100644 --- a/src/fsspec_xrootd/xrootd.py +++ b/src/fsspec_xrootd/xrootd.py @@ -35,7 +35,7 @@ class ErrorCodes(IntEnum): def _async_wrap( - func: Callable[..., XRootDStatus | tuple[XRootDStatus, T]] + func: Callable[..., XRootDStatus | tuple[XRootDStatus, T]], ) -> Callable[..., Coroutine[Any, Any, tuple[XRootDStatus, T]]]: """Wraps pyxrootd functions to run asynchronously. Returns an async callable @@ -302,7 +302,7 @@ def _get_kwargs_from_urls(u: str) -> dict[Any, Any]: def _strip_protocol(cls, path: str | list[str]) -> Any: if isinstance(path, str): if path.startswith(cls.protocol): - return client.URL(path).path.rstrip("/") or cls.root_marker + return client.URL(path).path_with_params.rstrip("/") or cls.root_marker # assume already stripped return path.rstrip("/") or cls.root_marker elif isinstance(path, list): diff --git a/tests/test_basicio.py b/tests/test_basicio.py index d257575..db8dec8 100644 --- a/tests/test_basicio.py +++ b/tests/test_basicio.py @@ -110,7 +110,16 @@ def test_path_parsing(): "root://serv.er//dir/", ] ) - assert paths == ["/blah", "/more", "dir", "/dir"] + assert paths == [ + "/blah", + "/more", + "dir", + "/dir", + ] + # get_fs_token_paths will expand glob patterns if '*', '?', or '[' are present + # so we need to test parameter parsing using a different method + fs, path = fsspec.url_to_fs("root://server.com//blah?param1=1¶m2=2") + assert path == "/blah?param1=1¶m2=2" def test_pickle(localserver, clear_server):