Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Bug fixes

- Fix wrong handling of some windows network paths (#635).
- Fix writing empty string category columns with arrow fails (#621).
- Fix overwriting a corrupt fileGDB directory (#600).

Expand Down
15 changes: 15 additions & 0 deletions pyogrio/tests/test_path.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import contextlib
import os
import sys
from pathlib import Path
from zipfile import ZIP_DEFLATED, ZipFile

Expand Down Expand Up @@ -109,6 +110,20 @@ def test_vsi_path_unknown():
assert vsi_path("s4://test/data.geojson") == "s4://test/data.geojson"


@pytest.mark.parametrize(
"path, expected",
[
(r"\\server\!test\example.shp", r"\\server\!test\example.shp"),
(r"\\server\!test\example.shp.zip", r"\\server\!test\example.shp.zip"),
(r"\\server\!test\example.zip", r"\\server\!test\example.zip"),
],
)
@pytest.mark.skipif(not sys.platform.startswith("win"), reason="Windows specific paths")
def test_vsi_path_windows(path, expected):
"""Test for some specific Windows paths that only pass on Windows."""
assert vsi_path(path) == expected


def test_vsi_handling_read_functions(naturalearth_lowres_vsi):
# test that all different read entry points have the path handling
# (a zip:// path would otherwise fail)
Expand Down
4 changes: 3 additions & 1 deletion pyogrio/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ def vsi_path(path: str | Path) -> str:

# Windows drive letters (e.g. "C:\") confuse `urlparse` as they look like
# URL schemes
if sys.platform == "win32" and re.match("^[a-zA-Z]\\:", path):
if sys.platform == "win32" and (
re.match("^[a-zA-Z]\\:", path) or path.startswith(r"\\")
):
# If it is not a zip file or it is multi-extension zip file that is directly
# supported by a GDAL driver, return the path as is.
if not path.split("!")[0].endswith(".zip"):
Expand Down