mirror of
https://github.com/aclist/dztui.git
synced 2026-11-16 23:01:53 +01:00
Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
45c412e1ad | ||
|
|
a32c99b3eb | ||
|
|
da474e274f | ||
|
|
d694aa56e8 | ||
|
|
6adecbedaa |
No files matched your search
+1
-1
@@ -15,7 +15,7 @@ author = 'aclist'
|
||||
extensions = []
|
||||
|
||||
templates_path = ['_templates']
|
||||
exclude_patterns = []
|
||||
exclude_patterns = [] # type: ignore[var-annotated]
|
||||
|
||||
|
||||
|
||||
|
||||
+13
-4
@@ -27,6 +27,7 @@ from dzgui.const.constants import (
|
||||
FLATPAK_STEAM_PATH,
|
||||
LIBRARYFOLDERS_PATH,
|
||||
REQUEST_TIMEOUT,
|
||||
SNAP_STEAM_PATH,
|
||||
UBUNTU_STEAM_PATH,
|
||||
VDF_PATH,
|
||||
)
|
||||
@@ -67,23 +68,31 @@ def get_steam_paths() -> list[tuple[Path, str]]:
|
||||
HOME = Path.home()
|
||||
env = os.environ.get("XDG_DATA_HOME")
|
||||
if env is not None:
|
||||
XDG_DATA_HOME = env
|
||||
XDG_DATA_HOME = Path(env)
|
||||
DEFAULT_PATH = XDG_DATA_HOME.joinpath("Steam")
|
||||
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)
|
||||
UBUNTU_PATH = HOME.joinpath(UBUNTU_STEAM_PATH)
|
||||
DEBIAN_PATH = HOME.joinpath(DEBIAN_STEAM_PATH)
|
||||
SNAP_PATH = HOME.joinpath(SNAP_STEAM_PATH)
|
||||
|
||||
human = {
|
||||
DEFAULT_PATH: wizard.desc_default_path,
|
||||
FLATPAK_PATH: wizard.desc_flatpak_path,
|
||||
UBUNTU_PATH: wizard.desc_ubuntu_path,
|
||||
SNAP_PATH: wizard.desc_snap_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:
|
||||
continue
|
||||
if path is not FLATPAK_PATH and has_steam_client() is False:
|
||||
|
||||
@@ -60,6 +60,7 @@ DEFAULT_STEAM_PATH = ".local/share/Steam"
|
||||
FLATPAK_ROOT_PATH = ".var/app/com.valvesoftware.Steam"
|
||||
FLATPAK_STEAM_PATH = FLATPAK_ROOT_PATH + "/data/Steam"
|
||||
UBUNTU_STEAM_PATH = ".steam/steam"
|
||||
SNAP_STEAM_PATH = "snap/steam/common/" + DEFAULT_STEAM_PATH
|
||||
DEBIAN_STEAM_PATH = ".steam/debian-installation"
|
||||
|
||||
LOG_FILTERS = ("CRITICAL", "WARNING", "INFO", "DEBUG")
|
||||
|
||||
@@ -17,6 +17,7 @@ desc_flatpak_path = (
|
||||
"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_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>."
|
||||
no_valid_paths = (
|
||||
"No valid Steam path or Steam command found on system. Please install Steam to continue."
|
||||
|
||||
@@ -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)
|
||||
Reference in new issue
Block a user