mirror of
https://github.com/aclist/dztui.git
synced 2026-11-10 20:10:38 +01:00
Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3677b01fdc | ||
|
|
4f6223f90b | ||
|
|
441066a1a0 | ||
|
|
fa1ac8fa31 |
No files matched your search
+5
-4
@@ -2,10 +2,10 @@ import hashlib
|
||||
import logging
|
||||
import re
|
||||
|
||||
from concurrent.futures import wait
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
from concurrent.futures import ThreadPoolExecutor, wait
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
from dzgui.api.steam import get_app_path
|
||||
from dzgui.api.servers import get_rules, fqip_to_record
|
||||
@@ -18,8 +18,7 @@ from dzgui.const.constants import (
|
||||
|
||||
from dzgui.config.query import lookup
|
||||
from dzgui.const.enum import Preferences
|
||||
|
||||
from typing import Any
|
||||
from dzgui.init.migrate import clean_legacy_versions_file
|
||||
|
||||
logger = logging.getLogger(APP_NAME)
|
||||
|
||||
@@ -133,6 +132,8 @@ def remove_stale_signatures(
|
||||
versions.touch()
|
||||
return
|
||||
|
||||
clean_legacy_versions_file(versions)
|
||||
|
||||
path = lookup(config, Preferences.DEFAULT)
|
||||
steam_path = Path(path)
|
||||
if ids is None:
|
||||
|
||||
+6
-6
@@ -31,10 +31,10 @@ from dzgui.const.constants import (
|
||||
VDF_PATH,
|
||||
)
|
||||
from dzgui.const.endpoints import (
|
||||
STEAM_APP_DETAILS,
|
||||
APP_DETAILS,
|
||||
SUB_ENDPOINT,
|
||||
STEAM_PUBLISHED_FILES,
|
||||
STEAM_SUB,
|
||||
STEAM_UNSUB,
|
||||
UNSUB_ENDPOINT,
|
||||
)
|
||||
from dzgui.strings import wizard
|
||||
from dzgui.strings.errors import api_validation_error, workshop_endpoint_error
|
||||
@@ -310,11 +310,11 @@ def update_workshop(key: str, mod: int, endpoint: str) -> None:
|
||||
|
||||
|
||||
def subscribe(key: str, mod: int) -> None:
|
||||
update_workshop(key, mod, STEAM_SUB)
|
||||
update_workshop(key, mod, SUB_ENDPOINT)
|
||||
|
||||
|
||||
def unsubscribe(key: str, mod: int) -> None:
|
||||
update_workshop(key, mod, STEAM_UNSUB)
|
||||
update_workshop(key, mod, UNSUB_ENDPOINT)
|
||||
|
||||
|
||||
def validate_mod(client: str, mod: str) -> None:
|
||||
@@ -512,7 +512,7 @@ def get_app_path(folders_path: Path, appid: int) -> Path:
|
||||
|
||||
def get_app_name(appid: int) -> str | None:
|
||||
payload = {"appids": [appid]}
|
||||
res = requests.get(STEAM_APP_DETAILS, params=payload)
|
||||
res = requests.get(APP_DETAILS, params=payload)
|
||||
if res.status_code != 200:
|
||||
return None
|
||||
try:
|
||||
|
||||
+1
-1
@@ -18,8 +18,8 @@ from dzgui.config.query import lookup
|
||||
from dzgui.config.userprefs import UserPrefs
|
||||
from dzgui.config.xdg import get_xdg_paths, parse_filepaths
|
||||
from dzgui.init.migrate import (
|
||||
has_new_config,
|
||||
copy_state_files,
|
||||
has_new_config,
|
||||
migrate_cols_file,
|
||||
)
|
||||
from dzgui.init.flock import lock_acquire
|
||||
|
||||
@@ -6,7 +6,8 @@ if TYPE_CHECKING:
|
||||
from dzgui.util.ip import Coords
|
||||
|
||||
|
||||
# NOTE: mutable dataclass, 'use_miles' key changes on demand
|
||||
# NOTE: mutable dataclass: 'use_miles' key changes on demand
|
||||
# 'frozen' cannot be True
|
||||
@dataclass(slots=True)
|
||||
class UserPrefs:
|
||||
is_steam_deck: bool
|
||||
|
||||
@@ -3,9 +3,9 @@ STEAM_PUBLISHED_FILES = (
|
||||
"https://api.steampowered.com/ISteamRemoteStorage/GetPublishedFileDetails/v1"
|
||||
)
|
||||
STEAM_SERVERS = "https://api.steampowered.com/IGameServersService/GetServerList/v1"
|
||||
STEAM_SUB = "https://api.steampowered.com/IPublishedFileService/Subscribe/v1"
|
||||
STEAM_UNSUB = "https://api.steampowered.com/IPublishedFileService/Unsubscribe/v1"
|
||||
STEAM_APP_DETAILS = "https://store.steampowered.com/api/appdetails?"
|
||||
SUB_ENDPOINT = "https://api.steampowered.com/IPublishedFileService/Subscribe/v1"
|
||||
UNSUB_ENDPOINT = "https://api.steampowered.com/IPublishedFileService/Unsubscribe/v1"
|
||||
APP_DETAILS = "https://store.steampowered.com/api/appdetails?"
|
||||
|
||||
GITHUB = "https://github.com/aclist"
|
||||
GITHUB_RELEASES = "https://api.github.com/repos/aclist/dztui/releases/latest"
|
||||
|
||||
+22
-1
@@ -1,12 +1,21 @@
|
||||
import json
|
||||
import logging
|
||||
import re
|
||||
import shutil
|
||||
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
from dzgui.const.constants import LEGACY_CONFIG_PATH, LEGACY_COLS_PATH, LEGACY_IPS_PATH
|
||||
from dzgui.const.constants import (
|
||||
APP_NAME,
|
||||
LEGACY_CONFIG_PATH,
|
||||
LEGACY_COLS_PATH,
|
||||
LEGACY_IPS_PATH,
|
||||
)
|
||||
from dzgui.config.convert import rc2json
|
||||
from dzgui.util._json import read_json, write_json
|
||||
|
||||
logger = logging.getLogger(APP_NAME)
|
||||
|
||||
|
||||
def migrate_legacy_conf(config: Path) -> Any:
|
||||
old_conf = Path.home() / LEGACY_CONFIG_PATH
|
||||
@@ -70,3 +79,15 @@ def copy_ipdb(ips_path: Path) -> None:
|
||||
return
|
||||
# TODO: ensure that month file is copied
|
||||
shutil.copy(legacy, ips_path)
|
||||
|
||||
|
||||
def clean_legacy_versions_file(versions: Path) -> None:
|
||||
# NOTE: handling for #523
|
||||
try:
|
||||
pat = r"^(\d+),(\d+)$"
|
||||
lines = versions.read_text().splitlines()
|
||||
clean = [line for line in lines if re.match(pat, line)]
|
||||
concat = "\n".join(clean)
|
||||
versions.write_text(concat)
|
||||
except Exception as e:
|
||||
logger.warning(e)
|
||||
@@ -0,0 +1,25 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from dzgui.init.migrate import clean_legacy_versions_file
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def test_null_signature_stripping(tmp_path: "Path") -> None:
|
||||
tmp = tmp_path.joinpath("dzg.versions")
|
||||
lines = [
|
||||
"1111,2222",
|
||||
"3333,4444",
|
||||
"5555,null",
|
||||
"foo",
|
||||
",4555",
|
||||
"1111",
|
||||
" ",
|
||||
",,,",
|
||||
"-1",
|
||||
]
|
||||
expect = ["1111,2222", "3333,4444"]
|
||||
tmp.write_text("\n".join(lines))
|
||||
clean_legacy_versions_file(tmp)
|
||||
assert expect == tmp.read_text().splitlines()
|
||||
Reference in new issue
Block a user