Compare commits

..
Author SHA1 Message Date
aclist 3677b01fdc fix: exception handling 2026-11-09 22:25:13 +09:00
aclist 4f6223f90b fix: strip invalid values from versions file 2026-11-09 22:24:26 +09:00
aclist 441066a1a0 chore: update comments 2026-11-09 22:23:37 +09:00
aclist fa1ac8fa31 chore: update imports 2026-11-09 22:23:27 +09:00
13 changed files with 77 additions and 35 deletions

No files matched your search

-2
View File
@@ -37,8 +37,6 @@ Users wishing to review the licenses to these components can inspect the `LICENS
Steam and the Steam logo are trademarks and/or registered trademarks of Valve Corporation in the U.S. and/or other countries.
DayZ is a trademark and brand of Bohemia Interactive a.s.
## Disclaimer
DZGUI is beta-quality software and is provided as-is.
+5 -4
View File
@@ -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:
+1 -1
View File
@@ -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
+2 -1
View File
@@ -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
+22 -1
View File
@@ -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)
+2 -2
View File
@@ -1,4 +1,4 @@
from shared import get_git_root
from pathlib import Path
BOILERPLATE = """
This file includes the combined licenses to the following components:
@@ -40,7 +40,7 @@ class CombinedLicense:
def concat_license() -> str:
combined = CombinedLicense()
root = get_git_root()
root = Path(__file__).resolve().parents[1]
licenses = root.joinpath("docs/licenses")
main_license = root.joinpath(LICENSE_FILE)
+4 -5
View File
@@ -1,11 +1,10 @@
import shutil
import subprocess
from pathlib import Path
from shared import get_git_root
root = get_git_root()
clog = root.joinpath("CHANGELOG.md")
target = root.joinpath("dzgui/data/CHANGELOG.md")
par = Path(__file__).parent.parent
clog = par / "CHANGELOG.md"
target = par / "dzgui/data/CHANGELOG.md"
shutil.copy(clog, target)
+3 -2
View File
@@ -1,9 +1,10 @@
import tomllib
from shared import get_git_root
from pathlib import Path
root = Path(__file__).resolve().parents[1]
def get_entrypoint() -> None:
root = get_git_root()
p = root.joinpath("pyproject.toml")
with open(p, "rb") as f:
t = tomllib.load(f)
+2 -3
View File
@@ -3,15 +3,14 @@ import requests
import subprocess
import tarfile
from pathlib import Path
from urllib.parse import unquote
from shared import get_git_root
BUILD = "3.13.9"
DATE = "20251014"
CPYTHON_BUILD = f"cpython-{BUILD}"
root = get_git_root()
root = Path(__file__).resolve().parents[1]
build_dir = root.joinpath("build")
cpython_dir = build_dir.joinpath(CPYTHON_BUILD)
+1 -2
View File
@@ -9,7 +9,6 @@ from pathlib import Path
from concat_licenses import concat_license
from parse_toml import get_entrypoint
from prebuild import get_pyapp, rebuild_cpython
from shared import get_git_root
def update_uname(info: tarfile.TarInfo) -> tarfile.TarInfo:
@@ -18,7 +17,7 @@ def update_uname(info: tarfile.TarInfo) -> tarfile.TarInfo:
return info
root = get_git_root()
root = Path(__file__).resolve().parents[1]
dist_dir = root.joinpath("dist")
build_dir = root.joinpath("build")
+10 -1
View File
@@ -1,7 +1,16 @@
import subprocess
from pathlib import Path
from dzgui.app_init import build_gui
from shared import get_git_root
def get_git_root() -> Path:
proc = subprocess.run(
["git", "rev-parse", "--show-toplevel"], capture_output=True, text=True
)
if proc.returncode != 0:
raise OSError("Failed to parse git root")
return Path(proc.stdout.rstrip())
def get_image_path() -> Path:
-11
View File
@@ -1,11 +0,0 @@
import subprocess
from pathlib import Path
def get_git_root() -> Path:
proc = subprocess.run(
["git", "rev-parse", "--show-toplevel"], capture_output=True, text=True
)
if proc.returncode != 0:
raise OSError("Failed to parse git root")
return Path(proc.stdout.rstrip())
+25
View File
@@ -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()