From 137d55b6f030d4f4ebcb82569fa8da7cdfa53bee Mon Sep 17 00:00:00 2001 From: Buried-In-Code Date: Thu, 26 Nov 2026 09:27:45 +1300 Subject: [PATCH 1/3] Fix settings being overridden by tests --- perdoo/settings.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/perdoo/settings.py b/perdoo/settings.py index 75de5e8..eabad36 100644 --- a/perdoo/settings.py +++ b/perdoo/settings.py @@ -2,7 +2,7 @@ from enum import StrEnum from pathlib import Path -from typing import Annotated, ClassVar, Literal, Self, get_args +from typing import Annotated, Literal, Self, get_args from msgspec import Meta, Struct, ValidationError, convert, field, structs, to_builtins from msgspec.toml import decode, encode @@ -61,14 +61,12 @@ class Services(Struct, rename="kebab"): class Sync(Struct, rename="kebab"): cover_hash_distance: Annotated[ - int, Meta(ge=0, le=64, description="'cover-hash-distance' must be between 0 and 64") + int, Meta(ge=0, le=20, description="'cover-hash-distance' must be between 0 and 20") ] = 10 days: Annotated[int, Meta(ge=7, description="'days' must be greater than 6")] = 28 class Settings(Struct, rename="kebab"): - _file: ClassVar[Path] = get_config_home() / "settings.toml" - output: Output = field(default_factory=Output) removals: list[str] = field( default_factory=lambda: ["*.db", "*.ini", "*.nfo", "*.sfv", ".DS_Store"] @@ -76,24 +74,29 @@ class Settings(Struct, rename="kebab"): services: Services = field(default_factory=Services) sync: Sync = field(default_factory=Sync) + @classmethod + def _file(cls) -> Path: + return get_config_home() / "settings.toml" + @property def path(self) -> Path: - return self._file + return self._file() @classmethod def load(cls) -> "Settings": - if not cls._file.exists(): + file = cls._file() + if not file.exists(): return cls().save() try: return convert( - _restore_none(value=decode(cls._file.read_bytes()), struct_type=cls), + _restore_none(value=decode(file.read_bytes()), struct_type=cls), type=cls, dec_hook=lambda typ, obj: ( Path(obj) if typ is Path and isinstance(obj, str) else obj ), ) except ValidationError as err: - raise ValueError(f"Invalid settings file {cls._file}: {err}") from err + raise ValueError(f"Invalid settings file {file}: {err}") from err def save(self) -> Self: def encoder(obj: object) -> object: @@ -123,7 +126,7 @@ def encoder(obj: object) -> object: ] CONSOLE.print(Panel.fit("\n".join(default_vals), title="Default Settings")) - CONSOLE.print(Panel.fit("\n".join(override_vals), title=str(cls._file))) + CONSOLE.print(Panel.fit("\n".join(override_vals), title=str(cls._file()))) def _toml_serializable(value: object) -> object: From ee024d2482d3e3bd5a7a6123c267e520ccc7a184 Mon Sep 17 00:00:00 2001 From: Buried-In-Code Date: Thu, 26 Nov 2026 22:39:29 +1300 Subject: [PATCH 2/3] Improve printing of files in archives --- perdoo/cli/convert/images.py | 5 ++++- perdoo/cli/rename.py | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/perdoo/cli/convert/images.py b/perdoo/cli/convert/images.py index de8fa1d..dc1f566 100644 --- a/perdoo/cli/convert/images.py +++ b/perdoo/cli/convert/images.py @@ -69,7 +69,10 @@ def convert_comic_images( continue comic.write_file(filename=new_name, data=data) comic.remove_file(filename=name) - CONSOLE.print(f"Converted {name!r} to {new_name!r}") + CONSOLE.print( + f"Converted '{comic.file.name}!/{name}' to '{comic.file.name}!/{new_name}'", + style="logging.level.info", + ) existing.add(new_name) changed += 1 if failed: diff --git a/perdoo/cli/rename.py b/perdoo/cli/rename.py index 94a5fc3..ee824ed 100644 --- a/perdoo/cli/rename.py +++ b/perdoo/cli/rename.py @@ -42,7 +42,10 @@ def rename_comic(comic: Comic, image_exts: Sequence[str]) -> bool: new_name = f"{str(idx).zfill(pad)}{standardize_image_suffix(suffix)}" idx += 1 if filename != new_name: - CONSOLE.print(f"Renaming {filename!r} to {new_name!r}") + CONSOLE.print( + f"Renaming '{comic.file.name}!/{filename}' to '{comic.file.name}!/{new_name}''", # noqa: E501 + style="logging.level.info", + ) comic.rename_file(filename=filename, new_name=new_name, override=True) renamed = True except ArchiveCapabilityError as err: From c454813b97a7f2f94a047413b6c913a496ab050d Mon Sep 17 00:00:00 2001 From: Buried-In-Code Date: Thu, 26 Nov 2026 22:42:28 +1300 Subject: [PATCH 3/3] Reduce cover-hash-distance max to 20 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e9ba85e..3819819 100644 --- a/README.md +++ b/README.md @@ -374,7 +374,7 @@ Defaults to `28`. The maximum Hamming distance accepted when matching an archive cover. -Defaults to `10`. Supported values range from `0` to `64`. +Defaults to `10`. Supported values range from `0` to `20`. ## Socials