File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -503,10 +503,14 @@ def _init_filesystem(url, **kwargs):
503503 else :
504504 protocols = set ()
505505
506- is_local = bool (protocols .intersection ({"file" , "local" })) or fs .__class__ .__name__ == "LocalFileSystem"
507-
506+ is_local = (
507+ bool (protocols .intersection ({"file" , "local" }))
508+ or fs .__class__ .__name__ == "LocalFileSystem"
509+ )
510+
508511 if is_local :
509512 from urllib .parse import unquote
513+
510514 path = unquote (path )
511515
512516 # Path compatibility, fsspec/gcsfs behaviour varies between versions.
Original file line number Diff line number Diff line change 11import os
2- import pytest
3- from pathlib import Path
42from malariagen_data .util import _init_filesystem
53
4+
65def test_init_filesystem_decodes_file_uri_escaped_path (tmp_path ):
76 dir_with_space = tmp_path / "dir with space's"
87 dir_with_space .mkdir ()
98 file_path = dir_with_space / "v3-config.json"
109 file_path .write_text ('{"foo": "bar"}' )
1110
1211 uri = dir_with_space .as_uri ()
13-
12+
1413 fs , path = _init_filesystem (uri )
15-
14+
1615 assert "%20" in uri
1716 assert "%20" not in path
1817 assert "%27" not in path
@@ -27,10 +26,10 @@ def test_init_filesystem_plain_local_path_unchanged(tmp_path):
2726 dir_with_space .mkdir ()
2827 file_path = dir_with_space / "v3-config.json"
2928 file_path .write_text ('{"foo": "bar"}' )
30-
29+
3130 uri = str (dir_with_space )
32-
31+
3332 fs , path = _init_filesystem (uri )
34-
33+
3534 with fs .open (os .path .join (path , "v3-config.json" ), "r" ) as f :
3635 assert f .read () == '{"foo": "bar"}'
You can’t perform that action at this time.
0 commit comments