Skip to content

Commit 8f9c353

Browse files
committed
refactor: remove batch_mode and locale from configuration
1 parent fbfc2b5 commit 8f9c353

File tree

8 files changed

+27
-83
lines changed

8 files changed

+27
-83
lines changed

docs/architecture/configuration.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ Default values and where they are defined
4141
config_version = 1.0.0
4242
max_concurrent_downloads = 5
4343
max_backup = 1
44-
batch_mode = true
45-
locale = en_US
4644
log_level = INFO
4745
console_log_level = WARNING
4846
[network]

docs/wiki.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -218,13 +218,6 @@ max_concurrent_downloads = 5
218218
# Maximum number of backups to keep for each AppImage.
219219
max_backup = 1
220220

221-
# Enables batch mode for downloading AppImages without user interaction.
222-
batch_mode = true
223-
224-
# Locale for the user interface and messages.
225-
# Supported languages: English (en_US)
226-
locale = "en_US"
227-
228221
# Logging level for the application.
229222
# Supported levels: DEBUG, INFO, WARNING, ERROR
230223
log_level = "INFO"

my_unicorn/commands/config.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ async def _show_config(self) -> None:
2626
"""Display current configuration."""
2727
print("📋 Current Configuration:")
2828
print(f" Config Version: {self.global_config['config_version']}")
29-
print(f" Max Downloads: {self.global_config['max_concurrent_downloads']}")
30-
print(f" Batch Mode: {self.global_config['batch_mode']}")
29+
print(
30+
f" Max Downloads: {self.global_config['max_concurrent_downloads']}"
31+
)
3132
print(f" Log Level: {self.global_config['log_level']}")
3233
print(f" Storage Dir: {self.global_config['directory']['storage']}")
3334
print(f" Download Dir: {self.global_config['directory']['download']}")

my_unicorn/config.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,15 @@
2424
CONFIG_FILE_NAME,
2525
CONFIG_VERSION,
2626
DEFAULT_APPS_DIR_NAME,
27-
DEFAULT_BATCH_MODE,
2827
DEFAULT_CONFIG_SUBDIR,
2928
DEFAULT_CONSOLE_LOG_LEVEL,
30-
DEFAULT_LOCALE,
3129
DEFAULT_LOG_LEVEL,
3230
DEFAULT_MAX_BACKUP,
3331
DEFAULT_MAX_CONCURRENT_DOWNLOADS,
3432
DIRECTORY_KEYS,
3533
ISO_DATETIME_FORMAT,
36-
KEY_BATCH_MODE,
3734
KEY_CONFIG_VERSION,
3835
KEY_CONSOLE_LOG_LEVEL,
39-
KEY_LOCALE,
4036
KEY_LOG_LEVEL,
4137
KEY_MAX_BACKUP,
4238
KEY_MAX_CONCURRENT_DOWNLOADS,
@@ -96,8 +92,6 @@ def get_section_comments() -> dict[str, str]:
9692
# config_version: Version of configuration format (DO NOT EDIT)
9793
# max_concurrent_downloads: Max simultaneous downloads (1-10)
9894
# max_backup: Number of backup copies to keep when updating apps (0-5)
99-
# batch_mode: Enable non-interactive mode (true/false)
100-
# locale: Language setting (en_US, es_ES, fr_FR, etc.)
10195
# log_level: Detail level for log files (DEBUG, INFO, WARNING, ERROR)
10296
# console_log_level: Console output detail level (DEBUG, INFO, etc.)
10397
@@ -178,8 +172,6 @@ class GlobalConfig(TypedDict):
178172
config_version: str
179173
max_concurrent_downloads: int
180174
max_backup: int
181-
batch_mode: bool
182-
locale: str
183175
log_level: str
184176
console_log_level: str
185177
network: NetworkConfig
@@ -384,8 +376,6 @@ def get_default_global_config(self) -> dict[str, str | dict[str, str]]:
384376
DEFAULT_MAX_CONCURRENT_DOWNLOADS
385377
),
386378
KEY_MAX_BACKUP: str(DEFAULT_MAX_BACKUP),
387-
KEY_BATCH_MODE: str(DEFAULT_BATCH_MODE).lower(),
388-
KEY_LOCALE: DEFAULT_LOCALE,
389379
KEY_LOG_LEVEL: DEFAULT_LOG_LEVEL,
390380
KEY_CONSOLE_LOG_LEVEL: DEFAULT_CONSOLE_LOG_LEVEL,
391381
SECTION_NETWORK: {"retry_attempts": "3", "timeout_seconds": "10"},
@@ -507,8 +497,6 @@ def save_global_config(self, config: GlobalConfig) -> None:
507497
config["max_concurrent_downloads"]
508498
),
509499
"max_backup": str(config["max_backup"]),
510-
"batch_mode": str(config["batch_mode"]).lower(),
511-
"locale": config["locale"],
512500
"log_level": config["log_level"],
513501
"console_log_level": config["console_log_level"],
514502
}
@@ -640,14 +628,6 @@ def get_scalar_config(key: str, default: str | int) -> str | int:
640628
else 10,
641629
)
642630

643-
# Get batch mode value
644-
batch_mode_str = get_scalar_config("batch_mode", "true")
645-
batch_mode = (
646-
batch_mode_str.lower() == "true"
647-
if isinstance(batch_mode_str, str)
648-
else True
649-
)
650-
651631
return GlobalConfig(
652632
config_version=str(
653633
get_scalar_config("config_version", CONFIG_VERSION)
@@ -656,8 +636,6 @@ def get_scalar_config(key: str, default: str | int) -> str | int:
656636
get_scalar_config("max_concurrent_downloads", 5)
657637
),
658638
max_backup=int(get_scalar_config("max_backup", 1)),
659-
batch_mode=batch_mode,
660-
locale=str(get_scalar_config("locale", "en_US")),
661639
log_level=str(get_scalar_config("log_level", "INFO")),
662640
console_log_level=str(
663641
get_scalar_config("console_log_level", "WARNING")

my_unicorn/constants.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@
3636
# Defaults used by the global config manager
3737
DEFAULT_MAX_CONCURRENT_DOWNLOADS: Final[int] = 5
3838
DEFAULT_MAX_BACKUP: Final[int] = 1
39-
DEFAULT_BATCH_MODE: Final[bool] = True
40-
DEFAULT_LOCALE: Final[str] = "en_US"
4139
DEFAULT_CONSOLE_LOG_LEVEL: Final[str] = "WARNING"
4240

4341
# Date/time formats used in config headers and saved timestamps
@@ -51,8 +49,6 @@
5149
KEY_CONFIG_VERSION: Final[str] = "config_version"
5250
KEY_MAX_CONCURRENT_DOWNLOADS: Final[str] = "max_concurrent_downloads"
5351
KEY_MAX_BACKUP: Final[str] = "max_backup"
54-
KEY_BATCH_MODE: Final[str] = "batch_mode"
55-
KEY_LOCALE: Final[str] = "locale"
5652
KEY_LOG_LEVEL: Final[str] = "log_level"
5753
KEY_CONSOLE_LOG_LEVEL: Final[str] = "console_log_level"
5854

scripts/update.bash

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,6 @@
44
# in the ~/.config/my-unicorn/apps directory.
55
# You need to install the apps first to use this script.
66
#
7-
# Make sure you enabled batch mode if you want to run this
8-
# script in an automated fashion (e.g. via cron or a window
9-
# manager autostart). Batch mode already defaults to true
10-
# in the ~/.config/my-unicorn/settings.conf file.
11-
#
12-
# "batch_mode": true,
13-
#
147
# Author: Cyber-Syntax
158
# License: same as my-unicorn project
169

tests/commands/test_config.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ def load_global_config(self):
4040
return {
4141
"config_version": "1.0",
4242
"max_concurrent_downloads": 5,
43-
"batch_mode": True,
4443
"log_level": "INFO",
4544
"directory": {
4645
"storage": "/tmp/storage",
@@ -77,7 +76,7 @@ async def test_execute_show(monkeypatch, handler, capsys):
7776
assert "📋 Current Configuration:" in captured.out
7877
assert "Config Version: 1.0" in captured.out
7978
assert "Max Downloads: 5" in captured.out
80-
assert "Batch Mode: True" in captured.out
79+
8180
assert "Log Level: INFO" in captured.out
8281
assert "/tmp/storage" in captured.out
8382
assert "/tmp/download" in captured.out

tests/test_config.py

Lines changed: 23 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,6 @@ def test_ensure_directories_from_config(config_manager, tmp_path):
206206
"config_version": "1.0.0",
207207
"max_concurrent_downloads": 5,
208208
"max_backup": 1,
209-
"batch_mode": True,
210-
"locale": "en_US",
211209
"log_level": "INFO",
212210
"network": {"retry_attempts": 3, "timeout_seconds": 10},
213211
"directory": dirs,
@@ -288,7 +286,6 @@ def test_comment_stripping_configparser(config_manager):
288286
"""Test that CommentAwareConfigParser correctly strips inline comments."""
289287
# Create a config file with inline comments
290288
config_content = """[DEFAULT]
291-
batch_mode = true # Non-interactive mode
292289
293290
[directory]
294291
logs = /test/logs # Log files directory
@@ -305,7 +302,6 @@ def test_comment_stripping_configparser(config_manager):
305302
parser.read(test_config_file)
306303

307304
# Verify that comments are stripped from values
308-
assert parser.get("DEFAULT", "batch_mode") == "true"
309305
assert parser.get("directory", "logs") == "/test/logs"
310306
assert parser.get("directory", "cache") == "/test/cache"
311307
assert parser.get("directory", "tmp") == "/test/tmp"
@@ -369,7 +365,6 @@ def test_global_config_manager(config_dir):
369365
raw_config = ConfigParser()
370366
raw_config.add_section("settings")
371367
raw_config.set("settings", "max_backup", "3")
372-
raw_config.set("settings", "locale", "en_US")
373368
converted = global_manager._convert_to_global_config(raw_config)
374369
assert "directory" in converted
375370
assert "network" in converted
@@ -580,7 +575,7 @@ def test_config_manager_facade_integration(config_dir):
580575
assert isinstance(default_config, dict)
581576

582577
# Test the global config manager conversion method by creating a proper config dict
583-
test_config = {"max_backup": "2", "locale": "en_US", "directory": {}}
578+
test_config = {"max_backup": "2", "directory": {}}
584579
converted_config = (
585580
config_manager.global_config_manager._convert_to_global_config(
586581
test_config
@@ -661,7 +656,6 @@ def test_merge_missing_fields(config_dir):
661656
# Start with minimal config using proper ConfigParser syntax
662657
user_config.read_string("""[DEFAULT]
663658
config_version = 1.0.0
664-
locale = en_US
665659
""")
666660

667661
defaults = manager.get_default_global_config()
@@ -740,7 +734,6 @@ def test_configuration_migration_integration(config_dir):
740734
# Create old configuration file missing some fields
741735
old_config_content = """[DEFAULT]
742736
config_version = 1.0.0
743-
locale = fr_FR
744737
max_backup = 3
745738
746739
[network]
@@ -756,7 +749,6 @@ def test_configuration_migration_integration(config_dir):
756749

757750
# Verify configuration was migrated
758751
assert config["config_version"] == "1.0.2" # Should be updated
759-
assert config["locale"] == "fr_FR" # User value preserved
760752
assert config["max_backup"] == 3 # User value preserved
761753
assert config["network"]["retry_attempts"] == 5 # User value preserved
762754

@@ -791,7 +783,6 @@ def mock_validate_failure(config):
791783

792784
old_config_content = """[DEFAULT]
793785
config_version = 1.0.0
794-
locale = test_locale
795786
"""
796787
manager.directory_manager.settings_file.write_text(old_config_content)
797788

@@ -817,7 +808,6 @@ def test_migration_with_new_config_file(config_dir):
817808

818809
# Should create default configuration
819810
assert config["config_version"] == "1.0.2"
820-
assert config["locale"] == "en_US"
821811
assert manager.directory_manager.settings_file.exists()
822812

823813

@@ -827,30 +817,28 @@ def test_migration_no_changes_needed(config_dir):
827817

828818
# Create current configuration file with all required fields
829819
complete_config_content = """[DEFAULT]
830-
config_version = 1.0.2
831-
max_concurrent_downloads = 5
832-
max_backup = 1
833-
batch_mode = true
834-
locale = en_US
835-
log_level = INFO
836-
console_log_level = WARNING
837-
838-
[network]
839-
retry_attempts = 3
840-
timeout_seconds = 10
841-
842-
[directory]
843-
repo = /tmp/test-repo
844-
package = /tmp/test-package
845-
download = /tmp/downloads
846-
storage = /tmp/storage
847-
backup = /tmp/backup
848-
icon = /tmp/icons
849-
settings = /tmp/settings
850-
logs = /tmp/logs
851-
cache = /tmp/cache
852-
tmp = /tmp/tmp
853-
"""
820+
config_version = 1.0.2
821+
max_concurrent_downloads = 5
822+
max_backup = 1
823+
log_level = INFO
824+
console_log_level = WARNING
825+
826+
[network]
827+
retry_attempts = 3
828+
timeout_seconds = 10
829+
830+
[directory]
831+
repo = /tmp/test-repo
832+
package = /tmp/test-package
833+
download = /tmp/downloads
834+
storage = /tmp/storage
835+
backup = /tmp/backup
836+
icon = /tmp/icons
837+
settings = /tmp/settings
838+
logs = /tmp/logs
839+
cache = /tmp/cache
840+
tmp = /tmp/tmp
841+
"""
854842

855843
manager.directory_manager.settings_file.write_text(complete_config_content)
856844

@@ -915,7 +903,6 @@ def test_comment_stripping_functionality(config_dir, tmp_path):
915903
config_content = """[DEFAULT]
916904
max_concurrent_downloads = 10 # Max simultaneous downloads
917905
max_backup = 3 # Number of backup copies to keep
918-
batch_mode = false # Non-interactive mode
919906
920907
[network]
921908
retry_attempts = 5 # Download retry attempts
@@ -932,7 +919,6 @@ def test_comment_stripping_functionality(config_dir, tmp_path):
932919

933920
assert config["max_concurrent_downloads"] == 10
934921
assert config["max_backup"] == 3
935-
assert config["batch_mode"] is False
936922
assert config["network"]["retry_attempts"] == 5
937923
assert config["network"]["timeout_seconds"] == 30
938924
assert str(config["directory"]["download"]) == "/tmp/downloads"

0 commit comments

Comments
 (0)