Compare commits

..
Author SHA1 Message Date
aclist 45c412e1ad change: make reference to snap more generic 2026-11-17 03:12:05 +09:00
aclist a32c99b3eb feat: support Ubuntu Snap path 2026-11-17 02:22:59 +09:00
aclist da474e274f chore: update tests 2026-11-17 01:45:26 +09:00
aclist d694aa56e8 chore: clear typehinting errors 2026-11-17 01:44:23 +09:00
aclist 6adecbedaa fix: parse custom xdg path correctly 2026-11-17 01:44:12 +09:00
5 changed files with 59 additions and 5 deletions

No files matched your search

+1 -1
View File
@@ -15,7 +15,7 @@ author = 'aclist'
extensions = [] extensions = []
templates_path = ['_templates'] templates_path = ['_templates']
exclude_patterns = [] exclude_patterns = [] # type: ignore[var-annotated]
+13 -4
View File
@@ -27,6 +27,7 @@ from dzgui.const.constants import (
FLATPAK_STEAM_PATH, FLATPAK_STEAM_PATH,
LIBRARYFOLDERS_PATH, LIBRARYFOLDERS_PATH,
REQUEST_TIMEOUT, REQUEST_TIMEOUT,
SNAP_STEAM_PATH,
UBUNTU_STEAM_PATH, UBUNTU_STEAM_PATH,
VDF_PATH, VDF_PATH,
) )
@@ -67,23 +68,31 @@ def get_steam_paths() -> list[tuple[Path, str]]:
HOME = Path.home() HOME = Path.home()
env = os.environ.get("XDG_DATA_HOME") env = os.environ.get("XDG_DATA_HOME")
if env is not None: if env is not None:
XDG_DATA_HOME = env XDG_DATA_HOME = Path(env)
DEFAULT_PATH = XDG_DATA_HOME.joinpath("Steam")
else: else:
XDG_DATA_HOME = DEFAULT_STEAM_PATH DEFAULT_PATH = HOME.joinpath(DEFAULT_STEAM_PATH)
DEFAULT_PATH = HOME.joinpath(XDG_DATA_HOME)
FLATPAK_PATH = HOME.joinpath(FLATPAK_STEAM_PATH) FLATPAK_PATH = HOME.joinpath(FLATPAK_STEAM_PATH)
UBUNTU_PATH = HOME.joinpath(UBUNTU_STEAM_PATH) UBUNTU_PATH = HOME.joinpath(UBUNTU_STEAM_PATH)
DEBIAN_PATH = HOME.joinpath(DEBIAN_STEAM_PATH) DEBIAN_PATH = HOME.joinpath(DEBIAN_STEAM_PATH)
SNAP_PATH = HOME.joinpath(SNAP_STEAM_PATH)
human = { human = {
DEFAULT_PATH: wizard.desc_default_path, DEFAULT_PATH: wizard.desc_default_path,
FLATPAK_PATH: wizard.desc_flatpak_path, FLATPAK_PATH: wizard.desc_flatpak_path,
UBUNTU_PATH: wizard.desc_ubuntu_path, UBUNTU_PATH: wizard.desc_ubuntu_path,
SNAP_PATH: wizard.desc_snap_path,
DEBIAN_PATH: wizard.desc_debian_path, DEBIAN_PATH: wizard.desc_debian_path,
} }
for path in DEFAULT_PATH, FLATPAK_PATH, UBUNTU_PATH, DEBIAN_PATH: for path in (
DEFAULT_PATH,
FLATPAK_PATH,
UBUNTU_PATH,
SNAP_PATH,
DEBIAN_PATH,
):
if path is FLATPAK_PATH and has_flatpak_client() is False: if path is FLATPAK_PATH and has_flatpak_client() is False:
continue continue
if path is not FLATPAK_PATH and has_steam_client() is False: if path is not FLATPAK_PATH and has_steam_client() is False:
+1
View File
@@ -60,6 +60,7 @@ DEFAULT_STEAM_PATH = ".local/share/Steam"
FLATPAK_ROOT_PATH = ".var/app/com.valvesoftware.Steam" FLATPAK_ROOT_PATH = ".var/app/com.valvesoftware.Steam"
FLATPAK_STEAM_PATH = FLATPAK_ROOT_PATH + "/data/Steam" FLATPAK_STEAM_PATH = FLATPAK_ROOT_PATH + "/data/Steam"
UBUNTU_STEAM_PATH = ".steam/steam" UBUNTU_STEAM_PATH = ".steam/steam"
SNAP_STEAM_PATH = "snap/steam/common/" + DEFAULT_STEAM_PATH
DEBIAN_STEAM_PATH = ".steam/debian-installation" DEBIAN_STEAM_PATH = ".steam/debian-installation"
LOG_FILTERS = ("CRITICAL", "WARNING", "INFO", "DEBUG") LOG_FILTERS = ("CRITICAL", "WARNING", "INFO", "DEBUG")
+1
View File
@@ -17,6 +17,7 @@ desc_flatpak_path = (
"This is the default Steam path if you are using <b>Flatpak Steam</b>." "This is the default Steam path if you are using <b>Flatpak Steam</b>."
) )
desc_ubuntu_path = "This is the default Steam path on <b>Ubuntu-based systems</b>." desc_ubuntu_path = "This is the default Steam path on <b>Ubuntu-based systems</b>."
desc_snap_path = "This is the default Steam path on <b>systems using Snap packages</b>."
desc_debian_path = "This is the default Steam path on <b>Debian-based systems</b>." desc_debian_path = "This is the default Steam path on <b>Debian-based systems</b>."
no_valid_paths = ( no_valid_paths = (
"No valid Steam path or Steam command found on system. Please install Steam to continue." "No valid Steam path or Steam command found on system. Please install Steam to continue."
+43
View File
@@ -0,0 +1,43 @@
import pytest
import tempfile
from pathlib import Path
from typing import TYPE_CHECKING
from dzgui.api.steam import get_steam_paths
if TYPE_CHECKING:
from _pytest.monkeypatch import MonkeyPatch
def test_custom_xdg_path(monkeypatch: "MonkeyPatch") -> None:
tmp = tempfile.TemporaryDirectory(delete=False).name
custom_path = Path(tmp).joinpath("xdg_data_home")
monkeypatch.setenv("XDG_DATA_HOME", str(custom_path))
vdf_path = custom_path.joinpath("Steam/steamapps")
vdf_path.mkdir(parents=True, exist_ok=True)
vdf_path.joinpath("libraryfolders.vdf").touch()
resolved_paths = get_steam_paths()
expect = custom_path.joinpath("Steam")
assert any(expect in el for el in resolved_paths)
def test_default_xdg_path() -> None:
resolved_paths = get_steam_paths()
expect = Path.home().joinpath(".local/share/Steam")
assert any(expect in el for el in resolved_paths)
def test_ubuntu_path() -> None:
resolved_paths = get_steam_paths()
expect = Path.home().joinpath(".steam/steam")
assert any(expect in el for el in resolved_paths)
@pytest.mark.flatpak
def test_flatpak_path() -> None:
resolved_paths = get_steam_paths()
expect = Path.home().joinpath(".var/app/com.valvesoftware.Steam/data/steam")
assert any(expect in el for el in resolved_paths)