Skip to content

Commit

Permalink
Fix archive/path parsing bug
Browse files Browse the repository at this point in the history
  • Loading branch information
sgillies committed Mar 1, 2024
1 parent 0420972 commit 5a8e175
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fiona/_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ class _ParsedPath(_Path):
@classmethod
def from_uri(cls, uri):
parts = urlparse(uri)
if sys.platform == "win32" and re.match(r"^[a-zA-Z]\:", parts.netloc) and not parts.path:
parsed_path = parts.netloc
if sys.platform == "win32" and re.match(r"^[a-zA-Z]\:", parts.netloc):
parsed_path = f"{parts.netloc}{parts.path}"
parsed_netloc = None
else:
parsed_path = parts.path
Expand Down
9 changes: 9 additions & 0 deletions tests/test__path.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,12 @@ def test_parse_zip_windows(monkeypatch):
vsi_path = _vsi_path(path)
assert vsi_path.startswith("/vsizip/D")
assert vsi_path.endswith("coutwildrnp.zip/coutwildrnp.shp")


def test_parse_zip_windows(monkeypatch):
"""Parse a tar+ Windows path."""
monkeypatch.setattr(sys, "platform", "win32")
path = _parse_path("tar://D:\\a\\Fiona\\Fiona\\tests\\data\\coutwildrnp.tar!testing/coutwildrnp.shp")
vsi_path = _vsi_path(path)
assert vsi_path.startswith("/vsitar/D")
assert vsi_path.endswith("coutwildrnp.tar/testing/coutwildrnp.shp")

0 comments on commit 5a8e175

Please sign in to comment.