From 6292e0aca3627cd9ff170ae330902418b609bfcf Mon Sep 17 00:00:00 2001 From: Dan Allan Date: Thu, 16 Jan 2025 13:24:47 -0500 Subject: [PATCH] Fix path handling for Windows --- tiled/utils.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/tiled/utils.py b/tiled/utils.py index d2cb25341..12d534c04 100644 --- a/tiled/utils.py +++ b/tiled/utils.py @@ -718,20 +718,19 @@ def path_from_uri(uri) -> Path: """ parsed = urlparse(uri) if parsed.scheme == "file": - path = parsed.path + if platform.system() == "Windows": + # We slice because we need "C:/..." not "/C:/...". + path = Path(parsed.path[1:]) + else: + path = Path(parsed.path) elif parsed.scheme == "sqlite": # The path begins after the third slash. - path = parsed.path[1:] + path = Path(parsed.path[1:]) else: raise ValueError( "Supported schemes are 'file' and 'sqlite'. " f"Did not recognize scheme {parsed.scheme!r}" ) - if platform.system() == "Windows": - # We slice because we need "C:/..." not "/C:/...". - path = Path(path[1:]) - else: - path = Path(path) return path