mirror of
https://github.com/aclist/dztui.git
synced 2026-11-10 12:00: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 logging
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from concurrent.futures import wait
|
from concurrent.futures import ThreadPoolExecutor, wait
|
||||||
from concurrent.futures import ThreadPoolExecutor
|
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
from dzgui.api.steam import get_app_path
|
from dzgui.api.steam import get_app_path
|
||||||
from dzgui.api.servers import get_rules, fqip_to_record
|
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.config.query import lookup
|
||||||
from dzgui.const.enum import Preferences
|
from dzgui.const.enum import Preferences
|
||||||
|
from dzgui.init.migrate import clean_legacy_versions_file
|
||||||
from typing import Any
|
|
||||||
|
|
||||||
logger = logging.getLogger(APP_NAME)
|
logger = logging.getLogger(APP_NAME)
|
||||||
|
|
||||||
@@ -133,6 +132,8 @@ def remove_stale_signatures(
|
|||||||
versions.touch()
|
versions.touch()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
clean_legacy_versions_file(versions)
|
||||||
|
|
||||||
path = lookup(config, Preferences.DEFAULT)
|
path = lookup(config, Preferences.DEFAULT)
|
||||||
steam_path = Path(path)
|
steam_path = Path(path)
|
||||||
if ids is None:
|
if ids is None:
|
||||||
|
|||||||
+1
-1
@@ -18,8 +18,8 @@ from dzgui.config.query import lookup
|
|||||||
from dzgui.config.userprefs import UserPrefs
|
from dzgui.config.userprefs import UserPrefs
|
||||||
from dzgui.config.xdg import get_xdg_paths, parse_filepaths
|
from dzgui.config.xdg import get_xdg_paths, parse_filepaths
|
||||||
from dzgui.init.migrate import (
|
from dzgui.init.migrate import (
|
||||||
has_new_config,
|
|
||||||
copy_state_files,
|
copy_state_files,
|
||||||
|
has_new_config,
|
||||||
migrate_cols_file,
|
migrate_cols_file,
|
||||||
)
|
)
|
||||||
from dzgui.init.flock import lock_acquire
|
from dzgui.init.flock import lock_acquire
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ if TYPE_CHECKING:
|
|||||||
from dzgui.util.ip import Coords
|
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)
|
@dataclass(slots=True)
|
||||||
class UserPrefs:
|
class UserPrefs:
|
||||||
is_steam_deck: bool
|
is_steam_deck: bool
|
||||||
|
|||||||
+22
-1
@@ -1,12 +1,21 @@
|
|||||||
import json
|
import json
|
||||||
|
import logging
|
||||||
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any
|
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.config.convert import rc2json
|
||||||
from dzgui.util._json import read_json, write_json
|
from dzgui.util._json import read_json, write_json
|
||||||
|
|
||||||
|
logger = logging.getLogger(APP_NAME)
|
||||||
|
|
||||||
|
|
||||||
def migrate_legacy_conf(config: Path) -> Any:
|
def migrate_legacy_conf(config: Path) -> Any:
|
||||||
old_conf = Path.home() / LEGACY_CONFIG_PATH
|
old_conf = Path.home() / LEGACY_CONFIG_PATH
|
||||||
@@ -70,3 +79,15 @@ def copy_ipdb(ips_path: Path) -> None:
|
|||||||
return
|
return
|
||||||
# TODO: ensure that month file is copied
|
# TODO: ensure that month file is copied
|
||||||
shutil.copy(legacy, ips_path)
|
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