mirror of
https://github.com/aclist/dztui.git
synced 2026-11-03 00:22:04 +01:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
12daf041ff |
No files matched your search
@@ -2,7 +2,6 @@ import logging
|
||||
import re
|
||||
|
||||
from collections.abc import Iterator
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
from warnings import deprecated
|
||||
@@ -70,28 +69,6 @@ class ACF:
|
||||
except StopIteration:
|
||||
return acf
|
||||
|
||||
def search_key(self, key: str) -> str:
|
||||
return str(self.dict["AppState"][key])
|
||||
|
||||
def date_to_str(self, epoch: int) -> str | None:
|
||||
if epoch == 0:
|
||||
return None
|
||||
return datetime.fromtimestamp(epoch).isoformat(" ")
|
||||
|
||||
def get_date_by_key(self, key: str) -> str | None:
|
||||
try:
|
||||
stamp = int(self.search_key(key))
|
||||
return self.date_to_str(stamp)
|
||||
except Exception as e:
|
||||
logger.critical(e)
|
||||
return None
|
||||
|
||||
def get_last_updated(self) -> str | None:
|
||||
return self.get_date_by_key("LastUpdated")
|
||||
|
||||
def get_last_played(self) -> str | None:
|
||||
return self.get_date_by_key("LastPlayed")
|
||||
|
||||
def get_allows_downloads(self) -> int | None:
|
||||
try:
|
||||
# TODO: consider coercing strs to ints on initial import
|
||||
|
||||
@@ -389,18 +389,6 @@ def get_running_app() -> int | None:
|
||||
return None
|
||||
|
||||
|
||||
def get_last_updated(path: Path, appid: int) -> str | None:
|
||||
root_path = get_app_path(path, appid)
|
||||
acf = root_path.joinpath(f"steamapps/appmanifest_{appid}.acf")
|
||||
return ACF(acf).get_last_updated()
|
||||
|
||||
|
||||
def get_last_played(path: Path, appid: int) -> str | None:
|
||||
root_path = get_app_path(path, appid)
|
||||
acf = root_path.joinpath(f"steamapps/appmanifest_{appid}.acf")
|
||||
return ACF(acf).get_last_played()
|
||||
|
||||
|
||||
def get_app_allows_downloads(path: Path, appid: int) -> bool:
|
||||
try:
|
||||
root_path = get_app_path(path, appid)
|
||||
|
||||
+1
-1
Submodule dzgui/lib/dayzquery updated: fe413df8e8...07483b88ed.
@@ -2,7 +2,6 @@ from pathlib import Path
|
||||
from typing import Callable, TYPE_CHECKING
|
||||
|
||||
from dzgui.api import pefile as PeFile
|
||||
from dzgui.api.steam import get_last_updated
|
||||
|
||||
from dzgui.config import query
|
||||
from dzgui.const.constants import (
|
||||
@@ -341,10 +340,8 @@ class Options(ScrollableMixin, Gtk.ScrolledWindow): # type: ignore
|
||||
[LeftLabel(options.flatpak_label), self.flatpak_toggle],
|
||||
)
|
||||
|
||||
self.dayz_version_label = Gtk.Label(label=strings.null, halign=Gtk.Align.START)
|
||||
self.dayz_exp_version_label = Gtk.Label(
|
||||
label=strings.null, halign=Gtk.Align.START
|
||||
)
|
||||
self.dayz_version_label = Gtk.Label(label=strings.null)
|
||||
self.dayz_exp_version_label = Gtk.Label(label=strings.null)
|
||||
|
||||
version_rows = [
|
||||
[LeftLabel(APPNAME_DAYZ), self.dayz_version_label],
|
||||
@@ -470,18 +467,10 @@ class Options(ScrollableMixin, Gtk.ScrolledWindow): # type: ignore
|
||||
dayz_version = PeFile.get_pretty_version(steam_path, APPID_DAYZ)
|
||||
if dayz_version is None:
|
||||
dayz_version = strings.null
|
||||
else:
|
||||
last_updated = get_last_updated(steam_path, APPID_DAYZ)
|
||||
if last_updated is not None:
|
||||
dayz_version += f" (updated at {last_updated})"
|
||||
|
||||
dayz_exp_version = PeFile.get_pretty_version(steam_path, APPID_DAYZ_EXP)
|
||||
if dayz_exp_version is None:
|
||||
dayz_exp_version = strings.null
|
||||
else:
|
||||
last_updated = get_last_updated(steam_path, APPID_DAYZ_EXP)
|
||||
if last_updated is not None:
|
||||
dayz_exp_version += f" (updated at {last_updated})"
|
||||
|
||||
self.dayz_version_label.set_text(dayz_version)
|
||||
self.dayz_exp_version_label.set_text(dayz_exp_version)
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
"AppState"
|
||||
{
|
||||
"appid" "444"
|
||||
"Universe" "1"
|
||||
"name" "TEST APP"
|
||||
"StateFlags" "4"
|
||||
"installdir" "TESTAPP"
|
||||
"LastUpdated" "1792595373"
|
||||
"LastPlayed" "0"
|
||||
"SizeOnDisk" "0"
|
||||
"StagingSize" "0"
|
||||
"buildid" "0"
|
||||
"LastOwner" "0"
|
||||
"DownloadType" "2"
|
||||
"UpdateResult" "0"
|
||||
"BytesToDownload" "0"
|
||||
"BytesDownloaded" "0"
|
||||
"BytesToStage" "0"
|
||||
"BytesStaged" "0"
|
||||
"TargetBuildID" "0"
|
||||
"AutoUpdateBehavior" "0"
|
||||
"AllowOtherDownloadsWhileRunning" "0"
|
||||
"ScheduledAutoUpdate" "0"
|
||||
"FullValidateAfterNextUpdate" "1"
|
||||
"InstalledDepots"
|
||||
{
|
||||
"3330"
|
||||
{
|
||||
"manifest" "0"
|
||||
"size" "0"
|
||||
}
|
||||
}
|
||||
"SharedDepots"
|
||||
{
|
||||
"228983" "228980"
|
||||
"228985" "228980"
|
||||
"228988" "228980"
|
||||
"228990" "228980"
|
||||
"229004" "228980"
|
||||
}
|
||||
"UserConfig"
|
||||
{
|
||||
"language" "english"
|
||||
"platform_override_dest" "linux"
|
||||
"platform_override_source" "windows"
|
||||
}
|
||||
"MountedConfig"
|
||||
{
|
||||
"language" "english"
|
||||
"platform_override_dest" "linux"
|
||||
"platform_override_source" "windows"
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
"AppState"
|
||||
{
|
||||
"appid" "555"
|
||||
"Universe" "1"
|
||||
"name" "TEST APP"
|
||||
"StateFlags" "4"
|
||||
"installdir" "TESTAPP"
|
||||
"LastUpdated" "0"
|
||||
"LastPlayed" "0"
|
||||
"SizeOnDisk" "0"
|
||||
"StagingSize" "0"
|
||||
"buildid" "0"
|
||||
"LastOwner" "0"
|
||||
"DownloadType" "2"
|
||||
"UpdateResult" "0"
|
||||
"BytesToDownload" "0"
|
||||
"BytesDownloaded" "0"
|
||||
"BytesToStage" "0"
|
||||
"BytesStaged" "0"
|
||||
"TargetBuildID" "0"
|
||||
"AutoUpdateBehavior" "0"
|
||||
"AllowOtherDownloadsWhileRunning" "0"
|
||||
"ScheduledAutoUpdate" "0"
|
||||
"FullValidateAfterNextUpdate" "1"
|
||||
"InstalledDepots"
|
||||
{
|
||||
"3330"
|
||||
{
|
||||
"manifest" "0"
|
||||
"size" "0"
|
||||
}
|
||||
}
|
||||
"SharedDepots"
|
||||
{
|
||||
"228983" "228980"
|
||||
"228985" "228980"
|
||||
"228988" "228980"
|
||||
"228990" "228980"
|
||||
"229004" "228980"
|
||||
}
|
||||
"UserConfig"
|
||||
{
|
||||
"language" "english"
|
||||
"platform_override_dest" "linux"
|
||||
"platform_override_source" "windows"
|
||||
}
|
||||
"MountedConfig"
|
||||
{
|
||||
"language" "english"
|
||||
"platform_override_dest" "linux"
|
||||
"platform_override_source" "windows"
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ import pytest
|
||||
from _pytest.monkeypatch import MonkeyPatch
|
||||
from pathlib import Path
|
||||
|
||||
from dzgui.api.steam import get_app_allows_downloads, get_last_updated
|
||||
from dzgui.api.steam import get_app_allows_downloads
|
||||
from tests.fixtures import fixture_path
|
||||
|
||||
pytestmark = pytest.mark.apitest
|
||||
@@ -43,14 +43,6 @@ def patch_api() -> None:
|
||||
mp.undo()
|
||||
|
||||
|
||||
def test_no_last_update(steam_path) -> None:
|
||||
assert get_last_updated(steam_path, 555) is None
|
||||
|
||||
|
||||
def test_last_update(steam_path) -> None:
|
||||
assert get_last_updated(steam_path, 444) == "2026-10-22 00:09:33"
|
||||
|
||||
|
||||
def test_app_allows_downloads(steam_path) -> None:
|
||||
assert get_app_allows_downloads(steam_path, 111) is True
|
||||
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
import pytest
|
||||
|
||||
from dzgui.model.model_factory import FastInsertListStore
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def heterogeneous_list() -> None:
|
||||
return [["a", 0, True], ["b", 1, False]]
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mismatched_length_list() -> None:
|
||||
return [["a", 0, True], ["b", 1, False, 0]]
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def extended_list(heterogeneous_list) -> None:
|
||||
fs = FastInsertListStore(str, int, bool)
|
||||
fs.extend(heterogeneous_list)
|
||||
return fs
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def appended_list(heterogeneous_list) -> None:
|
||||
fs = FastInsertListStore(str, int, bool)
|
||||
for row in heterogeneous_list:
|
||||
fs.append(row)
|
||||
return fs
|
||||
|
||||
|
||||
@pytest.mark.parametrize("target", ["extended_list", "appended_list"])
|
||||
def test_list_parity(heterogeneous_list, request, target) -> None:
|
||||
target = request.getfixturevalue(target)
|
||||
extracted = [[el for el in row] for row in target]
|
||||
assert heterogeneous_list == extracted
|
||||
|
||||
|
||||
def test_type_disparity(heterogeneous_list) -> None:
|
||||
with pytest.raises(TypeError):
|
||||
fs = FastInsertListStore(str, bool, bool)
|
||||
fs.extend(heterogeneous_list)
|
||||
|
||||
|
||||
def test_length_disparity(mismatched_length_list) -> None:
|
||||
with pytest.raises(ValueError):
|
||||
fs = FastInsertListStore(str, int, bool)
|
||||
fs.extend(mismatched_length_list)
|
||||
Reference in new issue
Block a user