- QUrl.toLocalFile() prevents leading slash on Windows drive letters (e.g. "/C:/Users/...") that was causing Path operations to fail - remove docs/ from .gitignore so document revisions are tracked in Git
This commit is contained in:
+1
-1
@@ -21,7 +21,6 @@ env/
|
||||
*.swp
|
||||
*.swo
|
||||
*~
|
||||
docs
|
||||
|
||||
# OS
|
||||
.DS_Store
|
||||
@@ -56,3 +55,4 @@ AGENTS.md
|
||||
CONVENTIONS.md
|
||||
specs/
|
||||
graphify-out/
|
||||
.personal-docs/
|
||||
|
||||
@@ -4,9 +4,8 @@ import logging
|
||||
import shutil
|
||||
import time
|
||||
from pathlib import Path
|
||||
from urllib.parse import unquote, urlparse
|
||||
|
||||
from PySide6.QtCore import Property, QObject, Signal, Slot
|
||||
from PySide6.QtCore import Property, QObject, QUrl, Signal, Slot
|
||||
|
||||
from pygui.backend.license.license_manager import (
|
||||
LICENSE_FILENAME_RE,
|
||||
@@ -21,9 +20,15 @@ TRIAL_DAYS = 30
|
||||
|
||||
|
||||
def _to_local_path(path_or_url: str) -> Path:
|
||||
"""Accept both plain paths and file:// URLs (QML FileDialog gives URLs)."""
|
||||
"""Accept both plain paths and file:// URLs (QML FileDialog gives URLs).
|
||||
|
||||
Uses QUrl.toLocalFile() rather than urlparse — a manual
|
||||
urlparse().path strip leaves a leading slash before a Windows drive
|
||||
letter (e.g. "/C:/Users/...", not a valid absolute path), which
|
||||
QUrl's platform-aware conversion handles correctly.
|
||||
"""
|
||||
if path_or_url.startswith("file:"):
|
||||
return Path(unquote(urlparse(path_or_url).path))
|
||||
return Path(QUrl(path_or_url).toLocalFile())
|
||||
return Path(path_or_url)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user