mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2026-10-22 17:22:09 +03:00
[#2615] Prevent Linux NONE Toml Config Crash
This commit is contained in:
6 files changed
+36
-6
No files matched your search
@@ -276,6 +276,12 @@
|
||||
/* coriolis.py: 'Normal' label for Coriolis site override selection; coriolis.py: Coriolis normal/beta selection - normal; In files: coriolis.py:49; coriolis.py:75; coriolis.py:95; coriolis.py:121; coriolis.py:137; coriolis.py:180; */
|
||||
"Normal" = "Normal";
|
||||
|
||||
/* coriolis.py: Settings>Coriolis: API key label */
|
||||
"Coriolis CMDR API Key" = "Coriolis CMDR API Key";
|
||||
|
||||
/* coriolis.py: Settings>Coriolis: checkbox to enable sending data to Coriolis CMDR */
|
||||
"Send ship, module, and material data to Coriolis CMDR" = "Send ship, module, and material data to Coriolis CMDR";
|
||||
|
||||
/* coriolis.py: 'Beta' label for Coriolis site override selection; coriolis.py: Coriolis normal/beta selection - beta; In files: coriolis.py:50; coriolis.py:76; coriolis.py:96; coriolis.py:122; coriolis.py:138; coriolis.py:181; */
|
||||
"Beta" = "Beta";
|
||||
|
||||
|
||||
+2
-2
@@ -670,10 +670,10 @@ class Session:
|
||||
if IS_FROZEN:
|
||||
tk.messagebox.showinfo( # type: ignore
|
||||
title=tr.tl("Authentication Successful"), # LANG: Messagebox title authentication successful
|
||||
message=tr.tl(
|
||||
message=tr.tl( # LANG: Messagebox body after successful CAPI authentication
|
||||
"Authentication with cAPI Successful.{CR}"
|
||||
"You may now close the Frontier login tab if it is still open."
|
||||
).format(CR="\n") # LANG: Messagebox body after successful CAPI authentication
|
||||
).format(CR="\n")
|
||||
)
|
||||
|
||||
def close(self) -> None:
|
||||
|
||||
+5
-1
@@ -563,7 +563,11 @@ class Config:
|
||||
|
||||
def set(self, key: str, value: Any):
|
||||
"""Modify a setting and save to disk."""
|
||||
if not isinstance(value, (str, int, float, bool, list, dict, type(None))):
|
||||
if value is None:
|
||||
self.delete(key, suppress=True)
|
||||
return
|
||||
|
||||
if not isinstance(value, (str, int, float, bool, list, dict)):
|
||||
raise TypeError(
|
||||
f"Unsupported config value type for {key!r}: {type(value).__name__}"
|
||||
)
|
||||
|
||||
+2
-2
@@ -202,10 +202,10 @@ def plugin_prefs(parent: ttk.Notebook, cmdr: str | None, is_beta: bool) -> nb.Fr
|
||||
)
|
||||
cur_row += 1
|
||||
|
||||
# LANG: Settings>Coriolis: checkbox to enable sending data to Coriolis CMDR
|
||||
coriolis_config.cmdr_sync_button = nb.Checkbutton(
|
||||
conf_frame,
|
||||
text=tr.tl('Send ship, module and material data to Coriolis CMDR'),
|
||||
# LANG: Settings>Coriolis: checkbox to enable sending data to Coriolis CMDR
|
||||
text=tr.tl('Send ship, module, and material data to Coriolis CMDR'),
|
||||
variable=coriolis_config.cmdr_sync,
|
||||
command=_prefs_cmdr_sync_changed,
|
||||
)
|
||||
|
||||
@@ -171,3 +171,23 @@ def test_init_platform_calls_linux_helper(mock_app_dir):
|
||||
Config(mock_app_dir)
|
||||
|
||||
mock_module.linux_helper.assert_called_once()
|
||||
|
||||
|
||||
def test_set_none_deletes_key(mock_app_dir):
|
||||
"""Test that calling set(key, None) deletes the key from config."""
|
||||
with patch("config.Config._init_platform"):
|
||||
cfg = Config(mock_app_dir)
|
||||
|
||||
# Set a key first
|
||||
cfg.set("some_temp_key", "value")
|
||||
assert cfg.get("some_temp_key") == "value"
|
||||
|
||||
# Set it to None, which should delete it
|
||||
cfg.set("some_temp_key", None)
|
||||
assert cfg.get("some_temp_key") is None
|
||||
|
||||
# Verify disk persistence does not have it either
|
||||
with open(cfg.toml_path, "rb") as f:
|
||||
import tomllib
|
||||
data = tomllib.load(f)
|
||||
assert "some_temp_key" not in data["settings"]
|
||||
Reference in new issue
Block a user