mirror of
https://github.com/aclist/dztui.git
synced 2026-11-08 02:50:46 +01:00
Compare commits
20
Commits
e692e1d139
...
7.0.0b15
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6c56f16633 | ||
|
|
2b87272b52 | ||
|
|
4de5147899 | ||
|
|
4c31cd7ecd | ||
|
|
61f90d6016 | ||
|
|
cd1fd1b179 | ||
|
|
1b25c8fadb | ||
|
|
18146bf66f | ||
|
|
8ae54d436a | ||
|
|
4d94551f87 | ||
|
|
1154789f8b | ||
|
|
cbccd4c5f6 | ||
|
|
8cac752a0d | ||
|
|
580273053c | ||
|
|
8d75c1f7b2 | ||
|
|
320c2f692e | ||
|
|
413d84b2b5 | ||
|
|
c751b277d0 | ||
|
|
7f36a3acad | ||
|
|
5780d3daff |
No files matched your search
@@ -26,7 +26,7 @@ You can install it via the following set of commands:
|
|||||||
.. code:: console
|
.. code:: console
|
||||||
|
|
||||||
sudo apt update
|
sudo apt update
|
||||||
sudo apt install libgirepository-2.0
|
sudo apt install libgirepository-2.0-0
|
||||||
|
|
||||||
Next steps
|
Next steps
|
||||||
---------------
|
---------------
|
||||||
|
|||||||
@@ -289,13 +289,14 @@ def query_direct(ip: str, qport: int, timeout: float = 3.0) -> dict[str, Any] |
|
|||||||
|
|
||||||
|
|
||||||
def get_details(record: Record) -> Details:
|
def get_details(record: Record) -> Details:
|
||||||
|
# TODO: consolidate try/except statements
|
||||||
ip = record.ip
|
ip = record.ip
|
||||||
qport = record.qport
|
qport = record.qport
|
||||||
default_str = strings.none_provided
|
default_str = strings.none_provided
|
||||||
|
|
||||||
try:
|
try:
|
||||||
info = a2s.info((ip, qport))
|
info = a2s.info((ip, qport))
|
||||||
except TimeoutError:
|
except (TimeoutError, a2s.exceptions.BrokenMessageError):
|
||||||
return Details(None, default_str, False)
|
return Details(None, default_str, False)
|
||||||
try:
|
try:
|
||||||
rules = dayzquery.dayz_rules((ip, qport))
|
rules = dayzquery.dayz_rules((ip, qport))
|
||||||
|
|||||||
@@ -0,0 +1,152 @@
|
|||||||
|
import logging
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
|
|
||||||
|
from dzgui.const.constants import APP_NAME, APP_NAME_LOWER
|
||||||
|
from dzgui.const.enum import Preferences
|
||||||
|
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,
|
||||||
|
migrate_cols_file,
|
||||||
|
)
|
||||||
|
from dzgui.init.flock import lock_acquire
|
||||||
|
from dzgui.init.prereqs import has_steam_client
|
||||||
|
from dzgui.strings import boot
|
||||||
|
|
||||||
|
# from dzgui.util.map_count import get_map_count
|
||||||
|
from dzgui.util.deck import is_steam_deck, is_game_mode
|
||||||
|
from dzgui.util.localize import set_locale
|
||||||
|
from dzgui.util.strings import init
|
||||||
|
|
||||||
|
from dzgui.views.base import App
|
||||||
|
from dzgui.views.dialogs.boot import BootWindow
|
||||||
|
from dzgui.views.dialogs.early_alert import EarlyAlertDialog
|
||||||
|
from dzgui.views.dialogs.wizard import SetupWizard
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
logger = logging.getLogger(APP_NAME)
|
||||||
|
|
||||||
|
|
||||||
|
# TODO: profile load time
|
||||||
|
def make_parents(path: "Path") -> None:
|
||||||
|
path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
|
|
||||||
|
def setup_logger(log_path: "Path") -> None:
|
||||||
|
_format = (
|
||||||
|
"%(asctime)s␞%(levelname)s␞%(filename)s::%(funcName)s::%(lineno)s␞%(message)s"
|
||||||
|
)
|
||||||
|
fh = logging.FileHandler(log_path)
|
||||||
|
formatter = logging.Formatter(_format)
|
||||||
|
fh.setFormatter(formatter)
|
||||||
|
fh.setLevel(logging.DEBUG)
|
||||||
|
logger.setLevel(logging.DEBUG)
|
||||||
|
logger.addHandler(fh)
|
||||||
|
|
||||||
|
|
||||||
|
def copy_bare_configs(config: "Path", resolution: "Path") -> tuple[bool, bool]:
|
||||||
|
# NOTE: temporary workaround for #375
|
||||||
|
conf = "config.json"
|
||||||
|
state = [
|
||||||
|
"dzg.history",
|
||||||
|
"dzg.versions",
|
||||||
|
"dzg.res.json",
|
||||||
|
"dzg.filters.json",
|
||||||
|
"dzg.columns.json",
|
||||||
|
"dzg.notes.json",
|
||||||
|
"ips.csv",
|
||||||
|
".month",
|
||||||
|
]
|
||||||
|
config_changed = False
|
||||||
|
state_changed = False
|
||||||
|
if config.parent.exists() is False:
|
||||||
|
new_file = config
|
||||||
|
old_file = config.parent.parent / conf
|
||||||
|
if old_file.is_file():
|
||||||
|
try:
|
||||||
|
make_parents(new_file)
|
||||||
|
shutil.copy(old_file, new_file)
|
||||||
|
config_changed = True
|
||||||
|
except Exception as e:
|
||||||
|
logger.critical(e)
|
||||||
|
if resolution.parent.exists() is False:
|
||||||
|
state_path = resolution.parent
|
||||||
|
for state_file in state:
|
||||||
|
old_file = state_path.parent / state_file
|
||||||
|
if old_file.is_file():
|
||||||
|
try:
|
||||||
|
new_file = state_path / state_file
|
||||||
|
make_parents(new_file)
|
||||||
|
shutil.copy(old_file, new_file)
|
||||||
|
state_changed = True
|
||||||
|
except Exception as e:
|
||||||
|
logger.critical(e)
|
||||||
|
return (config_changed, state_changed)
|
||||||
|
|
||||||
|
|
||||||
|
def load_gui(version: str, is_debug: bool) -> None:
|
||||||
|
lock = lock_acquire() # noqa
|
||||||
|
|
||||||
|
set_locale()
|
||||||
|
# NOTE: consider aborting this check if steam deck
|
||||||
|
xdg_paths = get_xdg_paths()
|
||||||
|
XDG = parse_filepaths(xdg_paths)
|
||||||
|
|
||||||
|
copy_bare_configs(XDG.config, XDG.resolution)
|
||||||
|
|
||||||
|
if XDG.resolution.parent.is_dir() is False:
|
||||||
|
make_parents(XDG.resolution)
|
||||||
|
|
||||||
|
if XDG.debug.is_file() is False:
|
||||||
|
make_parents(XDG.debug)
|
||||||
|
|
||||||
|
_is_steam_deck = is_steam_deck()
|
||||||
|
_is_game_mode = is_game_mode() if _is_steam_deck else False
|
||||||
|
if _is_game_mode:
|
||||||
|
# NOTE: this may no longer be necessary on newer versions of SteamOS
|
||||||
|
del os.environ["GTK_IM_MODULE"]
|
||||||
|
|
||||||
|
if has_new_config(XDG.config) is False:
|
||||||
|
migrate_cols_file(XDG.columns)
|
||||||
|
copy_state_files(xdg_paths["XDG_STATE_HOME"])
|
||||||
|
# TODO: add logging inside wizard
|
||||||
|
SetupWizard(_is_steam_deck, XDG.config)
|
||||||
|
|
||||||
|
# NOTE: implies that setup wizard failed or was closed
|
||||||
|
if has_new_config(XDG.config) is False:
|
||||||
|
return
|
||||||
|
|
||||||
|
setup_logger(XDG.debug)
|
||||||
|
with open(XDG.debug, "w") as f:
|
||||||
|
f.truncate(0)
|
||||||
|
|
||||||
|
if _is_steam_deck is False:
|
||||||
|
# TODO: sudo escalation dialog
|
||||||
|
# count = get_map_count()
|
||||||
|
# TODO: move into module
|
||||||
|
if has_steam_client() is False:
|
||||||
|
EarlyAlertDialog(init.requires_steam)
|
||||||
|
|
||||||
|
bootwin = BootWindow(XDG, version)
|
||||||
|
local_coords, latest_release = bootwin.get_results()
|
||||||
|
|
||||||
|
use_miles = lookup(XDG.config, Preferences.DIST)
|
||||||
|
prefs = UserPrefs(
|
||||||
|
is_steam_deck=_is_steam_deck,
|
||||||
|
is_game_mode=_is_game_mode,
|
||||||
|
is_debug=is_debug,
|
||||||
|
coords=local_coords,
|
||||||
|
version=version,
|
||||||
|
paths=XDG,
|
||||||
|
latest_release=latest_release,
|
||||||
|
use_miles=use_miles,
|
||||||
|
)
|
||||||
|
print(boot.all_ok)
|
||||||
|
App(prefs)
|
||||||
+6
-5
@@ -29,9 +29,9 @@ def is_writeable(path_str: str) -> bool:
|
|||||||
if not path.exists():
|
if not path.exists():
|
||||||
try:
|
try:
|
||||||
path.mkdir(parents=True)
|
path.mkdir(parents=True)
|
||||||
|
path.unlink()
|
||||||
except OSError:
|
except OSError:
|
||||||
return False
|
return False
|
||||||
path.unlink()
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -55,11 +55,12 @@ def get_xdg_paths() -> dict:
|
|||||||
|
|
||||||
resolved_paths = {}
|
resolved_paths = {}
|
||||||
for path in xdg_paths:
|
for path in xdg_paths:
|
||||||
rp = os.environ.get(path)
|
real_path = os.environ.get(path)
|
||||||
if rp is not None and is_writeable(rp):
|
if real_path is not None and is_writeable(real_path):
|
||||||
resolved_paths[path] = Path(rp)
|
new_path = Path(real_path)
|
||||||
else:
|
else:
|
||||||
resolved_paths[path] = xdg_paths[path] / APP_NAME_LOWER
|
new_path = xdg_paths[path]
|
||||||
|
resolved_paths[path] = new_path / APP_NAME_LOWER
|
||||||
return resolved_paths
|
return resolved_paths
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+4
-5
@@ -1,11 +1,12 @@
|
|||||||
import platform
|
import platform
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from pathlib import Path
|
from ctypes.util import find_library
|
||||||
from warnings import deprecated
|
from warnings import deprecated
|
||||||
|
|
||||||
LIB = "libgirepository-2.0"
|
LIB = "libgirepository-2.0"
|
||||||
|
|
||||||
|
|
||||||
@deprecated("currently unused")
|
@deprecated("currently unused")
|
||||||
def is_debian() -> bool:
|
def is_debian() -> bool:
|
||||||
"""
|
"""
|
||||||
@@ -39,12 +40,10 @@ def is_debian() -> bool:
|
|||||||
|
|
||||||
|
|
||||||
def has_libgi() -> bool:
|
def has_libgi() -> bool:
|
||||||
parent_dir = Path("/usr/lib64")
|
return bool(find_library("girepository-2.0"))
|
||||||
exists = any(LIB in subdir.name for subdir in parent_dir.iterdir())
|
|
||||||
return exists
|
|
||||||
|
|
||||||
|
|
||||||
def test_missing_lib() -> bool:
|
def test_libgi_missing() -> None:
|
||||||
msg = f"System is missing the required library '{LIB}'. Install it via your system package manager."
|
msg = f"System is missing the required library '{LIB}'. Install it via your system package manager."
|
||||||
if has_libgi() is False:
|
if has_libgi() is False:
|
||||||
print(msg)
|
print(msg)
|
||||||
|
|||||||
+6
-103
@@ -1,40 +1,11 @@
|
|||||||
import argparse
|
import argparse
|
||||||
import logging
|
|
||||||
import os
|
|
||||||
import sys
|
import sys
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
from typing import TYPE_CHECKING
|
|
||||||
|
|
||||||
from dzgui.const.constants import APP_NAME
|
from dzgui.const.constants import APP_NAME
|
||||||
from dzgui.const.enum import Preferences
|
from dzgui.init.libgi import test_libgi_missing
|
||||||
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.flock import lock_acquire
|
|
||||||
from dzgui.init.migrate import (
|
|
||||||
has_new_config,
|
|
||||||
copy_state_files,
|
|
||||||
migrate_cols_file,
|
|
||||||
)
|
|
||||||
from dzgui.init.prefix import get_version
|
from dzgui.init.prefix import get_version
|
||||||
from dzgui.init.prereqs import has_steam_client
|
from dzgui.util.strings import flags
|
||||||
from dzgui.strings import boot
|
|
||||||
|
|
||||||
# from dzgui.util.map_count import get_map_count
|
|
||||||
from dzgui.util.deck import is_steam_deck, is_game_mode
|
|
||||||
from dzgui.util.localize import set_locale
|
|
||||||
from dzgui.util.strings import init, flags
|
|
||||||
|
|
||||||
from dzgui.views.base import App
|
|
||||||
from dzgui.views.dialogs.boot import BootWindow
|
|
||||||
from dzgui.views.dialogs.early_alert import EarlyAlertDialog
|
|
||||||
from dzgui.views.dialogs.wizard import SetupWizard
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
logger = logging.getLogger(APP_NAME)
|
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description=flags.description)
|
parser = argparse.ArgumentParser(description=flags.description)
|
||||||
parser.add_argument("-v", "--version", action="store_true", help=flags.version)
|
parser.add_argument("-v", "--version", action="store_true", help=flags.version)
|
||||||
@@ -43,11 +14,6 @@ parser.add_argument("-d", "--debug", action="store_true", help=flags.debug)
|
|||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
# TODO: profile load time
|
|
||||||
def make_parents(path: "Path") -> None:
|
|
||||||
path.parent.mkdir(parents=True, exist_ok=True)
|
|
||||||
|
|
||||||
|
|
||||||
def uninstall() -> None:
|
def uninstall() -> None:
|
||||||
# TODO: uninstall data files (-u)
|
# TODO: uninstall data files (-u)
|
||||||
# -u removes state, log, freedesktop
|
# -u removes state, log, freedesktop
|
||||||
@@ -57,21 +23,7 @@ def uninstall() -> None:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def setup_logger(log_path: "Path") -> None:
|
|
||||||
_format = (
|
|
||||||
"%(asctime)s␞%(levelname)s␞%(filename)s::%(funcName)s::%(lineno)s␞%(message)s"
|
|
||||||
)
|
|
||||||
fh = logging.FileHandler(log_path)
|
|
||||||
formatter = logging.Formatter(_format)
|
|
||||||
fh.setFormatter(formatter)
|
|
||||||
fh.setLevel(logging.DEBUG)
|
|
||||||
logger.setLevel(logging.DEBUG)
|
|
||||||
logger.addHandler(fh)
|
|
||||||
|
|
||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
lock = lock_acquire() # noqa
|
|
||||||
|
|
||||||
if args.version is True:
|
if args.version is True:
|
||||||
print(get_version())
|
print(get_version())
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
@@ -82,60 +34,11 @@ def main() -> None:
|
|||||||
warnings.filterwarnings("default", category=DeprecationWarning)
|
warnings.filterwarnings("default", category=DeprecationWarning)
|
||||||
|
|
||||||
version = get_version()
|
version = get_version()
|
||||||
set_locale()
|
|
||||||
|
|
||||||
print(f"{APP_NAME} {version}")
|
print(f"{APP_NAME} {version}")
|
||||||
|
test_libgi_missing()
|
||||||
|
|
||||||
# NOTE: consider aborting this check if steam deck
|
# NOTE: only import ligbirepository modules after the above check
|
||||||
xdg_paths = get_xdg_paths()
|
from dzgui.app_init import load_gui
|
||||||
XDG = parse_filepaths(xdg_paths)
|
|
||||||
|
|
||||||
if XDG.resolution.parent.is_dir() is False:
|
load_gui(version, args.debug)
|
||||||
make_parents(XDG.resolution)
|
|
||||||
|
|
||||||
if XDG.debug.is_file() is False:
|
|
||||||
make_parents(XDG.debug)
|
|
||||||
|
|
||||||
_is_steam_deck = is_steam_deck()
|
|
||||||
_is_game_mode = is_game_mode() if _is_steam_deck else False
|
|
||||||
if _is_game_mode:
|
|
||||||
# NOTE: this may no longer be necessary on newer versions of SteamOS
|
|
||||||
del os.environ["GTK_IM_MODULE"]
|
|
||||||
|
|
||||||
if has_new_config(XDG.config) is False:
|
|
||||||
migrate_cols_file(XDG.columns)
|
|
||||||
copy_state_files(xdg_paths["XDG_STATE_HOME"])
|
|
||||||
# TODO: add logging inside wizard
|
|
||||||
SetupWizard(_is_steam_deck, XDG.config)
|
|
||||||
|
|
||||||
# NOTE: implies that setup wizard failed or was closed
|
|
||||||
if has_new_config(XDG.config) is False:
|
|
||||||
return
|
|
||||||
|
|
||||||
setup_logger(XDG.debug)
|
|
||||||
with open(XDG.debug, "w") as f:
|
|
||||||
f.truncate(0)
|
|
||||||
|
|
||||||
if _is_steam_deck is False:
|
|
||||||
# TODO: sudo escalation dialog
|
|
||||||
# count = get_map_count()
|
|
||||||
# TODO: move into module
|
|
||||||
if has_steam_client() is False:
|
|
||||||
EarlyAlertDialog(init.requires_steam)
|
|
||||||
|
|
||||||
bootwin = BootWindow(XDG, version)
|
|
||||||
local_coords, latest_release = bootwin.get_results()
|
|
||||||
|
|
||||||
use_miles = lookup(XDG.config, Preferences.DIST)
|
|
||||||
prefs = UserPrefs(
|
|
||||||
is_steam_deck=_is_steam_deck,
|
|
||||||
is_game_mode=_is_game_mode,
|
|
||||||
is_debug=args.debug,
|
|
||||||
coords=local_coords,
|
|
||||||
version=version,
|
|
||||||
paths=XDG,
|
|
||||||
latest_release=latest_release,
|
|
||||||
use_miles=use_miles,
|
|
||||||
)
|
|
||||||
print(boot.all_ok)
|
|
||||||
App(prefs)
|
|
||||||
@@ -130,7 +130,6 @@ servers = {
|
|||||||
"Enter/space/double-click": "connect to server",
|
"Enter/space/double-click": "connect to server",
|
||||||
"Right-click/Ctrl-l": "additional context menus",
|
"Right-click/Ctrl-l": "additional context menus",
|
||||||
"Ctrl-r": "refresh players",
|
"Ctrl-r": "refresh players",
|
||||||
"Ctrl-p": "refresh ping",
|
|
||||||
"Ctrl-f": "jump to keyword search field",
|
"Ctrl-f": "jump to keyword search field",
|
||||||
"Ctrl-m": "jump to maps field",
|
"Ctrl-m": "jump to maps field",
|
||||||
"Ctrl-d": "select default LAN port",
|
"Ctrl-d": "select default LAN port",
|
||||||
@@ -148,8 +147,8 @@ servers = {
|
|||||||
vim = {
|
vim = {
|
||||||
"j": "Move down a row/scroll up",
|
"j": "Move down a row/scroll up",
|
||||||
"k": "Move up a row/scroll down",
|
"k": "Move up a row/scroll down",
|
||||||
"l": "Jump to main area from sidebar",
|
"h": "Jump to main area from sidebar",
|
||||||
"h": "Jump to sidebar from main area",
|
"l": "Jump to sidebar from main area",
|
||||||
"g": "Jump to first row/top of page",
|
"g": "Jump to first row/top of page",
|
||||||
"G": "Jump to last row/bottom of page",
|
"G": "Jump to last row/bottom of page",
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@ description = "DayZ server browser and mod manager for Linux"
|
|||||||
authors = [
|
authors = [
|
||||||
{name = "aclist"}
|
{name = "aclist"}
|
||||||
]
|
]
|
||||||
version = "7.0.0b13"
|
version = "7.0.0b15"
|
||||||
license = "GPL-3.0-or-later"
|
license = "GPL-3.0-or-later"
|
||||||
license-files = ["LICENSE"]
|
license-files = ["LICENSE"]
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
|||||||
@@ -0,0 +1,87 @@
|
|||||||
|
import pytest
|
||||||
|
import tempfile
|
||||||
|
import os
|
||||||
|
|
||||||
|
from dzgui.app_init import copy_bare_configs
|
||||||
|
from dzgui.config.xdg import get_xdg_paths, parse_filepaths
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
|
CONF_STRING = "DZGUI_CONF\n"
|
||||||
|
STATE_STRING = "DZGUI_STATE\n"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def state_files():
|
||||||
|
state = [
|
||||||
|
"dzg.history",
|
||||||
|
"dzg.versions",
|
||||||
|
"dzg.res.json",
|
||||||
|
"dzg.filters.json",
|
||||||
|
"dzg.columns.json",
|
||||||
|
"dzg.notes.json",
|
||||||
|
"ips.csv",
|
||||||
|
".month",
|
||||||
|
]
|
||||||
|
return state
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def xdg_paths():
|
||||||
|
paths = []
|
||||||
|
routes = {
|
||||||
|
"XDG_CONFIG_HOME": "",
|
||||||
|
"XDG_STATE_HOME": "",
|
||||||
|
"XDG_DATA_HOME": "",
|
||||||
|
"XDG_CACHE_HOME": "",
|
||||||
|
}
|
||||||
|
for route in routes:
|
||||||
|
tmp = tempfile.TemporaryDirectory(delete=False)
|
||||||
|
routes[route] = tmp.name
|
||||||
|
for k, v in routes.items():
|
||||||
|
os.environ[k] = v
|
||||||
|
env = get_xdg_paths()
|
||||||
|
return parse_filepaths(env)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.mods
|
||||||
|
def test_config_file_import(xdg_paths, state_files):
|
||||||
|
|
||||||
|
# NOTE: write bare files in root
|
||||||
|
tmp_conf = xdg_paths.config.parent.parent
|
||||||
|
tmp_conf_file = tmp_conf / xdg_paths.config.name
|
||||||
|
tmp_conf_file.write_text(CONF_STRING)
|
||||||
|
|
||||||
|
tmp_state = xdg_paths.resolution.parent.parent
|
||||||
|
for file in state_files:
|
||||||
|
tmp_state.joinpath(file).write_text(STATE_STRING)
|
||||||
|
# NOTE: function should move files into "dzgui" subdirectory
|
||||||
|
config_changed, state_changed = copy_bare_configs(
|
||||||
|
xdg_paths.config, xdg_paths.resolution
|
||||||
|
)
|
||||||
|
|
||||||
|
assert xdg_paths.config.read_text() == CONF_STRING
|
||||||
|
for file in state_files:
|
||||||
|
expected = xdg_paths.resolution.parent.joinpath(file)
|
||||||
|
assert expected.read_text() == STATE_STRING
|
||||||
|
|
||||||
|
assert config_changed is True
|
||||||
|
assert state_changed is True
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.mods
|
||||||
|
def test_config_file_no_import(xdg_paths, state_files):
|
||||||
|
for subdir in xdg_paths.config.parent, xdg_paths.resolution.parent:
|
||||||
|
subdir.mkdir()
|
||||||
|
|
||||||
|
tmp_conf_file = xdg_paths.config
|
||||||
|
tmp_conf_file.write_text(CONF_STRING)
|
||||||
|
|
||||||
|
for file in state_files:
|
||||||
|
xdg_paths.resolution.parent.joinpath(file).write_text(STATE_STRING)
|
||||||
|
|
||||||
|
config_changed, state_changed = copy_bare_configs(
|
||||||
|
xdg_paths.config, xdg_paths.resolution
|
||||||
|
)
|
||||||
|
assert config_changed is False
|
||||||
|
assert state_changed is False
|
||||||
Reference in new issue
Block a user