fix: fix various issues before merging
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import os
|
||||
from dataclasses import dataclass
|
||||
|
||||
DEFAULT_LIBLIB_TEMPLATE_UUID = "5d7e67009b344550bc1aa6ccbfa1d7f4"
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class MemoirImageSettings:
|
||||
@@ -17,13 +19,19 @@ class MemoirImageSettings:
|
||||
def from_env(cls) -> "MemoirImageSettings":
|
||||
return cls(
|
||||
enabled=os.getenv("MEMOIR_IMAGE_ENABLED", "").lower() in {"1", "true", "yes"},
|
||||
max_per_chapter=int(os.getenv("MEMOIR_IMAGE_MAX_PER_CHAPTER", "2")),
|
||||
max_per_chapter=_get_int_env("MEMOIR_IMAGE_MAX_PER_CHAPTER", 2),
|
||||
provider=os.getenv("MEMOIR_IMAGE_PROVIDER", "liblib"),
|
||||
default_style=os.getenv("MEMOIR_IMAGE_STYLE_DEFAULT", "watercolor"),
|
||||
default_size=os.getenv("MEMOIR_IMAGE_SIZE_DEFAULT", "1280x720"),
|
||||
poll_interval_seconds=int(os.getenv("MEMOIR_IMAGE_POLL_INTERVAL", "3")),
|
||||
max_attempts=int(os.getenv("MEMOIR_IMAGE_MAX_ATTEMPTS", "60")),
|
||||
liblib_template_uuid=os.getenv(
|
||||
"LIBLIB_TEMPLATE_UUID", "5d7e67009b344550bc1aa6ccbfa1d7f4"
|
||||
),
|
||||
poll_interval_seconds=_get_int_env("MEMOIR_IMAGE_POLL_INTERVAL", 3),
|
||||
max_attempts=_get_int_env("MEMOIR_IMAGE_MAX_ATTEMPTS", 60),
|
||||
liblib_template_uuid=os.getenv("LIBLIB_TEMPLATE_UUID") or DEFAULT_LIBLIB_TEMPLATE_UUID,
|
||||
)
|
||||
|
||||
|
||||
def _get_int_env(name: str, default: int) -> int:
|
||||
value = os.getenv(name, str(default))
|
||||
try:
|
||||
return int(value)
|
||||
except (TypeError, ValueError):
|
||||
return default
|
||||
|
||||
Reference in New Issue
Block a user